-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
[REQUIRED] Issue description
The following IMA Ad Uri is producing an undesired behavior, in which not all Ads in the Midrolls are being played. After 2-3 Ads (out of 7 or 8) content is getting resumed.
It seems that the state hold by AdPlaybackState AdGroup.count differs from what AdPodInfo.getTotalAds() is providing after the actual Ad sequence is loaded.
[REQUIRED] Reproduction steps
- On Exoplayer demo module, include the IMA Uri from below into a content longer than 10 min to allow midrolls to be reached.
- Play midrolls.
Expected: All 7/8 Ads are played.
Actual: Only first 2/3 Ads are played and it continues with Content. (Depending on the Exo version)
[REQUIRED] Link to test content
https://pubads.g.doubleclick.net/gampad/ads?env=vp&gdfp_req=1&unviewed_position_start=1&output=vast&iu=/5374/TV2video/avod/programmer/underholdning/love-island-uk/sesong-5&sz=640x480&description_url=https://www.tv2.no/v/1463716&hl=no&cmsid=2510181&vid=1463716
[REQUIRED] A full bug report captured from the device
Notice the behavior/result is slightly different from 2.11.3 and 2.11.5
2.11.3 is logging some warning after the 3rd Ad is played and content playback continues
ImaAdsLoader: Unexpected ad count in LOADED, 7, expected 3
2.11.5 is logging the following exception after the 2nd Ad is played and content playback continues.
2020-06-08 13:08:00.792 8357-8357/com.google.android.exoplayer2.demo E/ImaAdsLoader: Internal error in loadAd
java.lang.IllegalArgumentException
at com.google.android.exoplayer2.util.Assertions.checkArgument(Assertions.java:39)
at com.google.android.exoplayer2.source.ads.AdPlaybackState$AdGroup.withAdUri(AdPlaybackState.java:151)
at com.google.android.exoplayer2.source.ads.AdPlaybackState.withAdUri(AdPlaybackState.java:399)
at com.google.android.exoplayer2.ext.ima.ImaAdsLoader.loadAd(ImaAdsLoader.java:872)
at com.google.ads.interactivemedia.v3.internal.akf.a(IMASDK:23)
at com.google.ads.interactivemedia.v3.internal.akb.a(IMASDK:177)
at com.google.ads.interactivemedia.v3.internal.akb.a(IMASDK:43)
at com.google.ads.interactivemedia.v3.internal.ake.b(IMASDK:28)
at com.google.ads.interactivemedia.v3.internal.akc.shouldOverrideUrlLoading(IMASDK:6)
at android.webkit.WebViewClient.shouldOverrideUrlLoading(WebViewClient.java:77)
at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(chromium-Monochrome.aab-stable-410409673:16)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
2020-06-08 13:08:00.796 8357-8357/com.google.android.exoplayer2.demo E/EventLogger: internalError [eventTime=29.60, mediaPos=0.21, window=0, loadError
com.google.android.exoplayer2.source.ads.AdsMediaSource$AdLoadException: java.lang.RuntimeException: Internal error in loadAd
at com.google.android.exoplayer2.ext.ima.ImaAdsLoader.maybeNotifyInternalError(ImaAdsLoader.java:1440)
at com.google.android.exoplayer2.ext.ima.ImaAdsLoader.loadAd(ImaAdsLoader.java:875)
at com.google.ads.interactivemedia.v3.internal.akf.a(IMASDK:23)
at com.google.ads.interactivemedia.v3.internal.akb.a(IMASDK:177)
at com.google.ads.interactivemedia.v3.internal.akb.a(IMASDK:43)
at com.google.ads.interactivemedia.v3.internal.ake.b(IMASDK:28)
at com.google.ads.interactivemedia.v3.internal.akc.shouldOverrideUrlLoading(IMASDK:6)
at android.webkit.WebViewClient.shouldOverrideUrlLoading(WebViewClient.java:77)
at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(chromium-Monochrome.aab-stable-410409673:16)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.RuntimeException: Internal error in loadAd
at com.google.android.exoplayer2.ext.ima.ImaAdsLoader.maybeNotifyInternalError(ImaAdsLoader.java:1439)
at com.google.android.exoplayer2.ext.ima.ImaAdsLoader.loadAd(ImaAdsLoader.java:875)
at com.google.ads.interactivemedia.v3.internal.akf.a(IMASDK:23)
at com.google.ads.interactivemedia.v3.internal.akb.a(IMASDK:177)
at com.google.ads.interactivemedia.v3.internal.akb.a(IMASDK:43)
at com.google.ads.interactivemedia.v3.internal.ake.b(IMASDK:28)
at com.google.ads.interactivemedia.v3.internal.akc.shouldOverrideUrlLoading(IMASDK:6)
at android.webkit.WebViewClient.shouldOverrideUrlLoading(WebViewClient.java:77)
at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(chromium-Monochrome.aab-stable-410409673:16)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.IllegalArgumentException
at com.google.android.exoplayer2.util.Assertions.checkArgument(Assertions.java:39)
at com.google.android.exoplayer2.source.ads.AdPlaybackState$AdGroup.withAdUri(AdPlaybackState.java:151)
at com.google.android.exoplayer2.source.ads.AdPlaybackState.withAdUri(AdPlaybackState.java:399)
at com.google.android.exoplayer2.ext.ima.ImaAdsLoader.loadAd(ImaAdsLoader.java:872)
at com.google.ads.interactivemedia.v3.internal.akf.a(IMASDK:23)
at com.google.ads.interactivemedia.v3.internal.akb.a(IMASDK:177)
at com.google.ads.interactivemedia.v3.internal.akb.a(IMASDK:43)
at com.google.ads.interactivemedia.v3.internal.ake.b(IMASDK:28)
at com.google.ads.interactivemedia.v3.internal.akc.shouldOverrideUrlLoading(IMASDK:6)
at android.webkit.WebViewClient.shouldOverrideUrlLoading(WebViewClient.java:77)
at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(chromium-Monochrome.aab-stable-410409673:16)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
]
[REQUIRED] Version of ExoPlayer being used
2.11.3 & 2.11.5 (latest)
[REQUIRED] Device(s) and version(s) of Android being used
It doesn't seem to be affected by device / android version. All.
Potential solution
We have seen that if we allow to change AdGroup.count when the received one from the updated AdPod is greater than the one in the AdGroup, it seems to work.
In r2.11.5, on ImaAdsLoader.loadAd method we have included the mentioned condition.
int adCount = Math.max(adPodInfo.getTotalAds(), adGroup.states.length);
if (adGroup.count == C.LENGTH_UNSET || adCount > adGroup.count)) {
adPlaybackState = adPlaybackState.withAdCount(adInfo.adGroupIndex, adCount);
adGroup = adPlaybackState.adGroups[adInfo.adGroupIndex];
}
Above requires that AdGroupd.withAdCount copy method doesn't check for count == C.LENGTH_UNSET condition.
It seems to be working fine for us so far, but I'm not sure if this is the proper solution. There are other places on ImaAdsLoader where AdPlaybackState.withAdCount is used.
** Sorry this didn't come before 2.11.5 was released :)