-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Issue description
Production users of my app are getting following crash sometimes.
Following is the crash logs -:
Fatal Exception: java.lang.IndexOutOfBoundsException
at com.google.android.exoplayer2.h.a.a(Assertions.java:68)
at com.google.android.exoplayer2.source.y.a(SinglePeriodTimeline.java:186)
at com.google.android.exoplayer2.source.h$b.a(ConcatenatingMediaSource.java:841)
at com.google.android.exoplayer2.source.a.a(AbstractConcatenatedTimeline.java:176)
at com.google.android.exoplayer2.a.a$b.a(AnalyticsCollector.java:778)
at com.google.android.exoplayer2.a.a$b.a(AnalyticsCollector.java:724)
at com.google.android.exoplayer2.a.a.a(AnalyticsCollector.java:424)
at com.google.android.exoplayer2.i$a.a(ExoPlayerImpl.java:746)
at com.google.android.exoplayer2.i.a(ExoPlayerImpl.java:681)
at com.google.android.exoplayer2.i.a(ExoPlayerImpl.java:622)
at com.google.android.exoplayer2.i.a(ExoPlayerImpl.java:567)
at com.google.android.exoplayer2.i$1.handleMessage(ExoPlayerImpl.java:109)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6396)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
Reproduction steps
I am using Exoplayer DynamicConcatenatingMediaSource for prefetching next song in song queue.
I am keeping only two sources at a time in DynamicConcatenatingMediaSource.As soon as I get the third source for adding in DynamicConcatenatingMediaSource, I remove the previous index source from DynamicConcatenatingMediaSource.
stacktrace.txt
Following is the code snippet I'm using -:
public void onPositionDiscontinuity(int reason) { int newIndex = exoPlayer.getCurrentWindowIndex(); if (newIndex != currentIndex) { // The index has changed; update the UI to show info for source at // newIndex currentIndex = newIndex; removeMediaSource(exoPlayer.getPreviousWindowIndex()); currentIndex = exoPlayer.getCurrentWindowIndex(); } }
`
private void removeMediaSource(int index) {
if (index >= 0 && index < dynamicConcatenatingMediaSource.getSize()) {
dynamicConcatenatingMediaSource.removeMediaSource(index, new Runnable() {
@Override
public void run() {
if (exoPlayer == null) {
return;
}
currentIndex = exoPlayer.getCurrentWindowIndex();
}
});
}
}`
Version of ExoPlayer being used
Exoplayer version - 2.8.2
Device(s) and version(s) of Android being used
Device-Redmi Note 5 Android-7.1.2
Device-Moto G(4) Plus Android-6.0