I see some crash reports:
Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=2; index=-1
at com.google.android.exoplayer2.source.ConcatenatingMediaSource$ConcatenatedTimeline.getFirstWindowIndexByChildIndex(SourceFile:922)
at com.google.android.exoplayer2.source.AbstractConcatenatedTimeline.getPeriodByUid(SourceFile:207)
at com.google.android.exoplayer2.ExoPlayerImpl.getCurrentWindowIndex(SourceFile:460)
at com.google.android.exoplayer2.analytics.AnalyticsCollector.generateEventTime(SourceFile:632)
at com.google.android.exoplayer2.analytics.AnalyticsCollector.generatePlayingMediaPeriodEventTime(SourceFile:650)
at com.google.android.exoplayer2.analytics.AnalyticsCollector.onTimelineChanged(SourceFile:442)
at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.notifyListeners(SourceFile:771)
at com.google.android.exoplayer2.ExoPlayerImpl.updatePlaybackInfo(SourceFile:708)
at com.google.android.exoplayer2.ExoPlayerImpl.handlePlaybackInfo(SourceFile:639)
at com.google.android.exoplayer2.ExoPlayerImpl.handleEvent(SourceFile:584)
at com.google.android.exoplayer2.ExoPlayerImpl$1.handleMessage(SourceFile:125)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)
_(index always = -1)_
Do you have any idea why it happen?
It maybe something wrong with my implementation, but I'm pretty sure that I access ExoPlayer instance and update ConcatenatingMediaSource in single thread. The stack trace is quite complicated to me to investigate, so please take a look.
Can't.
Not available.
2.9.2
Variety devices.
Variety os versions.
Can't see any issue with the code and it looks almost impossible that this should happen.
That's what I concluded from the stack trace:
ConcatenatedTimeline.getFirstWindowIndexByChildIndex is called with the invalid index -1AbstractConcatenatedTimeline.getPeriodByUid gets the index from a call to ConcatenatedTimeline.getChildIndexByChildUid which may return -1 but only if the uid is not part of the timeline. ConcatenatedTimeline.getPeriodByUid must have been called with a uid which is not part of the timeline.ExoPlayerImpl calls playbackInfo.timeline.getPeriodByUid(playbackInfo.periodId.periodUid,...) which suggests that the periodId.periodUid in a PlaybackInfo object is not part of the timeline in the same PlaybackInfo object.timeline is empty which doesn't apply here). There must obviously be some flaw in my reasoning here, otherwise you wouldn't see the crash. :)
As you already mentioned, it could be that something writes information in parallel. Are you using the main thread for all player access or a background thread? And on which thread do you create the player?
Also, do you have any other information about the context of the crash? Which player interactions came before the crash for example?
@tonihei, i also have this problem :(
Stack trace:
java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1
at com.google.android.exoplayer2.source.ConcatenatingMediaSource$ConcatenatedTimeline.e
at com.google.android.exoplayer2.source.AbstractConcatenatedTimeline.getPeriodByUid
at com.google.android.exoplayer2.ExoPlayerImpl.getCurrentWindowIndex
at com.google.android.exoplayer2.analytics.AnalyticsCollector.generateEventTime
at com.google.android.exoplayer2.analytics.AnalyticsCollector.generatePlayingMediaPeriodEventTime
at com.google.android.exoplayer2.analytics.AnalyticsCollector.onTimelineChanged
at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.notifyListeners
at com.google.android.exoplayer2.ExoPlayerImpl.updatePlaybackInfo
at com.google.android.exoplayer2.ExoPlayerImpl.handlePlaybackInfo
at com.google.android.exoplayer2.ExoPlayerImpl.a
at com.google.android.exoplayer2.ExoPlayerImpl$1.handleMessage
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
ExoPlayer: 2.9.0
All methods of ConcatenatingMediaSource are executed in the main thread. I can not reproduce the problem appears randomly.
@tonihei - We also started noticing this on upgrade form 2.7.3 -> 2.9.0
Intermittent but seen happening with Live/dash multiple period scenarios.
Sample stream:
https://content-duseqa1.downlynk.com/channel/29e9c85c070f413fb71a3b2a39eed208.mpd?ad=dashad
11-22 14:33:27.657 5447-7882/com.yahoo.mobile.client.android.example.yvideosdkdemo E/memtrack: Couldn't load memtrack module
11-22 14:33:27.683 5447-7882/com.yahoo.mobile.client.android.example.yvideosdkdemo E/ExoPlayerImplInternal:Handler-561: UNCAUGHT EXCEPTION
java.lang.ArrayIndexOutOfBoundsException: length=1; index=-1
at com.google.android.exoplayer2.source.ConcatenatingMediaSource$ConcatenatedTimeline.getFirstWindowIndexByChildIndex(ConcatenatingMediaSource.java:880)
at com.google.android.exoplayer2.source.AbstractConcatenatedTimeline.getPeriod(AbstractConcatenatedTimeline.java:217)
at com.google.android.exoplayer2.source.ForwardingTimeline.getPeriod(ForwardingTimeline.java:72)
at com.google.android.exoplayer2.Timeline.getPeriodByUid(Timeline.java:757)
at com.google.android.exoplayer2.ExoPlayerImpl.getCurrentWindowIndex(ExoPlayerImpl.java:492)
at com.google.android.exoplayer2.ExoPlayerImpl.createMessage(ExoPlayerImpl.java:444)
at com.google.android.exoplayer2.source.ConcatenatingMediaSource.scheduleListenerNotification(ConcatenatingMediaSource.java:611)
at com.google.android.exoplayer2.source.ConcatenatingMediaSource.updateMediaSourceInternal(ConcatenatingMediaSource.java:702)
at com.google.android.exoplayer2.source.ConcatenatingMediaSource.onChildSourceInfoRefreshed(ConcatenatingMediaSource.java:525)
at com.google.android.exoplayer2.source.ConcatenatingMediaSource.onChildSourceInfoRefreshed(ConcatenatingMediaSource.java:47)
at com.google.android.exoplayer2.source.CompositeMediaSource.lambda$prepareChildSource$0(CompositeMediaSource.java:104)
at com.google.android.exoplayer2.source.-$$Lambda$CompositeMediaSource$ahAPO18YbnzL6kKRAWdp4FR_Vco.onSourceInfoRefreshed(Unknown Source:4)
at com.verizondigitalmedia.mobile.client.android.player.extensions.MediaItemMediaSource.maybeNotifyTimeline(MediaItemMediaSource.java:102)
at com.verizondigitalmedia.mobile.client.android.player.extensions.MediaItemMediaSource$1.onSourceInfoRefreshed(MediaItemMediaSource.java:47)
at com.google.android.exoplayer2.source.BaseMediaSource.refreshSourceInfo(BaseMediaSource.java:79)
at com.google.android.exoplayer2.source.dash.DashMediaSource.processManifest(DashMediaSource.java:980)
at com.google.android.exoplayer2.source.dash.DashMediaSource.lambda$new$0(DashMediaSource.java:593)
at com.google.android.exoplayer2.source.dash.-$$Lambda$DashMediaSource$e1nzB-O4m3YSG1BkxQDKPaNvDa8.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:789)
@sneltyn This is unrelated and it looks like a known bug we had in 2.8. This should already be fixed.
@juechemparathy This may also be unrelated. It seems that you are using your own MediaSource. Can you check what kind of Timeline this media source is returning and if the uid value of the periods + the value returned by getIndexOfPeriod fit together?
@tonihei, thank! Perhaps you are right and the problem that is fixed above. If it appears then I will inform you.
@tonihei, I caught the same problem as in this ticket.
Stack trace:
java.lang.ArrayIndexOutOfBoundsException: length=2; index=-1
java.lang.ArrayIndexOutOfBoundsException: length=2; index=-1
at com.google.android.exoplayer2.source.ConcatenatingMediaSource$ConcatenatedTimeline.getFirstWindowIndexByChildIndex(ConcatenatingMediaSource.java:922)
at com.google.android.exoplayer2.source.AbstractConcatenatedTimeline.getPeriodByUid(AbstractConcatenatedTimeline.java:207)
at com.google.android.exoplayer2.ExoPlayerImpl.getCurrentWindowIndex(ExoPlayerImpl.java:460)
at com.google.android.exoplayer2.analytics.AnalyticsCollector.generateEventTime(AnalyticsCollector.java:632)
at com.google.android.exoplayer2.analytics.AnalyticsCollector.generatePlayingMediaPeriodEventTime(AnalyticsCollector.java:650)
at com.google.android.exoplayer2.analytics.AnalyticsCollector.onTimelineChanged(AnalyticsCollector.java:442)
at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.notifyListeners(ExoPlayerImpl.java:771)
at com.google.android.exoplayer2.ExoPlayerImpl.updatePlaybackInfo(ExoPlayerImpl.java:708)
at com.google.android.exoplayer2.ExoPlayerImpl.handlePlaybackInfo(ExoPlayerImpl.java:639)
at com.google.android.exoplayer2.ExoPlayerImpl.handleEvent(ExoPlayerImpl.java:584)
at com.google.android.exoplayer2.ExoPlayerImpl$1.handleMessage(ExoPlayerImpl.java:125)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6696)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
ExoPlayer: 2.9.2
I can make a demo in which this problem manifests itself.
I can make a demo in which this problem manifests itself
That would be great! If you have a demo to reproduce the problem, we can probably find out what's wrong.
Just found a potential problem: It looks like we are accessing the player from the wrong thread internally when creating the message to notify the listeners about updates in the playlist. Even though we should fix this, I'm not sure whether this can cause the stack traces posted above.
@tonihei, ok, I'll post a demo soon.
Marking as a bug for tracking the issue Toni mentions above.
Closing as no further evidence of a problem was reported and we have no actionable info to do something. Please re-open if you can provide further information that would help us to identify if and where the problem actually is.
Most helpful comment
Can't see any issue with the code and it looks almost impossible that this should happen.
That's what I concluded from the stack trace:
ConcatenatedTimeline.getFirstWindowIndexByChildIndexis called with the invalid index -1AbstractConcatenatedTimeline.getPeriodByUidgets the index from a call toConcatenatedTimeline.getChildIndexByChildUidwhich may return -1 but only if the uid is not part of the timeline.ConcatenatedTimeline.getPeriodByUidmust have been called with a uid which is not part of the timeline.ExoPlayerImplcallsplaybackInfo.timeline.getPeriodByUid(playbackInfo.periodId.periodUid,...)which suggests that theperiodId.periodUidin aPlaybackInfoobject is not part of thetimelinein the samePlaybackInfoobject.timelineis empty which doesn't apply here).There must obviously be some flaw in my reasoning here, otherwise you wouldn't see the crash. :)
As you already mentioned, it could be that something writes information in parallel. Are you using the main thread for all player access or a background thread? And on which thread do you create the player?
Also, do you have any other information about the context of the crash? Which player interactions came before the crash for example?