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

ArrayIndexOutOfBoundsException occurs in HlsChunkSource #5816

Closed
Leeyoungryun opened this issue Apr 29, 2019 · 3 comments
Closed

ArrayIndexOutOfBoundsException occurs in HlsChunkSource #5816

Leeyoungryun opened this issue Apr 29, 2019 · 3 comments
Assignees
Labels

Comments

@Leeyoungryun
Copy link

Leeyoungryun commented Apr 29, 2019

Hi I'm using exoplayer version 2.9.0

In HlsChunkSource,

There is a code

HlsMediaPlaylist.Segment segment = mediaPlaylist.segments.get(chunkIndex);

however, if chunk index is negative, that chunkIndex cause ArrayIndexOutOfBoundsException.

int chunkIndex = (int) (chunkMediaSequence - mediaPlaylist.mediaSequence);

upper code, that chunkMediaSequence can be negative. if previous chunk's next chunk index is negative, that chunkMediaSequence is negative

I have a question, In what situations is previous chunk index to be negative?

my log

2019-04-29 17:32:47.174 E/ExoPlayerImplInternal: Internal runtime error.
    java.lang.ArrayIndexOutOfBoundsException: length=10; index=-2
        at java.util.ArrayList.get(ArrayList.java:439)
        at java.util.Collections$UnmodifiableList.get(Collections.java:1351)
        at java.util.Collections$UnmodifiableList.get(Collections.java:1351)
        at com.google.android.exoplayer2.source.hls.HlsChunkSource.getNextChunk(HlsChunkSource.java:308)
        at com.google.android.exoplayer2.source.hls.HlsSampleStreamWrapper.continueLoading(HlsSampleStreamWrapper.java:561)
        at com.google.android.exoplayer2.source.CompositeSequenceableLoader.continueLoading(CompositeSequenceableLoader.java:78)
        at com.google.android.exoplayer2.source.hls.HlsMediaPeriod.continueLoading(HlsMediaPeriod.java:247)
        at com.google.android.exoplayer2.MediaPeriodHolder.continueLoading(MediaPeriodHolder.java:160)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.maybeContinueLoading(ExoPlayerImplInternal.java:1580)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleContinueLoadingRequested(ExoPlayerImplInternal.java:1552)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:324)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:214)
        at android.os.HandlerThread.run(HandlerThread.java:65)

@Leeyoungryun Leeyoungryun changed the title ArrayIndexOutOfBoundsException is occured in HlsChunkSource ArrayIndexOutOfBoundsException occurs in HlsChunkSource Apr 29, 2019
@Leeyoungryun
Copy link
Author

Leeyoungryun commented Apr 30, 2019

I investigated some codes.

In HlsChunkSource

"
if (chunkMediaSequence < mediaPlaylist.mediaSequence) {
if (previous != null && switchingVariant) {
// We try getting the next chunk without adapting in case that's the reason for falling
// behind the live window.
selectedVariantIndex = oldVariantIndex;
selectedUrl = variants[selectedVariantIndex];
mediaPlaylist = playlistTracker.getPlaylistSnapshot(selectedUrl);
startOfPlaylistInPeriodUs =
mediaPlaylist.startTimeUs - playlistTracker.getInitialStartTimeUs();
chunkMediaSequence = previous.getNextChunkIndex();
} else {
fatalError = new BehindLiveWindowException();
return;
}
}
int chunkIndex = (int) (chunkMediaSequence - mediaPlaylist.mediaSequence);
"

I have a few questions about that code.

  1. Do you consider if previous is not null and switchingVariant is true, chunkMediaSequence is under than mediaPlaylist.mediaSequence?
    I saw many safe guard(queue is null then switchingVariant is almost false) for sinking with chunks, but upper codition often breaks out.

  2. I think, "switchingVariant is true" means "Threre are some changes about track"
    is that right?

@AquilesCanta
Copy link
Contributor

I think an index out of bounds may be thrown for live content in some scenarios. A fix should be available in the dev-branch relatively soon. However, I'm not sure the fix will make it to 2.10.

ojw28 pushed a commit that referenced this issue Apr 30, 2019
Can happen if the load position falls behind in every playlist and
when we try to load the next segment, the adaptive selection logic
decides to change variant.

Issue:#5816
PiperOrigin-RevId: 245923006
@ojw28
Copy link
Contributor

ojw28 commented Apr 30, 2019

The fix will be included in 2.10.0; thanks!

@ojw28 ojw28 closed this as completed Apr 30, 2019
ojw28 pushed a commit that referenced this issue Apr 30, 2019
Can happen if the load position falls behind in every playlist and
when we try to load the next segment, the adaptive selection logic
decides to change variant.

Issue:#5816
PiperOrigin-RevId: 245923006
@google google locked and limited conversation to collaborators Aug 29, 2019
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

3 participants