AdMob drains CPU/battery when app is in background

閲覧: 398 回
最初の未読メッセージにスキップ

3c

未読、
2020/11/03 1:32:172020/11/03
To: Google Mobile Ads SDK Developers
For some reasons, without any code change, this issue is re-occurring again. I have 17+ free apps using AdMob and nearly 90% of the time the app exits or is put in background, it will continue to consume CPU.

Removing AdMob removes the issue!

I suspect this happens depending on ads shown, as few times it won't occur.

Haven't change the code in years, after putting some work-around to the same issue.

What is done: 

In OnResume(), adView is attached and ad is requested.

In OnPause(), AdView is paused, destroyed and detached from main view.

Still, shit continues to happen in background!


Also noted many errors reported in logcat:

2020-11-03 07:26:06.959 12206-12206/ccc71.st.cpu I/chromium: [INFO:CONSOLE(51)] "Uncaught TypeError: window.AFMA_updateActiveView is not a function", source: https://googleads.g.doubleclick.net/mads/mraid.js (51)

2020-11-03 07:26:08.912 12206-21736/ccc71.st.cpu E/FA: Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI
2020-11-03 07:26:11.916 12206-21736/ccc71.st.cpu W/ConnectionTracker: Exception thrown while unbinding
    java.lang.IllegalArgumentException: Service not registered: lx@b96ca0a
        at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1772)
        at android.app.ContextImpl.unbindService(ContextImpl.java:1895)
        at android.content.ContextWrapper.unbindService(ContextWrapper.java:792)
        at ci.b(:com.google.android.gms.dynamite_measurementdynamite@203915097@20.39.15 (150400-0):1)
        at ci.a(:com.google.android.gms.dynamite_measurementdynamite@203915097@20.39.15 (150400-0):6)
        at ly.A(:com.google.android.gms.dynamite_measurementdynamite@203915097@20.39.15 (150400-0):10)
        at li.a(:com.google.android.gms.dynamite_measurementdynamite@203915097@20.39.15 (150400-0):2)
        at ec.run(:com.google.android.gms.dynamite_measurementdynamite@203915097@20.39.15 (150400-0):3)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at jb.run(:com.google.android.gms.dynamite_measurementdynamite@203915097@20.39.15 (150400-0):6)
2020-11-03 07:26:12.053 12206-21664/ccc71.st.cpu I/pwIrisCR: YYY2-2 CoreContext[0x7bdedd1590]:: Destruct: ##PID##:12206


Those errors are reported repeatedly, this is annoying.

Using ads:

com.google.android.gms:play-services-ads:19.5.0
com.google.android.ads.consent:consent-library:1.0.8

Tested on OnePlus 8P Android 11, Pixel 3XL Android 9.

Is there a version without such issues? Those are dramatically impacting user experience.

メッセージは削除されました

andro...@gmail.com

未読、
2020/11/03 3:50:472020/11/03
To: Google Mobile Ads SDK Developers
Reverted to:
com.google.android.gms:play-services-ads:19.4.0

It seems to fix the issue, however I don't see the same ads, and the issue appears to be affected by certain ads.

Also, user refusing EU consent appears to better improve the situation.

With EU consent accepted, there seems to still be some activity taking place in the background, but far less than when using 19.5.0.

Mobile Ads SDK Forum Advisor Prod

未読、
2020/11/03 5:15:012020/11/03
To: andro...@gmail.com、google-adm...@googlegroups.com
Hi there,

Thank you for raising this to us.

Could you please provide the following details via Reply privately to author option, for us to investigate the issue further?
  • Memory profiler (screen recording) capturing the behavior
  • Project file where the issue is reproducible
Regards,
Google Logo
Teejay Wennie Pimentel
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q276gl9:ref

3c

未読、
2020/11/03 7:31:162020/11/03
To: Google Mobile Ads SDK Developers
Here is attached a session where behavior is acceptable and AdMob stops using resources after a while. Rejecting user consent seems to help stick with this scenario. Using 19.5.0 seems to increase the frequency (as new smart ads are used?). I believe it happens with complex dynamic ads that are obviously buggy and continue to run when app is not visible or even when ads view is destroyed, garbage-collected.

As the ads shown are nearly the same at the moment, I cannot reproduce and will have to wait to get dynamic and buggy ads, which happened earlier this morning constantly.

Obviously you could test this on your end more easily choosing ads to show, while I obviously can't do that.

I'll post a session where unacceptable behavior (constant CPU usage) occurs as soon as I can, that is when the problematic ads show again.
admob_ads1_background_activity.png

3c

未読、
2020/11/03 10:05:242020/11/03
To: Google Mobile Ads SDK Developers
Didn't take long before it started again. This time it was an ad for AliExpress 11.11 promotion. Open the app, the ad showed and then closed the app.

This session screenshot was started 5 minutes after the app was closed. I can see about 2% of CPU being used constantly. 0.02 seconds every second.

Then you can see I turned off the device, at least it stops behaving badly, but start again as soon as I turn device on again.

admob_ads3_background_activity.png

3c

未読、
2020/11/03 10:46:122020/11/03
To: Google Mobile Ads SDK Developers
FWIW, I have interstitials loading from time to time and I noticed that each time an interstitial is loaded CPU drain starts as well !

After the interstitial is shown, I receive the onClosed() and remove any reference to the interstitial object. I can't find any way to close/pause/destroy it ?

If I don't show the interstitial and remove any reference, same happens. CPU drain starts as soon as interstitial is received.

3c

未読、
2020/11/03 10:46:522020/11/03
To: Google Mobile Ads SDK Developers
You can find sample projects here:


It seems not to be a new issue...

Mobile Ads SDK Forum Advisor Prod

未読、
2020/11/03 14:22:482020/11/03
To: ccou...@gmail.com、google-adm...@googlegroups.com
Hi there,

I work with Teejay and will assist you. Thank you for the profiler pictures and more background. Can you give us a Charles log of the ads that cause resource drain in background? Also, can you show a project where this is reproducible? We would prefer to reliably reproduce in one or more of our sample apps.

Regards,

Google Logo
Aryeh Baker
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q276gl9:ref

3c

未読、
2020/11/04 3:57:302020/11/04
To: Google Mobile Ads SDK Developers
Ok, I tried your sample apps (interstitials) but it's so out-dated, it's barely usable.

First, using Android Studio 4.1, asks for upgrading gradle plugin, and if I do so, the project no longer compiles. Tried reverting plugin, errors everywhere.

Then, without upgrading plugin, I ran the app and it shows test ads... LOL, no-one will be able to reproduce any issues caused by ads themselves with such.
Then tried to enter my ads and publisher ID , failed with error 3 constantly.

Makes this sample pretty useless.


Then tried Charles log, again outdated documentation...  A 30-days trial...

Configure emulator is impossible because each time I use an emulator with play services, WiFI network does not work, play service version is displaying 'loading...' and updating it makes emulator simply hangs permanently.
More than anything, the option to enable debug logging for ads is not there in emulator! LOL.

Configuring real device doesn't say where to specify proxy on mobile device. Found no options in wifi for that. I doubt configure chrome will do it?
Nevertheless going to the said page leads to charlesproxy.com/getssl, which states that if download doesn't start, check browser compatibility... That being done in Chrome. Then in it goes in 'too many redirect'.


Well, I went the short road: disabled interstitials altogether.

Until you fix this issue and others (like adult contents showing in interestitials while category is blocked!)...

3c

未読、
2020/11/04 5:03:532020/11/04
To: Google Mobile Ads SDK Developers
FWIW, I downloaded your interstitial samples, changed pub/unit ids to match mine, set test device id for the target device. Ran the sample, showed an interstitial, problem occurs immediately!

Mobile Ads SDK Forum Advisor Prod

未読、
2020/11/04 5:55:142020/11/04
To: ccou...@gmail.com、google-adm...@googlegroups.com
Hi there,

I tried your App ID and Ad Unit ID, and I wasn't able to reproduce the issue. Instead, I'm consistently getting a no fill error instead. I was able to build our interstitial sample app without any issues. You just need to update the SDK from 18.2.0 to the latest version 19.5.0. 

I also tried our sample app with our sample ad unit ID, and I could see that the memory free up after the ads has been loaded and displayed (please see attached file). With this, the only way for us to investigate further is by capturing the Charles log while reproducing the issue, as this will enable us to replicate the behavior in our test app environment (by trafficking the creative in the test network). With that said, please provide us the Charles log (see instruction here) so we could further investigate the issue.

Regards,
Google Logo
Teejay Wennie Pimentel
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q276gl9:ref
profiler.png

3c

未読、
2020/11/04 6:22:352020/11/04
To: Google Mobile Ads SDK Developers
As I said I setup test device on the target device otherwise I get error 3.

Already updated sdk to 19.5.0 (obsolete samples as mentioned). And reproduced issue instantly and repeatedly.

As mentioned as well, I removed interstitials from all my apps until you fix this P1 issue.

Mobile Ads SDK Forum Advisor Prod

未読、
2020/11/04 11:01:572020/11/04
To: ccou...@gmail.com、google-adm...@googlegroups.com
Hi 3c,

Thank you for responding back. We have been looking into this for you and are requesting a Charles log so that we can look more into this for you. As you stated earlier in the post. You said that the issue appears to happen more often when getting a dynamic ad. To be able to get this to repeat we would need the Charles log to capture the ad, and thus test against what seems to be an issue with specific ads.

Regards,
Google Logo
William Pescherine
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q276gl9:ref

3c

未読、
2020/11/05 7:41:122020/11/05
To: Google Mobile Ads SDK Developers
As I said, Charles log are not working for me, be it in emulator or in real devices. Emulator, with play services = no internet. Device = documentation is incorrect and doesn't allow me to setup Charles log.

As I said, the CPU drain issue depends on ads being shown. It seems that each time an AliExpress ad is shown, be it adaptative banner or interstittials, things go haywire. And there's no stopping it unless I stop the app.

I reproduced this with your own interstitials sample and you asked for a sample, there you have it. But again, it's ad based so if you don't test your software thoroughly you'll never see it.

Also, you mention memory being freed, while the issue is about CPU usage, so obviously you've overlooked that point since OP. I never said memory was drained, ever.


You built your own sample without any issues because you either didn't upgrade gradle plugin or use older version of Android Studio (please read your customer's post before replying). And irrespective of updated libraries, the issue with CPU usage is easily reproducible as I'm sure you can pick the ads to show, while I can't.

So it can take me hours before the culprit ads are showing or the right condition occurs. But it's obvious you prefer I waste my time than yours testing your software.

I tried to modify your samples to use my app's signature, package name, app id and banner/interstitials id to get the same ads I receive in my app, but then i receive no ads, unless I setup test device on target device. But then in my app using test ads are no problem.

If I run my app, I get ads constantly, if I run your banner sample i get no ads even though I've set the same signature, package name, subscriber/ad id... 

There are just too many problems for me to find any solution to this critical issue:

- Obsolete samples that won't work with latest gradle plugin.
- Ads not showing in same conditions for original/sampled app.
- Ads reporting no fill or no config without any explanations or solution anywhere.
- Charles log not configurable on real device.
- Emulator with Play Services blocking internet.
- Adult content showing in ads where all adult categories are blocked (reported by few users, not just one).
- Firebase library keeps trying to run even if disabled.
- dynamite analytics crashing after every ads (reported in another conversations).
- no issue tracker for AdMob, as if there was no single issue lol


I'm more and more, like thousands out there reading various blogs, considering getting rid of AdMob altogether, and you're not helping on any issues, none whatsoever.

Even when I tell you I can't configure Charles log, you just perrot yourself about your need for Charles log, but you don't provide any form of assistance.


If there's customer service around here, I ought to get in touch with them, because here nobody's listening or actually reading customer posts.

Mobile Ads SDK Forum Advisor Prod

未読、
2020/11/05 11:29:282020/11/05
To: ccou...@gmail.com、google-adm...@googlegroups.com
Hi there,

Charles logs can be frustrating and cpu usage of ads can go wrong in many ways.

To address no ads in Sample app with your Id's, adding your applicationId to your app's build.gradle may help you get ads in the Sample app. 

Also, the Sample apps work with the new SDK just by updating the "implementation"to 

implementation 'com.google.android.gms:play-services-ads:19.5.0'

There's no need to upgrade gradle - it should run out of the box. If you did upgrade gradle, you can always delete entire project and redownload our Sample apps. To test different SDK versions you can change version number, sync and run.

Charles logs can work with the emulator. Since certain steps depend on the type of device being emulated I can give a general, unsupported outline of how I get an emulator to work with Charles on a Mac. Most of the steps you already know, but it is useful to have this outline for others in the forum.


I just now created a pixel 3a emulator with api level 30.
  1. To make the emulator a developer testing bed I go to settings->About Emulated Devices and click 7 times on build number. Back up to Settings->System->Advanced->Developer options->Enable USB Debugging, make sure it's set.
  2. To enable debug logging for ads you can go to Settings->Google->Ads-> and enable debug logging option should be there.
  3. To set up Charles correctly, I turned on Charles and in my Mac I go to Help->SSL proxying->Install Charles root certificate on Mobile Device. Then I went in emulator to Settings->Network & Internet->Wi-fi->Android Wi-fi. I clicked the pencil on top right and clicked Advanced Options, switched proxy to manual, entered proxy hostname and port and saved. Then I went to Android Chrome Browser and typed in chls.pro/ssl. The option to download certificate opens up. I downloaded and then went to Settings->Security->Encryption and Credentials->Install a certificate->CA Certificate. I clicked Install anyways and in the download folder the certificate should be there.
  4. To add SSL proxying to my app I made sure I have an xml directory under res. I control-clicked on res->New->Android Resource Directory. Under resource type I selected xml and pressed ok. I then control clicked on xml directory->New->XML Resource File and entered in File Name "network_security_config". I made sure I was in code mode and replaced the contents with this:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <debug-overrides>
        <trust-anchors>
            <!-- Trust user added CAs while debuggable only -->
            <certificates src="user" />
        </trust-anchors>
    </debug-overrides>
</network-security-config>

​​​​​​​

I then added to AndroidManifest.xml before the ">" of "application" this line:

 

android:networkSecurityConfig="@xml/network_security_config"

​​​​​​​​​​​​​​This worked to get our Sample apps and  Guide s working with Charles.

Let me address some of your concerns mentioned in your last post:



- Obsolete samples that won't work with latest gradle plugin.

You want out of the box use of latest gradle plugin. I will raise this request to the rest of my team. You may monitor our Releases for an update.



- Ads not showing in same conditions for original/sampled app.

Could you elaborate on what you are refering to? No ads showing insample with your Id? Different ads showing with your Id?



- Ads reporting no fill or no config without any explanations or solution anywhere.

This request for an explanation of why ads don't serve will be raised with the rest of the team. You may monitor our Blog for an update.



- Charles log not configurable on real device.

I hope that the example I gave for getting Charles to work on an emulator should be helpful for getting it to work on device. Since there are too many variables to consider we will only be able to suggest solutions. Feel free to ask but we may not be able to help. You can try StackOverflow though.



- Emulator with Play Services blocking internet.

You may want to request help for this from the Play Sevices Forum as we can only support integrating the Mobile Ads SDK into apps.



- Adult content showing in ads where all adult categories are blocked (reported by few users, not just one).

Ad serving issues are supported by the AdMob Forum​​​​.



- Firebase library keeps trying to run even if disabled.

Are there any performance issues that are occurring because of this? We would like to address any crashes or performance degradations when using our SDK.



- dynamite analytics crashing after every ads (reported in another conversations).

Please give us a reliably reproducible method for causing this crash so we can address it.


​​​​​​​
- no issue tracker for AdMob, as if there was no single issue lol

Could you elaborate on how and why you would like support to be configured? Are you referring to Github Issue Tracker?

Feel free to reach out to us. We would like to see a Charles log of the misbehaving ad sent to us by "Reply to author"

Regards,

Google Logo
Aryeh Baker
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q276gl9:ref

3c

未読、
2020/11/08 9:07:292020/11/08
To: Google Mobile Ads SDK Developers
I've managed to gather some Charles log, only to realize how obsolete documentation is and how useless this demand is in the first place.

Internet traffic logs you keep asking for has nothing to do with CPU drain, I thought it was something obvious. Don't understand why you guys keep ignoring this.

Here is attached the Charles log I got anyway, even if totally useless. 

I could see about 3 or 4 connections after the app was actually closed (already bad behavior), but there was more CPU drain than actual internet traffic.

Again, as mentioned numerous times, the behavior seems affected by certain dynamic ads, which I don't necessarily get on my end.

charles_log.zip

3c

未読、
2020/11/08 9:14:112020/11/08
To: Google Mobile Ads SDK Developers
Just in case you haven't tested this yet (obviously, lol), here is what I did:

Download both banner and interstitials samples. Setup my app's signature, publisher id and ads id. 

Ran it a couple of times on a stock Pixel 3 XL Android 9, exit the apps with back button.
Now I can see them consuming CPU regularly. Killed them, tried again, same results.

Tried on stock Android 11, same results.

Both samples!

When are you going to fix this?

Mobile Ads SDK Forum Advisor Prod

未読、
2020/11/09 0:13:062020/11/09
To: ccou...@gmail.com、google-adm...@googlegroups.com
Hi there,

We understand your frustration on this. However, we really need the Charles log as this will enable us to replicate the exact scenario that you're getting on your end. Please do note that the SDK just requests an ad to an ad-server (AdMob, Ad manager, etc.), and doesn't have any control on what ads will be served into your app. This is the reason that we are requesting a Charles log from the publishers whose getting this kind of issues. We really do appreciate you in helping us identify the issue that will benefit the whole AdMob community.

As per checking with your Charles log, it appears that the SSL Proxy was not turned on and thus, no traffic data were gathered (please see attached screenshot). With this, could you please follow this guide (specifically to number 4 instruction) and provide to us again the Charles log again? This would be a big help for us to investigate the issue further.

On the other hand, I also tried your case scenario using Google Pixel 3 as well (please see attached screencast). However, I'm still wasn't able to reproduce the behavior that you reported. The app didn't takes any phone's resources upon making the app on the foreground. With this, since this is only reproducible on your end. Could you kindly send the profiler file to us? Once sent, I'll raise this (including all the discussion thus far) to the rest of the team, and to provide a decisive resolution to this issue.

Regards,
Google Logo
Teejay Wennie Pimentel
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q276gl9:ref
Screen Recording 2020-11-09 at 12_59_08 PM_mov.html

3c

未読、
2020/11/09 3:56:282020/11/09
To: Google Mobile Ads SDK Developers
Checked your video, and I definitely see CPU activity while app is in background in your video. If you wait several minutes, you might see it get active on a regular basis. However it's doubtful you're using the right tool to see CPU drain when app is in background as it's usually lower than 1%.

Furthermore, some Android devices, after a day, reported both samples app as draining CPU/battery while I didn't use them at all!

Mobile Ads SDK Forum Advisor Prod

未読、
2020/11/09 6:29:042020/11/09
To: ccou...@gmail.com、google-adm...@googlegroups.com
Hi there,

As per deeper checking with the screencast we provided, the profiler's Energy readings just hovers between none to light (mostly stayed on none), and the CPU resources are between 0% to 6% only (when ads requested and displayed). The only peak of the CPU usage is 18% due to SDK initialization. With that all said, I could say that the app works fine, and the SDK doesn't take much resources. The screencast we sent earlier was recorded using the Android Studio Profiler, which we believe is the official go-to profiler by the Android community. However, if you believe that the Android Studio profiler (as supported by the Android community) is insufficient, feel free to recommend another profiler so we could check.

3c

未読、
2020/11/09 7:01:012020/11/09
To: Google Mobile Ads SDK Developers
Again you're referring to something i never complained about. I've never talked about CPU usage when ads are used but background CPU usage when ads and apps are not used, which you haven't checked yet, not even once !

If background CPU usage is ok as you suggest, then your product is perfectly ok, but I will not use it any longer as for my users it's not ok.

Mobile Ads SDK Forum Advisor Prod

未読、
2020/11/09 10:48:282020/11/09
To: ccou...@gmail.com、google-adm...@googlegroups.com
Hi 3c,

Thank you for your response back. Seeing as how this issue seems to be continuing for you. We will be bringing this to our team to further look into. Once we have some feedback from them we will be certain to pass this along to you.

Regards,
Google Logo
William Pescherine
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q276gl9:ref

Mobile Ads SDK Forum Advisor Prod

未読、
2020/11/17 0:39:532020/11/17
To: ccou...@gmail.com、google-adm...@googlegroups.com

Hi,

Your issue has been escalated to the Mobile Ads SDK engineering support team.

We understand your concern here and as you have pointed out it does seem that certain ads are causing more than expected CPU usage when the app is in the background. The screenshot you provided of the Ali Express promotion seems a relevant example.

As you no doubt are aware this is a confluence of factors including AdMob, webview and certain ad creatives so capturing the relevant variables that lead to the issue reproducing is the most effective way to resolve the issue. An effective way to identify a specific ad is via the response ID - https://developers.google.com/admob/android/response-info.  If you were able to capture the response ID of a specific ad that reproduces that may be enough to assist us in isolating the issue. A charles log capturing the response would also be helpful. Finally it would be helpful to know the version of webview running on the device.

I'm sorry we aren't able to resolve this issue more expediently but the more information we have the quicker we should be able to isolate and reproduce the issue. I have created an internal issue for this (b/173473357) to follow up with the SDK engineering team. It appears to be similar in nature to this webview issue - https://bugs.chromium.org/p/chromium/issues/detail?id=900557 which has been resolved, however I imagine this is a new occurrence.

Regards
 

Sam
Mobile Ads SDK support team



ref:_00D1U1174p._5004Q276gl9:ref
全員に返信
投稿者に返信
転送
新着メール 0 件