Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting IndexOutOfBoundsException crash in SinglePeriodTimeline #4634

Closed
harshitwynk opened this issue Aug 9, 2018 · 8 comments
Closed

Getting IndexOutOfBoundsException crash in SinglePeriodTimeline #4634

harshitwynk opened this issue Aug 9, 2018 · 8 comments
Assignees
Labels

Comments

@harshitwynk
Copy link

harshitwynk commented Aug 9, 2018

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

@ojw28
Copy link
Contributor

ojw28 commented Aug 9, 2018

Please can you de-obfuscate the stack trace.

@ojw28 ojw28 added the bug label Aug 9, 2018
@harshitwynk
Copy link
Author

harshitwynk commented Aug 10, 2018

Please find below de-obfuscated stack trace.

Fatal Exception: java.lang.IndexOutOfBoundsException
       at com.google.android.exoplayer2.util.Assertions.checkIndex(Assertions.java:68)
       at com.google.android.exoplayer2.source.SinglePeriodTimeline.getPeriod(SinglePeriodTimeline.java:186)
       at com.google.android.exoplayer2.source.ConcatenatingMediaSource$DeferredTimeline.getPeriod(ConcatenatingMediaSource.java:841)
       at com.google.android.exoplayer2.source.AbstractConcatenatedTimeline.getPeriod(AbstractConcatenatedTimeline.java:176)
       at com.google.android.exoplayer2.analytics.AnalyticsCollector$MediaPeriodQueueTracker.updateMediaPeriodToNewTimeline(AnalyticsCollector.java:778)
       at com.google.android.exoplayer2.analytics.AnalyticsCollector$MediaPeriodQueueTracker.onTimelineChanged(AnalyticsCollector.java:724)
       at com.google.android.exoplayer2.analytics.AnalyticsCollector.onTimelineChanged(AnalyticsCollector.java:424)
       at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.notifyListeners(ExoPlayerImpl.java:746)
       at com.google.android.exoplayer2.ExoPlayerImpl.updatePlaybackInfo(ExoPlayerImpl.java:681)
       at com.google.android.exoplayer2.ExoPlayerImpl.handlePlaybackInfo(ExoPlayerImpl.java:622)
       at com.google.android.exoplayer2.ExoPlayerImpl.handleEvent(ExoPlayerImpl.java:567)
       at com.google.android.exoplayer2.ExoPlayerImpl$1.handleMessage(ExoPlayerImpl.java:109)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6165)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)

stacktrace1.txt

@chandraveerr
Copy link

chandraveerr commented Aug 20, 2018

I am also facing the exactly same crash in my app in production on exoplayer version 2.8.2. This crash happens while adding or removing media in ConcatenatingMediaSource using addMediaSource or removeMediaSource. This crash is affecting a large portion of our users, is there a fix or workaround for this ?

@tonihei
Copy link
Collaborator

tonihei commented Aug 20, 2018

Unfortunately, I can't reproduce the issue with the code above. Can you try to provide minimal reproduction steps in our demo app? Please also verify that you access ExoPlayer from the main thread only as this issue may have been caused by parallel access.

In any case, we will change something internally which will make the problem obsolete as the call to this method won't happen anymore.

@chandraveerr
Copy link

Thanks for the quick reply. We are for sure accessing Exoplayer from main thread. Unfortunately i can't provide any reproduction steps as this crash comes at scale(when we release app).
In which version are you planing to release the change where this method won't be called ?

@tonihei
Copy link
Collaborator

tonihei commented Aug 20, 2018

Most likely 2.9.0, but we don't have a fixed date for that yet.

ojw28 pushed a commit that referenced this issue Sep 3, 2018
The current structure tries to associate events to media periods and windows
based on the reported values and the current timeline. However the reported
EventTime may not always be consistent in case the timeline doesn't contain
windows or media periods yet or not anymore.

The recent changes to MediaPeriodId allow to use it as a unique identifer for
media periods independent of the timeline. This enables more accurate tracking
of the media period queue and prevents reporting events with inconsistent
data.

Issue:#4492
Issue:#4634

-------------
Created by MOE: https:/google/moe
MOE_MIGRATED_REVID=210713120
@ojw28
Copy link
Contributor

ojw28 commented Sep 7, 2018

@tonihei - Can this issue be closed?

@tonihei
Copy link
Collaborator

tonihei commented Sep 7, 2018

Yes, it's fixed (or rather not longer applicable) by above mentioned change.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants