[英]AdView slows down whole app, possible reason
I have WebView + ListView and AdView below of screen.我在屏幕下方有 WebView + ListView 和 AdView。 WebView or ListView works terrible laggy on older devices (4.0-4.3 Android) until AdView gets loaded, then it works very smoothly. WebView 或 ListView 在旧设备(Android 4.0-4.3)上运行非常缓慢,直到 AdView 被加载,然后它才能非常流畅地运行。
Logcat shows that AdMob try to load something incredibly often with no success until.. success and then app is smooth. Logcat 显示,AdMob 经常尝试加载一些令人难以置信的内容,但一直没有成功,直到..成功,然后应用程序才流畅。 May it be a reason?可能是一个原因吗? How to fix it?如何解决?
10-10 01:02:20.954 7160-7214/com.test.test V/webcore﹕ webkitDraw NEW_PICTURE_MSG_ID
10-10 01:02:20.964 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:20.974 7160-7214/com.test.test V/webcore﹕ webkitDraw start
10-10 01:02:20.974 7160-7214/com.test.test V/webcore﹕ webkitDraw NEW_PICTURE_MSG_ID
10-10 01:02:21.004 7160-7160/com.test.test V/webview﹕ NEW_PICTURE_MSG_ID
10-10 01:02:21.004 7160-7160/com.test.test V/webview﹕ NEW_PICTURE_MSG_ID
10-10 01:02:21.004 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:21.004 7160-7214/com.test.test V/webcore﹕ webkitDraw start
10-10 01:02:21.014 7160-7214/com.test.test V/webcore﹕ webkitDraw NEW_PICTURE_MSG_ID
10-10 01:02:21.024 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:21.024 7160-7214/com.test.test V/webcore﹕ webkitDraw start
10-10 01:02:21.044 7160-7214/com.test.test V/webcore﹕ webkitDraw NEW_PICTURE_MSG_ID
10-10 01:02:21.044 7160-7160/com.test.test V/webview﹕ NEW_PICTURE_MSG_ID
10-10 01:02:21.054 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:21.054 7160-7214/com.test.test V/webcore﹕ webkitDraw start
10-10 01:02:21.054 7160-7160/com.test.test V/webview﹕ NEW_PICTURE_MSG_ID
10-10 01:02:21.054 7160-7214/com.test.test V/webcore﹕ webkitDraw NEW_PICTURE_MSG_ID
10-10 01:02:21.074 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:21.074 7160-7214/com.test.test V/webcore﹕ webkitDraw start
10-10 01:02:21.084 7160-7214/com.test.test V/webcore﹕ webkitDraw NEW_PICTURE_MSG_ID
10-10 01:02:21.084 7160-7160/com.test.test V/webview﹕ NEW_PICTURE_MSG_ID
10-10 01:02:21.094 7160-7160/com.test.test V/webview﹕ NEW_PICTURE_MSG_ID
10-10 01:02:21.104 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:21.114 7160-7214/com.test.test V/webcore﹕ webkitDraw start
10-10 01:02:21.114 7160-7214/com.test.test V/webcore﹕ webkitDraw NEW_PICTURE_MSG_ID
10-10 01:02:21.124 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:21.134 7160-7160/com.test.test V/webview﹕ NEW_PICTURE_MSG_ID
10-10 01:02:21.134 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:21.144 7160-7214/com.test.test V/webcore﹕ webkitDraw start
10-10 01:02:21.144 7160-7214/com.test.test V/webcore﹕ webkitDraw NEW_PICTURE_MSG_ID
10-10 01:02:21.164 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:21.164 7160-7214/com.test.test V/webcore﹕ webkitDraw start
10-10 01:02:21.164 7160-7214/com.test.test V/webcore﹕ webkitDraw NEW_PICTURE_MSG_ID
10-10 01:02:21.174 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:21.184 7160-7160/com.test.test V/webview﹕ NEW_PICTURE_MSG_ID
10-10 01:02:21.184 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:21.184 7160-7214/com.test.test V/webcore﹕ webkitDraw start
10-10 01:02:21.194 7160-7214/com.test.test V/webcore﹕ webkitDraw NEW_PICTURE_MSG_ID
10-10 01:02:21.194 7160-7160/com.test.test V/webview﹕ NEW_PICTURE_MSG_ID
10-10 01:02:21.194 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:21.204 7160-7214/com.test.test V/webcore﹕ webkitDraw start
10-10 01:02:21.224 7160-7214/com.test.test V/webcore﹕ webkitDraw NEW_PICTURE_MSG_ID
10-10 01:02:21.234 7160-7160/com.test.test V/webview﹕ NEW_PICTURE_MSG_ID
10-10 01:02:21.234 7160-7160/com.test.test V/webview﹕ NEW_PICTURE_MSG_ID
10-10 01:02:22.754 7160-7163/com.test.test D/dalvikvm﹕ GC_CONCURRENT freed 380K, 12% free 7624K/8583K, paused 17ms+38ms, total 102ms
10-10 01:02:24.514 7160-7214/com.test.test V/webcore﹕ SET_BACKGROUND_COLOR arg1=0 arg2=0 obj=null
10-10 01:02:24.534 7160-7214/com.test.test V/webcore﹕ SET_ACTIVE arg1=0 arg2=0 obj=null
10-10 01:02:24.554 7160-7214/com.test.test V/webcore﹕ LOAD_DATA arg1=0 arg2=0 obj=android.webkit.WebViewCore$BaseUrlData@4163c488
10-10 01:02:24.564 7160-7160/com.test.test V/webview﹕ WEBCORE_INITIALIZED_MSG_ID
10-10 01:02:24.714 7160-7160/com.test.test V/webview﹕ setCertificate=null
10-10 01:02:24.744 7160-7160/com.test.test V/webview﹕ WEBCORE_NEED_TOUCH_EVENTS
10-10 01:02:24.894 7160-7160/com.test.test V/webview﹕ SELECTION_STRING_CHANGED
10-10 01:02:24.904 7160-7160/com.test.test V/webview﹕ SELECTION_STRING_CHANGED
10-10 01:02:24.904 7160-7160/com.test.test V/webview﹕ SELECTION_STRING_CHANGED
10-10 01:02:24.904 7160-7214/com.test.test V/webcore﹕ didFirstLayout standardLoad =true
10-10 01:02:24.904 7160-7214/com.test.test V/webcore﹕ Can't get the viewWidth yet
10-10 01:02:24.914 7160-7160/com.test.test V/webview﹕ SAVE_WEBARCHIVE_FINISHED
10-10 01:02:25.064 7160-7160/com.test.test I/Ads﹕ Scheduling ad refresh 60000 milliseconds from now.
10-10 01:02:25.084 7160-7214/com.test.test V/webcore﹕ LOAD_URL arg1=0 arg2=0 obj=android.webkit.WebViewCore$GetUrlData@41679bd8
10-10 01:02:25.084 7160-7214/com.test.test V/webcore﹕ CORE loadUrl about:blank
10-10 01:02:25.224 7160-7214/com.test.test V/webcore﹕ didFirstLayout standardLoad =true
10-10 01:02:25.234 7160-7214/com.test.test V/webcore﹕ setupViewport mRestoredScale=0.0 mViewScale=1.0 mTextWrapScale=1.0 data.mScale= 1.0
10-10 01:02:25.234 7160-7214/com.test.test V/webcore﹕ viewSizeChanged w=320; h=50; textwrapWidth=320; scale=1.0
10-10 01:02:25.244 7160-7214/com.test.test V/webcore﹕ WEBKIT_DRAW arg1=0 arg2=0 obj=null
10-10 01:02:25.254 7160-7214/com.test.test V/webcore﹕ webkitDraw start
10-10 01:02:25.254 7160-7214/com.test.test V/webcore﹕ webkitDraw NEW_PICTURE_MSG_ID
10-10 01:02:25.254 7160-7214/com.test.test V/webcore﹕ LOAD_URL arg1=0 arg2=0 obj=android.webkit.WebViewCore$GetUrlData@417630d8
10-10 01:02:25.264 7160-7214/com.test.test V/webcore﹕ CORE loadUrl javascript:AFMA_updateActiveView({"units":[{"viewBox":{"bottom":480,"right":320,"left":0,"top":0},"isScreenOn":true,"isPaused":false,"adFormat":"320x50_as","localVisibleBoxVisible":false,"activeViewJSON":{"click_string":"BBggidEcYVtTJNpG6pAPDj7qgBAD1k7K5qQIAABABOAHIAQPIA4gEoAYD","active_experiment_ids":"","is_active_view_immediate_enabled":true,"activeview_cpm_urls":[]},"hashCode":"a096ae7d-5728-4f8b-9c0b-95ea0edc1618","afmaVersion":"afma-sdk-a-v8115000.8115000.0","windowVisibility":0,"screenDensity":1,"localVisibleBox":{"bottom":0,"right":0,"left":0,"top":0},"isAttachedToWindow":true,"timestamp":13403686,"globalVisibleBox":{"bottom":0,"right":0,"left":0,"top":0},"isVisible":true,"adBox":{"bottom":430,"right":0,"left":0,"top":430},"hitBox":{"bottom":0,"right":0,"left":0,"top":0},"isMraid":false,"globalVisibleBoxVisible":false,"isStopped":false}]});
10-10 01:02:25.364 7160-7160/com.test.test I/Ads﹕ Ad finished loading.
10-10 01:02:25.594 7160-7160/com.test.test V/webview﹕ setCertificate=null
10-10 01:02:25.594 7160-7160/com.test.test V/webview﹕ WEBCORE_NEED_TOUCH_EVENTS
10-10 01:02:25.594 7160-7160/com.test.test V/webview﹕ SELECTION_STRING_CHANGED
10-10 01:02:25.594 7160-7160/com.test.test V/webview﹕ SELECTION_STRING_CHANGED
10-10 01:02:25.594 7160-7160/com.test.test V/webview﹕ SELECTION_STRING_CHANGED
10-10 01:02:25.604 7160-7160/com.test.test V/webview﹕ SAVE_WEBARCHIVE_FINISHED
10-10 01:02:25.604 7160-7160/com.test.test V/webview﹕ NEW_PICTURE_MSG_ID
10-10 01:02:25.644 7160-7160/com.test.test V/webview﹕ sendOurVisibleRect=(0,430,r=320,b=480
10-10 01:02:25.664 7160-7163/com.test.test D/dalvikvm﹕ GC_CONCURRENT freed 324K, 11% free 7716K/8583K, paused 24ms+32ms, total 130ms
10-10 01:02:26.434 7160-7214/com.test.test V/webcore﹕ LOAD_URL arg1=0 arg2=0 obj=android.webkit.WebViewCore$GetUrlData@416f4320
10-10 01:02:26.434 7160-7214/com.test.test V/webcore﹕ CORE loadUrl javascript:AFMA_updateActiveView({"units":[{"viewBox":{"bottom":480,"right":320,"left":0,"top":0},"isScreenOn":true,"isPaused":false,"adFormat":"320x50_as","localVisibleBoxVisible":false,"activeViewJSON":{"click_string":"BBggidEcYVtTJNpG6pAPDj7qgBAD1k7K5qQIAABABOAHIAQPIA4gEoAYD","active_experiment_ids":"","is_active_view_immediate_enabled":true,"activeview_cpm_urls":[]},"hashCode":"a096ae7d-5728-4f8b-9c0b-95ea0edc1618","afmaVersion":"afma-sdk-a-v8115000.8115000.0","windowVisibility":0,"screenDensity":1,"localVisibleBox":{"bottom":0,"right":0,"left":0,"top":0},"isAttachedToWindow":true,"timestamp":13403836,"globalVisibleBox":{"bottom":0,"right":0,"left":0,"top":0},"isVisible":true,"adBox":{"bottom":430,"right":0,"left":0,"top":430},"hitBox":{"bottom":0,"right":0,"left":0,"top":0},"isMraid":false,"globalVisibleBoxVisible":false,"isStopped":false}]});
10-10 01:02:26.474 7160-7214/com.test.test V/webcore﹕ LOAD_URL arg1=0 arg2=0 obj=android.webkit.WebViewCore$GetUrlData@416d1eb8
10-10 01:02:26.474 7160-7214/com.test.test V/webcore﹕ CORE loadUrl javascript:AFMA_updateActiveView({"units":[{"viewBox":{"bottom":480,"right":320,"left":0,"top":0},"isScreenOn":true,"isPaused":false,"adFormat":"320x50_as","localVisibleBoxVisible":true,"activeViewJSON":{"click_string":"BBggidEcYVtTJNpG6pAPDj7qgBAD1k7K5qQIAABABOAHIAQPIA4gEoAYD","active_experiment_ids":"","is_active_view_immediate_enabled":true,"activeview_cpm_urls":[]},"hashCode":"a096ae7d-5728-4f8b-9c0b-95ea0edc1618","afmaVersion":"afma-sdk-a-v8115000.8115000.0","windowVisibility":0,"screenDensity":1,"localVisibleBox":{"bottom":50,"right":320,"left":0,"top":0},"isAttachedToWindow":true,"timestamp":13404006,"globalVisibleBox":{"bottom":480,"right":320,"left":0,"top":430},"isVisible":true,"adBox":{"bottom":480,"right":320,"left":0,"top":430},"hitBox":{"bottom":50,"right":320,"left":0,"top":0},"isMraid":false,"globalVisibleBoxVisible":true,"isStopped":false}]});
10-10 01:02:26.484 7160-7214/com.test.test V/webcore﹕ SET_SCROLL_OFFSET arg1=1 arg2=0 obj=Point(0, 0)
10-10 01:02:26.514 7160-7214/com.test.test V/webcore﹕ SET_GLOBAL_BOUNDS arg1=0 arg2=0 obj=Rect(0, 430 - 320, 480)
10-10 01:02:26.524 7160-7214/com.test.test V/webcore﹕ VIEW_SIZE_CHANGED arg1=0 arg2=0 obj=android.webkit.WebViewClassic$ViewSizeData@416f7348
10-10 01:02:26.524 7160-7214/com.test.test V/webcore﹕ viewSizeChanged w=320; h=50; textwrapWidth=320; scale=1.0
EDIT:编辑:
AdView is created in Activity.onCreate method. AdView 是在 Activity.onCreate 方法中创建的。 VISIBLE on start.开始时可见。 http://pastebin.com/xZ7C8WGK http://pastebin.com/xZ7C8WGK
I have a simple animation that runs when the app starts, it used to run smoothly before I put AdMob ads, apparently AdMob needs a lot of resources to start up.我有一个简单的动画,在应用程序启动时运行,它在我投放 AdMob 广告之前运行流畅,显然 AdMob 需要大量资源才能启动。
so my solution was to wait for the animations to end, then start loading the ad.所以我的解决方案是等待动画结束,然后开始加载广告。
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
AdRequest bannerRequest = new AdRequest.Builder().build();
mAdView.loadAd(bannerRequest);
}
},2000);
Admob is only slow at starting up, so this solved the start up lag. Admob 只是启动缓慢,因此解决了启动延迟问题。
Most likely it is a problem.很可能这是一个问题。 It can easily be checked by removing AdView (if I understand you correctly) I do not know the specifics of your application, but I advise you to try Crosswalk Project .可以通过删除 AdView 轻松检查它(如果我理解正确的话)我不知道您的应用程序的具体细节,但我建议您尝试Crosswalk Project 。
In general, work with the Admob to be synchronous, but you can try to use AsyncTask for its creation.一般来说,使用 Admob 是同步的,但您可以尝试使用 AsyncTask 来创建它。 Alternatively, you can try to run ads immediately, but after some time.或者,您可以尝试立即投放广告,但要在一段时间后投放。
Still I can advise to try to use a third-party plug-in for Admob.我仍然可以建议尝试使用 Admob的第三方插件。
Finally, the case may be in an unstable Internet channel.最后,案例可能是在不稳定的互联网渠道中。 That's all I could think of.我能想到的就这些。 I hope that everything will be OK.我希望一切都会好起来。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.