Cannot request ads while player is in the background

1,111 views
Skip to first unread message

Steven Barnett

unread,
Feb 5, 2020, 12:51:35 PM2/5/20
to Interactive Media Ads SDK
Which SDK are you using (Android, iOS, HTML5, Flash)?

GoogleAds-IMA-iOS-SDK (3.11.2) -- installed via CocoaPods

What ad tag are you using in your request?

Are you able to reproduce this issue using your ad tag in the sample app (AndroidiOS) or the Video Suite Inspector (HTML5Flash)?

The sample app did not compile for me, giving the error:

ld: library not found for -lPods-BasicExample

What steps must we take to reproduce your issue?

On iOS 13.3 after my content has begun playing, I run the following code:

        IMASettings *settings = [[IMASettings alloc] init];
        settings.enableBackgroundPlayback = YES;
       
        self.adsLoader = [[IMAAdsLoader alloc] initWithSettings:settings];
        self.adsLoader.delegate = self;
       
        IMAAdDisplayContainer *adDisplayContainer =
        [[IMAAdDisplayContainer alloc] initWithAdContainer:avPlayerViewController companionSlots:nil];
       
        self->request = [[IMAAdsRequest alloc] initWithAdTagUrl:vastUrl adDisplayContainer:adDisplayContainer contentPlayhead:nil userContext:nil];
       
        [self.adsLoader requestAdsWithRequest:request];


If the application is in the foreground when this code runs, then "adsLoader:adsLoadedWithData" gets called, I can grab the AdsManager from the adsLoadedData object, and I can call [adsManager start] to begin playback

If the application is in the background when this code runs, then "adsLoader:adsLoadedWithData" is never called. Furthermore, I see the following line show up in the Xcode debugger:

[ProcessSuspension] 0x2836f3bc0 - WKProcessAssertionBackgroundTaskManager: Ignored request to start a new background task because the application is already in the background

I don't know if this log is related to the issue, but it only seems to show up when the IMA SDK attempts to make an HTTP request while in the background. I also see this log if I background the app during and ad, right after hitting a quartile or midpoint (at which point the IMA SDK will presumably attempt to make an HTTP request to the tracker URL)

I don't recall having this issue before. It seems to have just recently started with an update to iOS
Message has been deleted
Message has been deleted

Steven Barnett

unread,
Feb 6, 2020, 4:55:47 PM2/6/20
to Interactive Media Ads SDK
Here's some additional discoveries I've made:
  • The issue seems to have started in iOS 13.X (it definitely happens in 13.3, I think it happens in 13.2, but I can't verify if it happens in 13.1 or 13.0)
  • The issue seems to be related to the WKWebView used by the IMA SDK to make VAST requests and hit tracking URLs - not actually a bug in the IMA SDK code, but a bug with one of their dependencies
  • The issue only seems to occur on an actual device, and not on the simulator
  • Although I've failed to discover how to reproduce the bug the way it occurs in our app (consistently, regardless of when the player was locked), I have discovered that it can be trivially reproduced by locking the screen after an ad has started playing
If you lock the screen after an ad has started playing on iOS 13.3 on a real device, future ad events do not fire -- including the call to "adsManagerRequestContentResume". Without the call to "adsManagerRequestContentResume", most players will not return to content

I have linked a sample application which reproduces the issue. Simply build and run this app on a real device running iOS 13.3, wait 10 seconds for the ad to start playing, and then lock the screen. The ad's audio will play through to the end, and then the player will fail to transition back to content when the ad is through. If you do not lock the screen, the ad transitions back to content flawlessly.

IMA SDK

unread,
Feb 7, 2020, 3:14:01 PM2/7/20
to steven....@blueframetech.com, ima...@googlegroups.com
Hi Steven,

Thank you for providing additional insights with regards to the issue. We were not able to reproduce the behavior that you're seeing with the content audio that is not resuming as it should when the screen is locked. We've run your test app, followed the steps described on this thread, the content audio resumed as expected when screen is locked (see video recording attached). Furthermore, all the ad events were fired as expected (see logs attached), to run the tests we used an iPhone device with iOS 13.3 install (see screenshot attached). The issue seems to be with your implementation, we would recommend you to review it while debugging against of our iOS AdvancedExample sample.

Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5001UV02zZ:ref
logs_txt.html
IMG_1147-_mov.html
IMG_0014_png.html

Steven Barnett

unread,
Feb 7, 2020, 3:20:24 PM2/7/20
to Interactive Media Ads SDK
Arnaud:

In the video provided, the screen was locked immediately prior to the ad beginning. As mentioned in my prior post:

If you lock the screen after an ad has started playing on iOS 13.3 on a real device, future ad events do not fire
(emphasis added)

Try locking the screen once the count down on the ad displays 7 seconds remaining (e.g. 3 seconds into the ad, or after the first quartile has fired but before the midpoint has fired). If this still does not reproduce the issue, then I will need to do some further research - because we are having no trouble reproducing the problem here at our office. We've tested on two iPhone and an iPad, all of which are running iOS 13.3

Steven Barnett

unread,
Feb 7, 2020, 3:43:17 PM2/7/20
to Interactive Media Ads SDK
I've created the following video demo'ing the issue on my phone, with the live logs beside the phone (I used OBS to capture my FaceTime Camera and my screen simultaneously):


Here you will see the additional "Ignored request to start a new background task" logs after the screen is locked, plus the failure to return to content.

Steven Barnett

unread,
Feb 7, 2020, 4:02:47 PM2/7/20
to Interactive Media Ads SDK
Interestingly, contrary to my tests yesterday, I noticed upon watching the logs in the video I posted that future ad events were fired after locking the screen today (yesterday I didn't see "Ad Event: Midpoint", "Ad Event: Third Quartile", etc)

But even with the additional ad events firing, it still did not call "adsManagerDidRequestContentResume" when the ad concluded, and the content did not start playing.

Both of these behaviors (content failing to resume with ad events and content failing to without ad events) are just a subset of the issue we're seeing in our production app, but I was not able to reproduce the issues of our production app in the minimum reproduction case I slapped together - so hopefully I'll be able to figure that one out with a deeper dive. In our production app the IMA SDK is also failing to download the VAST file, leading to an ad load timeout

Because the IMA SDK documentation states that they use a WKWebView for all HTTP requests (VAST file and tracking URLs) and due to the flood of logs saying "kill() returned unexpected error 1" which has been linked to the WebKit library used in iOS 13, and because the unique log that only shows up after locking the screen ("Ignored request to start a new background task") appears to be related to WebKit, I assumed all of these issues were related. But maybe they aren't - since yesterday I was unable to reproduce the ads not loading and today I'm not reproducing no ad events firing. I am still reproducing the content resume method not getting called, however, so this is still a serious issue that needs to be investigated.

IMA SDK

unread,
Feb 10, 2020, 2:24:37 PM2/10/20
to steven....@blueframetech.com, ima...@googlegroups.com

Hi Steven,

I was able to reproduce the behavior that you’re seeing with the content audio that is not resuming as it should when the screen is locked. Our team is going to review the issue. I will get back to you with more information as soon as possible.



Regards,
Arnaud Casame
IMA SDK Team



ref:_00D1U1174p._5001UV02zZ:ref

Paulo Santos

unread,
Mar 12, 2020, 1:29:54 PM3/12/20
to Interactive Media Ads SDK
Any update? I am facing the same issue in my App.

IMA SDK

unread,
Mar 12, 2020, 7:05:17 PM3/12/20
to paulo....@thoughtworks.com, ima...@googlegroups.com
Hi Paulo,

Thank you for following up with support. We don’t have an update for you at this time, but I will come back to this thread as soon as I have more information.



Regards,
Arnaud Casame
IMA SDK Team



ref:_00D1U1174p._5001UV02zZ:ref

Steven Barnett

unread,
Oct 14, 2020, 11:54:17 AM10/14/20
to Interactive Media Ads SDK
Any updates? It's been 7 months

IMA SDK

unread,
Oct 14, 2020, 12:29:13 PM10/14/20
to steven....@blueframetech.com, ima...@googlegroups.com
Hi Steven,

The latest SDK should work correctly. Could you test against it to see if your issue is resolved?

Regards,

Google Logo
Aryeh Baker
IMA SDK Team
 


ref:_00D1U1174p._5001UV02zZ:ref

Ricardo Fernandes

unread,
Jan 29, 2021, 5:10:36 AM1/29/21
to Interactive Media Ads SDK
Hello,

This error was fixed in version 3.11.2 but in version 3.13 it happens again, if you download the sample application provided by Steven Barnett
and run pod update the version installed is 3.11.3 and in this version the sample app works when going to background, but 
 changing the pod file to 

use_frameworks!

platform :ios, '10.0'

target 'IMA SDK Issue' do

    pod 'GoogleAds-IMA-iOS-SDK'

end

and run pod update it will install ima sdk 3.13 and the same error will occur.

Will the next version have this issue solved or are there any plans to solve this? 
My app is using audio advertising and when the app goes to background when the advertasing is playing no methods of ima are called so i cannot resume content.

Regards
Ricardo Fernandes

IMA SDK

unread,
Jan 29, 2021, 9:27:02 AM1/29/21
to ricardo....@velcrodesign.com, ima...@googlegroups.com
Hi Ricardo,

Thank you for reporting this. I replicated this issue in a simulator, the old SDK (3.11.2) runs fine in background and the new one (3.13.0) has that error with running board. When backgrounding the app in a simulator the ad plays delayed and ad events are delayed further but the content doesn't resume. In a device the app stalls on ad event: started. Let me bring this up to my team. We will get back to you as soon as we have more information.

IMA SDK

unread,
Aug 23, 2021, 2:04:30 PM8/23/21
to ima...@googlegroups.com
Hi all,

I know you've been very patiently waiting for an update on this: version 3.14.4 has now been released, with a major rewrite to background behavior. We believe requesting ads should now work as expected when the app is backgrounded.

Thanks,

Greg Schoppe
Reply all
Reply to author
Forward
0 new messages