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 · 5 comments
Open

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

lotz opened this issue May 6, 2024 · 5 comments

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.

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

3 participants