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

216 views
Skip to first unread message

Kurt

unread,
May 5, 2024, 10:27:16 PMMay 5
to Google Mobile Ads SDK Developers

 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.


Thanks!

Kurt

unread,
May 6, 2024, 12:05:00 AMMay 6
to Google Mobile Ads SDK Developers
IMG_0951.png

I ran the AdMob “BannerExample” project from https://github.com/googleads/googleads-mobile-ios-examples/, 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. Note the blank ad banner at the bottom of the above screenshot (with “Test mode” overlaid on it).

Mobile Ads SDK Forum Advisor

unread,
May 6, 2024, 1:16:48 AMMay 6
to ku...@soapbox.software, google-adm...@googlegroups.com
Hi,

Thank your for contacting us.

I am unable to replicate this issue in the Google Sample Project. In the event that you are using your own Id, could you share it with us for further investigation? As you are able to load the ads and are receiving a test label in the banner view, it suggests that there is no issue with the SDK. Ads are loading without any problems. Since these are test ads, it is possible that this issue could be occurring due to the unavailability of ads.

This message is in relation to case "ref:!00D1U01174p.!5004Q02tIssL:ref" (ADR-00233714)

Thanks,
 
Google Logo Mobile Ads SDK Team


Kurt Legerlotz

unread,
May 6, 2024, 7:21:23 AMMay 6
to Mobile Ads SDK Forum Advisor, google-adm...@googlegroups.com
Hello,

As mentioned, 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. I happens frequently enough with my own apps that I noticed the issue based on normal usage patterns. It can be challenging to reproduce on demand, however, as there’s no way to force the “suspended” state.

I was also able to capture the issue happening via screen recording (attached).

Thank you,
Kurt
IMG_0.MOV

Kurt

unread,
May 6, 2024, 7:45:49 AMMay 6
to Google Mobile Ads SDK Developers

Hello,


As mentioned, 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).


Thank you,

Kurt

Mobile Ads SDK Forum Advisor

unread,
May 6, 2024, 11:34:36 AMMay 6
to ku...@soapbox.software, google-adm...@googlegroups.com

Hi Kurt,

I ran the latest version of the Google Mobile Ads SDK via Swift Package Manager (11.3.0) and able to load ads successfully through simulator. Subsequently, I suspended the app for a duration of 30 mins. Upon reopening the app, I was able to successfully load ads within the simulator. 

Kindly share your sample project which replicate the issue.

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, kindly provide requested information to us via reply to author option or using the steps below:

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002tIssLQAS&entry.80707362=00233714

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

Kurt

unread,
May 6, 2024, 2:46:48 PMMay 6
to Google Mobile Ads SDK Developers
Hello,

I can work on creating an example project, but again, it will largely be the example project directly from https://github.com/googleads/googleads-mobile-ios-examples/. I may add a UI element to indicate the state of the `url` property of the underlying `WKWebView` to reflect if it is `nil` or not (which should track exactly with whether the ad is blank or not).

To reiterate: This issue only appears to occur on an actual hardware device (iPhone), and requires that the app go into the "suspended" state on iOS. For more information on the "suspended" state, please see: https://developer.apple.com/documentation/uikit/app_and_environment/managing_your_app_s_life_cycle#3200035

There is no way to manually trigger the suspended state in the simulator or on an actual hardware device, and it may happen after 30 minutes, or 1 hour, or 4 hours, or overnight. But it happens frequently enough that this issue shows up a few times per day for me, in both my apps and in the example project from https://github.com/googleads/googleads-mobile-ios-examples/.

Thank you!
Kurt

P.S. Sorry for the double post above. I was having trouble with the screen recording attachment and didn't think it was sent successfully.

Mobile Ads SDK Forum Advisor

unread,
May 6, 2024, 7:03:24 PMMay 6
to ku...@soapbox.software, google-adm...@googlegroups.com
Hi,

I will check with our team regarding your query and one of my team members will reach out to you once we have an update on this. Meanwhile, your patience is highly appreciated.

Mobile Ads SDK Forum Advisor

unread,
May 7, 2024, 11:03:04 AMMay 7
to google-adm...@googlegroups.com, ku...@soapbox.software
Hi Kurt,

Thanks for reaching out to us. Have you configured auto-refresh with the ad units in the test? In suspended state, no ad request would be made but the previous banner might be timed out resulting in the blank view. I think that could be working as intended, and you should make a new banner request every time the app gets foregrounded.

Thanks,
Jill
Google Mobile Ads SDK Team
 

ref:!00D1U01174p.!5004Q02tIssL:ref

Kurt

unread,
May 7, 2024, 11:20:39 AMMay 7
to Google Mobile Ads SDK Developers
Hi Jill,

Thanks for reaching out. For my apps, they are all set to "Google Optimized" for ad auto-refresh (attached example screenshot). For the test project, I am just using the default ad unit ID of "ca-app-pub-3940256099942544/2435281174" which is provided by the project. I am not sure if it is set to auto-refresh. I was also not aware it was recommended to make a new banner request each time the app is foregrounded, but can change to that approach if it is OK and there is no other resolution to this issue.

I have created a sample project here which is largely the same as the "examples" as mentioned before: https://github.com/lotz/googleads-mobile-ios-example-bug, but it includes an additional UI element to show when the underlying WKWebView's URL is nil. I just created this last night and have not seen the issue yet today (probably because I am repeatedly opening the app trying to get it happen 🙂).

Thank you!
Kurt

ad_refresh.png

Kurt

unread,
May 7, 2024, 3:52:54 PMMay 7
to Google Mobile Ads SDK Developers
I captured a screenshot of the state of the example app when the ad is blank (and not blank after force quitting and reloading):


IMG_0966.pngIMG_0967.png

Mobile Ads SDK Forum Advisor

unread,
May 9, 2024, 11:25:34 AMMay 9
to ku...@soapbox.software, google-adm...@googlegroups.com
Hi Kurt,

I'm also consulting other team members for the best practice for when an app is foregrounded. Will share with you once I have any meaningful findings. 

Please let us know if you still encounter the issue on your new app.

Kurt

unread,
May 9, 2024, 1:02:45 PMMay 9
to Google Mobile Ads SDK Developers
Thank you!

It has happened a number of times with my sample app in the last few days.

Kurt

Mobile Ads SDK Forum Advisor

unread,
May 13, 2024, 12:55:37 PMMay 13
to ku...@soapbox.software, google-adm...@googlegroups.com
Hi Kurt,

Do you have any issues with the approach to load a new banner every time the app is foregrounded?

Kurt

unread,
May 13, 2024, 1:03:35 PMMay 13
to Google Mobile Ads SDK Developers
I don’t, it just seemed a little counter to the “Google optimized” auto refresh setting. Though, I don’t suppose users are foregrounding and backgrounding the app in quick succession under normal usage patterns. I will give it a try. Will the documentation be updated to reflect this recommendation?

Thanks,
Kurt

Mobile Ads SDK Forum Advisor

unread,
May 13, 2024, 1:32:01 PMMay 13
to ku...@soapbox.software, google-adm...@googlegroups.com
Hi Kurt,

Did this issue happen from a specific version of the Google Mobile Ads SDK?

Kurt

unread,
May 13, 2024, 1:34:41 PMMay 13
to Google Mobile Ads SDK Developers
Good question. Anecdotally it seems to have happened in the last few months, but it’s also possible it is related to iOS 17.

I will try to reproduce it using a binary search of SDK versions going back 6 months to start and see if I can narrow in on it.

I have some iOS 16 test devices as well where I can try to reproduce it using the latest SDK version.

Thanks,
Kurt

Kurt

unread,
May 14, 2024, 9:42:19 AMMay 14
to Google Mobile Ads SDK Developers
I was able to reproduce the issue using Google Mobile Ads SDK for iOS version 10.14.0 on iOS 17.5 (example repo branch).

Will try to reproduce with different SDK versions on iOS 16 next before trying to narrow in on an SDK version.

Thanks,
Kurt


Image from iOS.jpg

Mobile Ads SDK Forum Advisor

unread,
May 14, 2024, 1:15:05 PMMay 14
to ku...@soapbox.software, google-adm...@googlegroups.com
Hi Kurt,

I don't think that iOS version plays a role here. We are waiting for the iOS GMA SDK version with which you've seen the issue to investigate.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02tIssL:ref" (ADR-00233714)

Thanks,
 
Google Logo
Jill Song
Mobile Ads SDK Team


Kurt

unread,
May 15, 2024, 6:45:33 AMMay 15
to Google Mobile Ads SDK Developers
I was able to reproduce the issue using Google Mobile Ads SDK for iOS version 9.14.0 on iOS 17.5 as well (example repo branch).

Thanks,
KurtIMG_1013.PNG

Kurt

unread,
May 16, 2024, 11:38:26 AMMay 16
to Google Mobile Ads SDK Developers
I was able to reproduce the issue using Google Mobile Ads SDK for iOS version 8.13.0 on iOS 17.5 as well (example repo branch).

I am trying with 7.69.0 next. I have not seen this issue using 11.4.0 on iOS 16.7.8 yet (though I do not use this test device regularly, I am just checking in on it periodically throughout the day).

Thanks,
Kurt

IMG_1017.PNG

Mobile Ads SDK Forum Advisor

unread,
May 16, 2024, 6:39:22 PMMay 16
to ku...@soapbox.software, google-adm...@googlegroups.com
Hi Kurt,

Thanks for the input. GMA SDK v7.x.x has been sunset in June 30, 2023, and v8.x.x will be sunset in June 30, 2024, which means we will no longer offer technical support and ad serving is at risk. Details in https://developers.google.com/admob/ios/deprecation.

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.

Kurt

unread,
May 16, 2024, 6:42:47 PMMay 16
to Google Mobile Ads SDK Developers
Hi Jill,

Thanks for the info, and just to clarify, I was just testing various versions to try to narrow in on when a potential bug was introduced. I’ll stick with the latest version in my production apps. 🙂

I also appreciate the prompt and continued communication on this all. I'll take the approach of loading a new ad when foregrounding, and stay tuned for any delegate method changes.

Thanks again for all the help!
Kurt

Reply all
Reply to author
Forward
0 new messages