ExoPlayer: IMA shouldOverrideUrlLoading NPEs
Issue description
We are seeing a lot of NullPointerException’s in Firebase coming from IMA in our latest release, containing ExoPlayer 2.12.0 and IMA 3.21.4 (Note: ExoPlayer specifies 3.21.0, so we’ve bumped it slightly).
GIven it’s IMA and obfuscated it’s hard to work out exactly what is going wrong from our perspective. It seems like at some point the WebView is triggering a URL load, which is causing IMA to call into components it thinks should not be null, but are at that point.
I’m guessing it’s some kind of lifecycle thing, maybe ExoPlayer has detached when this event occurs or hasn’t attached yet. Hoping someone who has worked with the IMA code could shed some light / point me in the right direction.
Reproduction steps
I have been so far unable to reproduce this, or find a specific flow making it happen.
Link to test content
Not content specific.
Stacktraces
Note, the actual crashes have repeats of this due to the way WebViews are implemented across devices.
Crash 1
Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object com.google.ads.interactivemedia.v3.api.StreamRequest.getUserRequestContext()' on a null object reference
at com.google.ads.interactivemedia.v3.internal.amr.c(IMASDK:3)
at com.google.ads.interactivemedia.v3.internal.aog.d(IMASDK:66)
at com.google.ads.interactivemedia.v3.internal.aom.d(IMASDK:5)
at com.google.ads.interactivemedia.v3.internal.aoj.shouldOverrideUrlLoading(IMASDK:2)
at android.webkit.WebViewClient.shouldOverrideUrlLoading(WebViewClient.java:77)
at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(chromium-Monochrome.aab-stable-428010123:17)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
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(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Crash 2
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.ads.interactivemedia.v3.internal.and.g()' on a null object reference
at com.google.ads.interactivemedia.v3.internal.amr.a(IMASDK:2)
at com.google.ads.interactivemedia.v3.internal.aog.d(IMASDK:71)
at com.google.ads.interactivemedia.v3.internal.aom.d(IMASDK:5)
at com.google.ads.interactivemedia.v3.internal.aoj.shouldOverrideUrlLoading(IMASDK:2)
at android.webkit.WebViewClient.shouldOverrideUrlLoading(WebViewClient.java:77)
at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(chromium-Monochrome.aab-stable-428014120:17)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:183)
at android.app.ActivityThread.main(ActivityThread.java:7258)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Version of ExoPlayer being used
2.12.0 with IMA 3.21.4
Device(s) and version(s) of Android being used
Device and OS independent
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (3 by maintainers)
Commits related to this issue
- Upgrade IMA SDK dependency to 3.22.3 This brings in a fix for `NullPointerExceptions` within `WebView` callbacks in the IMA SDK. Issue: #8447 PiperOrigin-RevId: 363627446 — committed to google/ExoPlayer by andrewlewis 3 years ago
- Upgrade IMA SDK dependency to 3.23.0 This brings in another fix for `NullPointerExceptions` within `WebView` callbacks in the IMA SDK, related to companion ads. Issue: #8447 #minor-release PiperOr... — committed to google/ExoPlayer by andrewlewis 3 years ago
- Upgrade IMA SDK dependency to 3.22.3 This brings in a fix for `NullPointerExceptions` within `WebView` callbacks in the IMA SDK. Issue: #8447 PiperOrigin-RevId: 363627446 — committed to google/ExoPlayer by andrewlewis 3 years ago
- Upgrade IMA SDK dependency to 3.23.0 This brings in another fix for `NullPointerExceptions` within `WebView` callbacks in the IMA SDK, related to companion ads. Issue: #8447 #minor-release PiperOr... — committed to google/ExoPlayer by andrewlewis 3 years ago
- Upgrade IMA SDK dependency to 3.22.3 This brings in a fix for `NullPointerExceptions` within `WebView` callbacks in the IMA SDK. Issue: #8447 PiperOrigin-RevId: 363627446 — committed to roblav96/ExoPlayer by andrewlewis 3 years ago
- Upgrade IMA SDK dependency to 3.23.0 This brings in another fix for `NullPointerExceptions` within `WebView` callbacks in the IMA SDK, related to companion ads. Issue: #8447 #minor-release PiperOr... — committed to roblav96/ExoPlayer by andrewlewis 3 years ago
- Dev v2 (#2) * Add buildUpon to MediaMetadata. PiperOrigin-RevId: 364590789 * Add commands only available in SimpleExoPlayer PiperOrigin-RevId: 364598601 * Improve commands Javadoc Pipe... — committed to shenwill/ExoPlayer by shenwill 3 years ago
A fix has been submitted for this. I’ll look out for the next IMA SDK update and hopefully we can get that into the next minor release.
@fpitters looks like IMA SDK team has release a fix for the NPE crash https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/history We will try to see if it’s fixes our issue in production which is identical to your report.
@AlienAsRoger This crash looks like it has a different cause to the others based on the stack trace. Did you see an increase in this recently, or was it present on older versions too? The cause appears to be that BitmapFactory.decodeStream is returning
nullfor the companion ad URL.Nice @andrewlewis because I’m seeing this a lot on the latest crashlytics reports which are bad for the company I work for
Forcing the later version should be fine (I think there won’t be any API incompatibilities, so it should only require the gradle change). I’d probably do a bit of manual testing anyway just to be safe.
Thank you for keeping track of this.
This is a report from Firebase using 3.22.2 with latest Exo 2.13.2.
Sorry for the delay. The fix for the stack trace with
getUserRequestContextis in 2.22 (“Fixes the error message when AdsLoader would receive an error without a valid session ID.”).Looking at the internal issue, I don’t think the second crash has been diagnosed yet. I also added a note there about the crash reported in https://groups.google.com/g/ima-sdk/c/BvHHkeXvhL4, which appears to have a similar cause (missing session ID).
There’s a fix for the
NullPointerExceptionwhich will hopefully go into the next IMA SDK release (I’d guess this will be 3.22.1 as it just missed the 3.22.0 release – here’s the repository). Although this will fix the NPE, without details about how the error was triggered, it’s hard to say what the root cause could be. With the fix, it’s possible that a more informative error will be propagated to allow diagnosing what’s going on.