(iOS) With AirPlay enabled, ads "finish" playback prematurely

585 views
Skip to first unread message

Sergio PR

unread,
Nov 19, 2019, 5:49:54 AM11/19/19
to Interactive Media Ads SDK
If I enable AirPlay and play content with ads, I see how the IMAAdsManager tells me to resume the content after a few seconds of playback, before the ads are actually finished. When AirPlay is not enabled on iOS, this doesn't happen and ad playback finishes as one would expect.

I've observed that right when this happen, I get this log from the SDK:

{

    adData =     {

    };

    logData =     {

        errorCode = 402;

        errorMessage = "VAST media file loading reached a timeout of 8 seconds.";

        type = adPlayError;

    };

}


However as I say, the playback started playing without issue.


I'm using Google IMA SDK for iOS v3.10.1

IMA SDK

unread,
Nov 19, 2019, 2:22:33 PM11/19/19
to sergio....@gmail.com, ima...@googlegroups.com
Hi Sergio,

Thank you for reaching out to us. The VastErrorCode: 402 is a fatal error that can be caused by a problem fetching or playing the VAST MediaFile, and could be any of the following:
  • The loadVideoTimeout is set too low in the IMA SDK. The default is 8 seconds.
  • Low bandwidth or poor website implementation with competing requests that delay loading of the MediaFile.
  • A video auto-plays in a mobile environment, whereas it should be click-to-play (there are some exceptions).
  • Showing video ads in an auto-play environment (for example, a playlist), while the window is not in focus (either another tab is selected, or window is minimized).*
The recommended actions are:
  • Increase the timeout limit of your player via the SDK.
  • Ensure that any CDN-hosted creatives are returned within the specified media timeout.

Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5001UOCbFO:ref

Sergio PR

unread,
Nov 19, 2019, 3:10:15 PM11/19/19
to Interactive Media Ads SDK
Thank you for your quick reply!

However it's a bit weird, because what surprises me is that the ad has loaded and is actually playing! So I don't know how could it time out if it's already playing :-\ If it's playing, I assume it has already loaded the VAST manifest, found the ad pods and all that, right?

And again, this only happens with AirPlay enabled. If I disable AirPlay, the ad also plays, but I don't get a time out.

IMA SDK

unread,
Nov 19, 2019, 5:21:19 PM11/19/19
to sergio....@gmail.com, ima...@googlegroups.com
Hi Sergio,

You're right, the VAST manifest was already loaded (on the LOADED event) but the VastErrorCode: 402 is an issue with the video that timed out not the VAST manifest. Added to that, when streaming, the entire video is not downloaded at once on the device, it is downloaded by chunk of files. One of the chunks probably timed out while being downloaded by the player causing the SDK to throw the VastErrorCode 402.


Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5001UOCbFO:ref

Sergio PR

unread,
Nov 25, 2019, 5:16:51 AM11/25/19
to Interactive Media Ads SDK
Thank you again for your reply :D

I've been digging into this a bit further: the ads are mp4 files and I observed with a proxy that they're downloaded steadily without any issues, so in theory there should be no reason to time out loading the media 🤔

And this happens in multi-pod ad breaks, where every single pod starts playing smoothly for 8 seconds and then I get that error and it skips to the next pod. And again, this doesn't happen when I play the very same ads in my iPhone/iPad, which of course is in the very same LAN network as my Apple TV, with 300/300 Mbps connection.

Any idea if this problem could be on Google IMA SDK's side or Apple's side? It seems like everything should be fine on my end 🤔

Thanks again!

IMA SDK

unread,
Nov 25, 2019, 2:12:58 PM11/25/19
to sergio....@gmail.com, ima...@googlegroups.com
Hi Sergio,

It is not an issue with the IMA SDK, if you take a closer look at your VAST XML, you'll see that it contains multiple MediaFile elements each of them has a URL that returns the media file when called. The SDK picks the right MediaFile to play depending on the player environment and capabilities. The issue may come from the ad server where its response time is slow enough to cause the ad player to not receive first video frame before the 8 seconds timeout required by the SDK. This is the reason why in the recommendations I previously shared, it is asked that you ensure that any CDN-hosted creatives are returned within the specified media timeout.


Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5001UOCbFO:ref

Sergio PR

unread,
Nov 26, 2019, 3:25:41 AM11/26/19
to Interactive Media Ads SDK
The issue may come from the ad server where its response time is slow enough to cause the ad player to not receive first video frame before the 8 seconds timeout required by the SDK.

That is exactly the problem: as I pointed out in my previous messages, the ad player not only receives the first frame very quickly, but is also capable of smooth playback during those 8 seconds. So if there is quick and smooth playback of the ad during 8 whole seconds, why did it time out?

If the problem is that the download of the media file got stuck at some point later, I also checked with a proxy and the player seemed to download the whole file steadily and without problems.

That's why I asked if it could be a problem in the interaction between IMA SDK and the AVPlayer instance used to play the ads, when AirPlay is enabled🤔

IMA SDK

unread,
Nov 26, 2019, 2:21:18 PM11/26/19
to sergio....@gmail.com, ima...@googlegroups.com
Hi Sergio,

We need to verify a few parameters with your IMA set up before we can tell you whether it's an issue with the SDK or the ad that you're using. Were you able to reproduce the behavior using our iOS sample app? If yes, can you share a screen recording showing the behavior you reported? We will also need the ad tag URL you were using and the proxy you recorded showing that the ad player downloaded the whole file while Airplay was enabled, can you share these information?


Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5001UOCbFO:ref

Sergio PR

unread,
Nov 27, 2019, 1:08:28 PM11/27/19
to Interactive Media Ads SDK
Thanks Arnaud :D

I tested your iOS sample app and it was very interesting. There are multiple examples, so I tried with the AdvancedExample and the BasicExample (both Objective-C in case it makes any difference to you) with the very same video and ad tag URL and they presented different behavior:
  • AdvancedExample worked flawlessly with AirPlay: ads finished when they should, and it switched between ads and content as you would expect. If you check the events received by the IMAAdsManager, you can see LOADED, STARTED, FIRST_QUARTILE, etc. All normal.
  • BasicExample however presented exactly the same behavior I described: ads finish early and if you print the events received by the IMAAdsManager you will only see LOADED and then LOG after those 8 seconds of playback, indicating the referred timeout. As a side note (although probably not important for this particular problem), in order to make the ad/content switching work with AirPlay, I had to set `allowsExternalPlayback` of the content AVPlayer instance to YES in `adsManagerDidRequestContentPause:` and to NO in `adsManagerDidRequestContentResume:`.

In terms of implementation, the main difference I see between both is that the AdvancedExample uses 1 AVPlayer instance for both content and ad playback, while the BasicExample (and my app) have 1 AVPlayer instance for content, and lets Google IMA SDK create another one for ads if needed. This difference can be observed in the way IMAAdsRequest are built in both.

As I say, in both I used the same data:

Regarding the proxy data, I couldn't make it work this time. For some reason, the profile I added to my Apple TV to use Charles Proxy has disappeared from the device and I'm unable to add it again 😐 I hope having 1 ad tag URL and 2 different usages of IMA SDK (one that work and one that doesn't) is enough for you to understand the problem better.

In any case, I recorded a video where I show you how I test both apps and the result. If you have any doubts about what you see (or hear… my English is quite bad, sorry 😳) please, let me know and I'll be happy to help.


Regards,
Sergio

IMA SDK

unread,
Nov 27, 2019, 4:45:57 PM11/27/19
to sergio....@gmail.com, ima...@googlegroups.com
Hi Sergio,

Thank you for providing additional insights with regards to the issue. The iOS sample apps we hosted on Github are just proof of concept of the IMA integration with the iOS platform. They don't contain all the codes that would prevent the app from throwing errors or crash under certain circumstances. The issue that occurred with the BasicExample seems to be with the implementation when it is confronted to the iOS Airplay set up. However, the results of your tests against the AdvancedExample, make it seems that the issue you initially reported is with your implementation of the IMA SDK. We would recommend you to debug your app against our AdvancedExample.

Sergio PR

unread,
Nov 28, 2019, 4:51:08 AM11/28/19
to Interactive Media Ads SDK
Hmmm but I don't understand. My app is using (and unfortunately must use) the same approach as in the BasicExample, which doesn't give IMA SDK control over the AVPlayer instance, and only passes the `currentTime` via the IMAContentPlayahead protocol implementation. That seems to be the only difference with the AdvancedExample. If that API is still valid, and doesn't work properly with AirPlay while the other available API does, shouldn't that first approach used in BasicExample be fixed on the IMA SDK side?

Or are you telling me that approach just doesn't work with AirPlay and never will?

Thank you!

Regards,
Sergio

IMA SDK

unread,
Nov 28, 2019, 7:41:18 AM11/28/19
to sergio....@gmail.com, ima...@googlegroups.com

Hi Sergio,

This is Sherwin and I'll be assisting you with your concern, as Arnaud is currently out of the office.

I've checked the video file that you have shared. However, it's not clear if the app crashes at the last part of the video. With this, could you confirm if the issue is only occurring to the IMA SDK for iOS Basic sample app and not with the Advance example?

Also, would you be able to provide a stack trace or error log that you've encountered while testing? Please do share with us, so we can investigate further.


Regards,
Sherwin Diesta
IMA SDK Team



ref:_00D1U1174p._5001UOCbFO:ref

Sergio PR

unread,
Nov 28, 2019, 8:07:25 AM11/28/19
to Interactive Media Ads SDK
Hello Sherwin,

thanks for your help! The issue at hand is not a crash: the problem is IMA SDK is erroring with media file timeouts when it shouldn't, when AirPlay is enabled, causing the ads to finish after playing smoothly for ~8 seconds. 

The video shows how it happens with the Basic sample app (which matches with the integration of IMA SDK in my app) but not with the Advanced one (which I can't use as an example of integration for my app). What you see shows the same video and the same ads being played with both examples. If the ads don't time out in one example, they shouldn't time out in the other… unless there is a bug in the integration or in IMA SDK. Since this only happens when AirPlay is enabled, I'm inclined to believe this is a bug inside of IMA SDK, but I might be wrong 😅

Regards,
Sergio

IMA SDK

unread,
Nov 28, 2019, 10:17:19 PM11/28/19
to sergio....@gmail.com, ima...@googlegroups.com

Hi Sergio,

Thanks for your response and for your confirmation. Let me share this information with my teammates for further investigation, and I'll get back to you as soon as I have more information.




Regards,
Sherwin Diesta
IMA SDK Team



ref:_00D1U1174p._5001UOCbFO:ref

JING

unread,
Aug 5, 2024, 3:46:54 AM (2 days ago) Aug 5
to Interactive Media Ads SDK

I have encountered this issue under the same conditions on the iPhone/iPad.

1. AirPlay Enabled: When the VMAP ad finishes playback, an event error with errorCode = 402 appears. Otherwise, ad playback works well.

2. Demo “AdvancedSample”: The same issue occurs.

2.1 I changed some IMAAdsRequest API calls to use contentPlayhead (with the main video using the BitmovinPlayer SDK for playback) instead of using *** avPlayerVideoDisplay, pictureInPictureProxy ***.”

contenPlayhead:

let request: IMAAdsRequest = IMAAdsRequest(

        adTagUrl: adTagUrl, adDisplayContainer: createAdDisplayContainer(),

        contentPlayhead: playhead, userContext: nil)


IMA SDK

unread,
Aug 5, 2024, 10:36:08 AM (2 days ago) Aug 5
to qqian...@gmail.com, ima...@googlegroups.com

Hi,

Thank you for getting back to us.

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

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

Thanks,
 
Google Logo IMA SDK Team


JING

unread,
Aug 6, 2024, 10:23:11 AM (19 hours ago) Aug 6
to Interactive Media Ads SDK
hi,   
    I have create a conversation at the "https://groups.google.com/g/ima-sdk/c/4d9HVKK-4V4" , please have a check.

Thanks
JING

Interactive Media Ads SDK

unread,
Aug 6, 2024, 12:50:04 PM (17 hours ago) Aug 6
to Interactive Media Ads SDK
Hi,

Unfortunately, the IMA SDK for iOS does not currently support Apple AirPlay. I apologize for any confusion associated with this functionality.

Thanks,

Greg Schoppe
IMA SDK Team
Reply all
Reply to author
Forward
0 new messages