Repository navigation
Ima Ads not playing with exception ADS_LOADER.REQUEST_ADS #700
Description
Version
Media3 1.1.1
More version details
We have recently migrated to media3 version 1.1.1 and found that IMA ads are not getting played. After looking at the logcat we got below exception in IMA sdk. Can you help us in finding out what can cause this exception.
Exception in ADS_LOADER.REQUEST_ADS
com.google.ads.interactivemedia.v3.internal.zzwa: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contains(java.lang.CharSequence)' on a null object reference
at com.google.ads.interactivemedia.v3.internal.zzvi.zza(com.google.ads.interactivemedia.v3:interactivemedia@@3.30.3:7)
at com.google.ads.interactivemedia.v3.internal.zzvd.zzb(com.google.ads.interactivemedia.v3:interactivemedia@@3.30.3:2)
at com.google.ads.interactivemedia.v3.internal.zzhb.run(com.google.ads.interactivemedia.v3:interactivemedia@@3.30.3:1)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contains(java.lang.CharSequence)' on a null object reference
at com.google.ads.interactivemedia.v3.internal.zzgt.zza(com.google.ads.interactivemedia.v3:interactivemedia@@3.30.3:1)
at com.google.ads.interactivemedia.v3.internal.zzgx.zza(com.google.ads.interactivemedia.v3:interactivemedia@@3.30.3:13)
at com.google.ads.interactivemedia.v3.internal.zzdq.call(com.google.ads.interactivemedia.v3:interactivemedia@@3.30.3:1)
at com.google.ads.interactivemedia.v3.internal.zzvy.zza(com.google.ads.interactivemedia.v3:interactivemedia@@3.30.3:1)
at com.google.ads.interactivemedia.v3.internal.zzvp.run(com.google.ads.interactivemedia.v3:interactivemedia@@3.30.3:4)
at com.google.ads.interactivemedia.v3.internal.zzvz.run(com.google.ads.interactivemedia.v3:interactivemedia@@3.30.3:1)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
We are creating ad tag xml ourselves and giving it to the sdk. Before migrating to media3 it was working fine. Below is the sample xml/tag that we are using.
<vmap:VMAP xmlns:vmap="http://www.iab.net/videosuite/vmap" version="1.0">
<vmap:AdBreak timeOffset="start" breakType="linear" breakId="preroll">
<vmap:AdSource id="preroll-ad-1" allowMultipleAds="false" followRedirects="true">
<vmap:AdTagURI templateType="vast3"><![CDATA[https://pubads.g.doubleclick.net/gampad/ads?slotname=/124319096/external/ad_rule_samples&sz=640x480&ciu_szs=300x250&cust_params=sar%3Da0f2&url=https://developers.google.com/interactive-media-ads/docs/sdks/html5/tags&unviewed_position_start=1&output=xml_vast3&impl=s&env=vp&gdfp_req=1&ad_rule=0&vad_type=linear&vpos=preroll&pod=1&ppos=1&lip=true&min_ad_duration=0&max_ad_duration=30000&sarid=4576&sf=2&sfu=vid&vrid=4576&npa=false&kfa=0&tfcd=0]]></vmap:AdTagURI>
</vmap:AdSource>
</vmap:AdBreak>
</vmap:VMAP>
Devices that reproduce the issue
LG G6(But should be reproducible in all devices)
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
Try to play IMA ads at preroll
Expected result
Preroll ad should play
Actual result
Ad not playing eventually blocking content playback.
Media
Attaching ad tag that we are using
<vmap:VMAP xmlns:vmap="http://www.iab.net/videosuite/vmap" version="1.0"> <vmap:AdBreak timeOffset="start" breakType="linear" breakId="preroll"> <vmap:AdSource id="preroll-ad-1" allowMultipleAds="false" followRedirects="true"> <vmap:AdTagURI templateType="vast3"><![CDATA[https://pubads.g.doubleclick.net/gampad/ads?slotname=/124319096/external/ad_rule_samples&sz=640x480&ciu_szs=300x250&cust_params=sar%3Da0f2&url=https://developers.google.com/interactive-media-ads/docs/sdks/html5/tags&unviewed_position_start=1&output=xml_vast3&impl=s&env=vp&gdfp_req=1&ad_rule=0&vad_type=linear&vpos=preroll&pod=1&ppos=1&lip=true&min_ad_duration=0&max_ad_duration=30000&sarid=4576&sf=2&sfu=vid&vrid=4576&npa=false&kfa=0&tfcd=0]]></vmap:AdTagURI> </vmap:AdSource> </vmap:AdBreak> </vmap:VMAP>
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Activity
marcbaechinger commentedon Oct 5, 2023
Thanks for your report.
The obfuscated stack trace is difficult to interpret, but at first sight I don't think this is something related to a change in Media3 except that your migration caused a change in the version of the IMA SDK version that's used by the library.
How do you setup the media source for your stream when you are doing this? Are you using the IMA extension of ExoPlayer? You need to give us a bit more context on how you are doing that. I don't know how to achieve this with the IMA extension, so I'm unclear whether this is MEdia3 issue, an SDK issue or an issue with the custom integration you are doing.
Where did you migrate from, or more importantly what IMA SDK library version were you using before? If you know the IMA version you were using before you can verify whether this is an issue with the different SDK by setting the SDK version what you were using before. This would rule out problems with Media3 and confirm the problem is in the interaction with the SDK and your VAST file:
https://docs.gradle.org/current/userguide/dependency_constraints.html#sec:adding-constraints-transitive-deps
google-oss-bot commentedon Oct 25, 2023
Hey @chinmaym14. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
danish241194 commentedon Oct 27, 2023
Hi, we are also facing same issue when using vast xml in base64 encoeded format
Adding Sample Code :
Dependencies :
icbaker commentedon Oct 27, 2023
I think this is only happening with
data://URIs partly due to thisif/elsehere:media/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaUtil.java
Lines 257 to 267 in c16accb
When the URL is
data://scheme then we only call IMA'sAdsRequest.setAdsResponseinstead ofAdsRequest.setAdTagUrl.From the IMA docs, this looks like a legit calling pattern, because
setAdsResponseis documented as follows (emphasis mine):However,
setAdTagUrldoes say:This issue would be a lot more obvious if the IMA SDK failed-fast if
adTagUrlwasn't set. Specifically here, where we pass theAdsRequestinto the IMA SDK'sAdsLoader.requestAdsmethod (which also documents the tag URL as being required):media/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/AdTagLoader.java
Line 578 in c16accb
It seems we should be always setting the tag URL, even if the response is already available. I will update our code.
chinmaym14 commentedon Oct 27, 2023
We resolved this issue by downgrading the IMA sdk version to 3.29.0. They have some unexpected NPE in latest version(same exception we were facing) and recommended to downgrade the version.
Thanks for your help!
1 remaining item
danish241194 commentedon Oct 27, 2023
@icbaker thanks for the detailed info. I tried to pass both vmap xml response and adTag url. if we pass both adResponse and adTagurl and above exception
Exception in ADS_LOADER.REQUEST_ADSis not occuring but ImaUtil is giving preference to adTagUrl and not adResponse.if conditionis failing and hence going to else statementmedia/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaUtil.java
Lines 257 to 267 in c16accb
Is there any way ima uses the response passed and not url.
icbaker commentedon Oct 30, 2023
@danish241194 Ah I think we're talking at different API levels.
I was suggesting in #700 (comment) that ExoPlayer should populate the ad tag URI in the IMA
AdsRequestobject even fordata://scheme URIs where we can also populate the body. This would be a change to the if/else you linked inImaUtil. I wasn't suggesting you change the way you're passing info to ExoPlayer.Your code snippet just sets media3's
MediaItem.AdsConfiguration.adTagUritwice (once from theMediaItem.Builder.AdsConfigurationconstructor, and once from the (deprecated)MediaItem.Builder.setAdTagUrimethod), so the second value overwrites the first. media3'sAdsConfigurationAPI has no explicit 'set response' method, using adata://URI is the expected way to do that.However - given that, despite the documentation, IMA's validation explicitly allows only
AdsRequest.adsResponsewithoutAdsRequest.adTagUri, I think the bug is in IMA if they throw an NPE deeper in their library.@chinmaym14 Can you try bumping to 3.31.0? That's the IMA version used in media3 1.2.0 alpha02 onwards (since b4d03a9). It's possible this is already fixed.
LloydBlv commentedon Dec 16, 2023
Hey @icbaker, This is happening on media3 1.2.0 too, Is this under your radar to fix?
LloydBlv commentedon Dec 16, 2023
icbaker commentedon Dec 18, 2023
@LloydBlv Based on my understanding above, there is no fix to be made for this issue in the media3 library - the NPE happens when interacting with the IMA library in a supported way (i.e. this is a bug inside the IMA SDK).
That said, I'm not able to reproduce. I tried setting a
data://ad URI in the demo app using the XML from the original comment. This is how I'm building theMediaItem:The pre-roll ad plays fine, then the content plays.
How are you reproducing the issue? Please provide a complete code snippet I can adapt for the demo app.
iddqdidkfaidclip commentedon Jan 19, 2024
I too have obfuscated exception in ADS_LOADER.REQUEST_ADS when i try pass Data Uri intead of android.net.Uri.parse(https://link). With link it work how i expected, but now i need to pass raw xml VAST 3.0 data.
Little bit modified snippet of my code with player setup. But in general it equal to upper comment i think.
versions of dependencies
stevemayhew commentedon May 1, 2024
@icbaker you are correct, this is a bug in the IMA SDK itself not ExoPlayer's supplied IMA Extension.
We are using data URL as well, ExoPlayer handles these just fine. ExoPlayer uses the
DataSchemeDataSourceto set the decoded VAST XML directly in AdsRequest.setAdsResponse(). The SDK Docs say either setAdTagUrl() or the response is required.I see different behavior with latest version of SDK (3.33.0), it still reports the error:
But then goes on to process the VAST document.
The version in the head of main (3.31.0), freezes after throwing the Exception.
My guess is the IMA SDK code is trying to reference the AdTagUri, before it even bothers to look if there is a response.
I can provide a pull request, I also posted this comment link to the IMA SDK Google group as well.
Two "fixes" (workaround basically) possible:
For number 2:
@icbaker the one line add,
request.setAdTagUrl(adTagDataSpec.uri.toString());makes the stack trace go away in both 3.33.0 and 3.31.0Bump IMA dependency to 3.33.0 to fix NPE with `data://` URIs
icbaker commentedon May 9, 2024
I've bumped the IMA dependency to 3.33.0 - which it sounds like resolves this issue.
stevemayhew commentedon May 17, 2024
@icbaker it "sort of" fixes it, you still see the IMASDK report the error:
I did get a response from the group, so I'll follow up with them. setting the URL and the request both is the only solution that eliminates the error message. You can see the IMA SDK code, so you know best if the error is still ok
icbaker commentedon May 22, 2024
Heh, fair point! I think I've found the only place that
String.contains()is invoked on the ad tag URL, and I've submitted a change that avoids the invocation if the URL is null - so hopefully that fixes the logging too. I'm not sure when that change will get released in a new IMA SDK version.