Admob High CPU usage in background ? HELP PLZ !!

351 views
Skip to first unread message

Haris Ali

unread,
Mar 6, 2016, 4:08:11 PM3/6/16
to Google Mobile Ads SDK Developers
here is the scenario.

1 : if i open my app and wait for the ad to load and close my app everything works great.


2 : if i open my app and close it before ad finishes loading , it causes very high CPU usage in background [even app is closed completely]?


i am using Admob 8.4.0 on android and issue is with banner ad.


i did everything from manually calling pauseTimers , to manually remove webviews from adview , still same issue.

Vu Chau (Mobile Ads SDK Team)

unread,
Mar 7, 2016, 10:08:09 AM3/7/16
to Google Mobile Ads SDK Developers
Hi Haris,

Thanks for letting us know about that.  However, I wasn't able to reproduce that with our sample app.  Could you try reproducing the issue there and let us know if it also causes a high CPU usage?  If not, feel free to send over a minified sample app capable of reproducing the issue and we'll check it out.

Vu Chau
Mobile Ads SDK Team

Haris Ali

unread,
Mar 7, 2016, 1:52:21 PM3/7/16
to Google Mobile Ads SDK Developers
Same issue with your sample.
some times it works , some times it causes high cpu usage in background.

i have nexus 6p with android 6.0


this is how i was able to reproduce it on your sample.

uninstall if you already installed the sample , now  open android studio , and run the sample, on first run close the app ASAP when ad is not loaded. try it 2 -5 times you will be able to reproduce it.

Vu Chau (Mobile Ads SDK Team)

unread,
Mar 7, 2016, 5:16:13 PM3/7/16
to Google Mobile Ads SDK Developers
Hey Haris,

Would you be able to send over a screenshot of the CPU usage reading (and/or a screencast showing the steps you take in the app to cause the high usage) in Android Studio?  On our end, the max we've been getting is about 20%, which is relatively normal.  

Vu Chau
Mobile Ads SDK Team

Haris Ali

unread,
Mar 7, 2016, 5:19:58 PM3/7/16
to Google Mobile Ads SDK Developers
yes its around 20-30% but it is always using CPU in background even if the app is closed.
some of my app user reported battery drain and when i looked into it , it was around 4% for 4 -5 hours.
my question is why it is using CPU when app is closed.

Vu Chau (Mobile Ads SDK Team)

unread,
Mar 8, 2016, 9:35:52 AM3/8/16
to Google Mobile Ads SDK Developers
If it's around the 20-30% range then I'd say it's a fairly normal consumption, since WebViews are resource-intensive, not to include the CSS and JavaScript of the creatives themselves.

I'm still not seeing the app using additional CPU after it's sent to the background.  However, rest assured that the SDK periodically executes cleanup tasks to stabilize performance, so I would not worry over manually pausing your WebViews and destroying unused resources.  The SDK should be doing that for you over the long run.

Vu Chau
Mobile Ads SDK Team

Haris Ali

unread,
Mar 8, 2016, 10:44:13 AM3/8/16
to Google Mobile Ads SDK Developers
i am talking about the sample app  , it is using 2-3% cpu in background. and its a LOT.
and it can even stack if you open and close it. i cannot understand why you cannot reproduce it. if you cant me to send you a video i can make it.
and it is always using CPU in background even after hours.

Vu Chau (Mobile Ads SDK Team)

unread,
Mar 8, 2016, 3:17:00 PM3/8/16
to Google Mobile Ads SDK Developers
I tested again and the max CPU usage once the app has been backgrounded is .85% for 1s.  The rest of the time the usage stays at 0% (see screenshot).  For scenarios when I continually open the app and close it, the max is about 10%, but it gets back to 0 once it's backgrounded or when no longer in use.

I would not attribute this amount of CPU consumption as a cause for battery drain.  There are far many other factors, including networking, which is the greatest factor for power drain. 

I understand you are concerned about the performance of your app, but so far in my testing all I have seen can be accounted for.  I recommend profiling your app using Systrace, so you can look into how your app is doing frame by frame.  Here is a trace I did just now.

The trace was for 10 seconds, during which I launched our sample app, let it load the banner, and backgrounded it at the 5th second.  The remaining 5 seconds was purely no work app-wise.  Looking at the trace, you can see all 8 cores of my Nexus 6P turned on from the beginning up until 5.5s, that was when I hit the home button to background the app.  A bit more work there for handling that input event, but after that towards 10s you can see more than half of my cores have turned off.  At the end, only two cores were still churning out some calculations.

Vu Chau
Mobile Ads SDK Team

CPU_app_launches_&_exits.png
CPU_in_Background.png

Haris Ali

unread,
Mar 8, 2016, 3:59:17 PM3/8/16
to Google Mobile Ads SDK Developers
i used your example app and i am using these properties.
android:noHistory="true"
android:excludeFromRecents="true"

in manifest file 
and close the app when the banner is not loaded like  open the app and close it within a second it will cause it.following are two traces please check them.
this is the sample banner app.

Trace 1   Trace 2

Vu Chau (Mobile Ads SDK Team)

unread,
Mar 8, 2016, 5:25:33 PM3/8/16
to Google Mobile Ads SDK Developers
I'm not sure if we're looking at the same thing here, but I'm still not see any CPU spike after I have done what you said (i.e. load the app --> close it before the banner loads --> repeat that cycle a few times).  Here is a screen recording showing you what I saw.

Like I said, I wouldn't zero in on this specific instance as a worrisome cause.  Remember that the AdView is a WebView, so there might be other factors of WebView objects (that are unrelated to AdMob or the SDK) that might cause the CPU spike you see.

Vu

Nguyễn Martin

unread,
Apr 2, 2016, 6:00:45 AM4/2/16
to Google Mobile Ads SDK Developers
Vào 03:59:17 UTC+7 Thứ Tư, ngày 09 tháng 3 năm 2016, Haris Ali đã viết:
Dear Haris,

I have same problem, did you have solution for this bug. this issue is anoyying
I had try call webview pause timer and resume timer but it still comsuming cpu in bacground

Sdk team. You can using any app for check cpu time. You will see this issue. In my case i using Gsam battery monitor for check cpu time

Vu Chau (Mobile Ads SDK Team)

unread,
Apr 4, 2016, 12:48:13 PM4/4/16
to Google Mobile Ads SDK Developers
Hello,

Could you send us any trace or profiling proof?  Do you see the high CPU usage even in our sample app?

Vu Chau
Mobile Ads SDK Team

Reply all
Reply to author
Forward
0 new messages