Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Banner ad blank when app returns to foreground sometimes (iOS) #421

Open
lotz opened this issue May 6, 2024 · 12 comments
Open

Banner ad blank when app returns to foreground sometimes (iOS) #421

lotz opened this issue May 6, 2024 · 12 comments
Assignees

Comments

@lotz
Copy link

lotz commented May 6, 2024

I have some iOS apps that implements a banner ad using UIKit. I implement the “GADBannerViewDelegate” protocol to listen for ad loading events and errors.

Occasionally, when opening the app, returning to the Home Screen on iOS, then returning to the app after some time has passed (possibly enough time for the app to be “suspended” by the OS), the ad banner is blank.

After some view hierarchy debugging, I’ve noticed that the banner ad view utilizes a WKWebView to render the ad from a URL. When the ad is blank, it appears that this WKWebView’s “url” property is “nil”. Additionally, the GADBannerViewDelegate’s error method is not called, so I don’t know when this has occurred to recover from it.

I think this is a bug as it seems to have started happening recently, maybe within the last few months. I have been using Google Mobile Ads in my iOS apps for over 10 years. Any help would be appreciated.

Additionally, I ran the AdMob “BannerExample” project from this repo, installing the latest version of Google Mobile Ads for iOS SDK from Swift Package Manager (11.3.0 at the time of this post), and the issue is present there on iOS 17.4.

IMG_0951

@lotz
Copy link
Author

lotz commented May 6, 2024

The only change I have made to the example project is adding the latest version of the Google Mobile Ads SDK via Swift Package Manager (11.3.0). The ad unit ID and other IDs come directly from the project.

This issue only surfaces on an actual device after some time has passed, enough that the OS puts the app into a “suspended” state. Maybe 30 mins or so, or an hour, depending on usage of the device and other apps (seems somewhat consistent overnight if you open the app just before bed). While it can be challenging to reproduce on demand, as there’s no way to force the “suspended” state, it happens frequently enough with my own apps that I noticed the issue based on normal usage patterns (opening the apps at regular intervals throughout the day).

I have also posted this issue in the following forums:

@lotz
Copy link
Author

lotz commented May 8, 2024

I've created a smaller example project here as well: https://github.com/lotz/googleads-mobile-ios-example-bug

@abinhho
Copy link

abinhho commented May 15, 2024

Same here.

@dylancom
Copy link

dylancom commented May 21, 2024

@lotz to fix this, is it enough to call loadRequest(objc)/load(swift) upon foregrounding or do we need to create a complete new instance?

@lotz
Copy link
Author

lotz commented May 21, 2024

Calling load with the existing instance works for me.

@NVentimiglia
Copy link
Member

@lotz

I was not able to replicate this on my end. Can you open a SDK support case and include the debug log and a network trace?

https://developers.devsite.corp.google.com/admob/support

@lotz
Copy link
Author

lotz commented Jul 17, 2024

@NVentimiglia I have already opened a discussion here with a lengthy debug process: https://groups.google.com/u/1/g/google-admob-ads-sdk/c/rwBpqOUr8m8

Reproducing this on demand is difficult, as there is no way to manually trigger the "suspended" state -- it must happen on its on after several hours or even overnight.

@NVentimiglia
Copy link
Member

@lotz

Thanks for your patience, I was able to confirm the issue and confirm that we are working on a solution.

@NVentimiglia NVentimiglia self-assigned this Jul 17, 2024
@lotz
Copy link
Author

lotz commented Jul 17, 2024

@NVentimiglia this is great to hear, thanks for the update!

@mschonvogel
Copy link

Hey @NVentimiglia, when do you think we can expect a resolution for this bug? 👀

@JulianMaus98
Copy link

Any updates on this topic, @NVentimiglia? 🙂

@NVentimiglia
Copy link
Member

NVentimiglia commented Oct 1, 2024

From the google thread :

Back to this issue, the OS reserves the right to terminate WKWebView at any time due to memory pressure. That could be the underlying problem. And for that we don't have a way to control. None of the current BannerViewDelegate methods are appropriate for this event, so it's expected none is invoked. We are exploring if we should provide a new delegate method to listen to web view termination for better user experience, but that's still too early to say. Right now your best option would be to stay on GMA v10 and above, and requesting a new ad when the app is foregrounded.

I will forward this to engineering to see if there is something we can do such as an error event.

That said, In the mean time I recommend reloading banners if the app is suspended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants