ExoPlayer: Crash happening on 2.13.0: ArrayIndexOutOfBoundsException in maybeUpdateAdMediaSources

I want to report a crash using exoplayer v2.13.0 and googleIMA 3.22.0. It’s a TV app in which we have a DAI video and other VOD videos with prerolls/midrolls. Not sure if it’s crashing on live video (DAI) or VOD. Since we updated Exoplayer to 2.13.0 this crash started happening:

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException
length=0; index=1
com.google.android.exoplayer2.source.ads.AdsMediaSource.maybeUpdateAdMediaSources (AdsMediaSource.java:316)
com.google.android.exoplayer2.source.ads.AdsMediaSource.onAdPlaybackState (AdsMediaSource.java:295)
com.google.android.exoplayer2.source.ads.AdsMediaSource.access$100 (AdsMediaSource.java:58)
com.google.android.exoplayer2.source.ads.AdsMediaSource$ComponentListener.lambda$onAdPlaybackState$0 (AdsMediaSource.java:385)
com.google.android.exoplayer2.source.ads.AdsMediaSource$ComponentListener.lambda$onAdPlaybackState$0$AdsMediaSource$ComponentListener (AdsMediaSource.java:7)
com.google.android.exoplayer2.source.ads.-$$Lambda$AdsMediaSource$ComponentListener$0n-PEDqeEt9IJPXJ3J126o4e0MQ.run (-.java:7)
android.os.Handler.handleCallback (Handler.java:751)
android.os.Handler.dispatchMessage (Handler.java:95)
android.os.Looper.loop (Looper.java:154)
android.os.HandlerThread.run (HandlerThread.java:61)

I believe this might be a crash in the Exo SDK itself since we’re not seeing any reference to our code in the stack trace, but even if it’s not could you provide me any information on what could be causing this, as well as any tips to fix it?

  • ExoPlayer version 2.13.0
  • IMA version 3.22.0
  • Android 7 47% of crashes
  • Android 5 45% of crashes
  • Android 9 8% of crashes
  • Android device: Amazon AFTT/AFTTM

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 16 (1 by maintainers)

Commits related to this issue

Most upvoted comments

To clarify, I’m planning to fix the bug anyway (at which either ordering should work again), but if you need a quick fix without waiting for an ExoPlayer release or patch then swapping the order of the calls should do it.

I’m planning to look into this today. Yes, there may is probably a size check missing, but I want to find the code path that’s causing the size to be out of synch just to make sure this isn’t a symptom of another bug.

for the record, this must be something new caused by 2.13.0 though, right? just clarifying because this code where ImaAdsLoader.release() is called before Player.release() has been there for a long time

this crash is still happening on 2.13.2