Repository navigation
Scrubbing issue with HLS content #2598
Description
Version
Media3 pre-release (alpha, beta or RC not in this list)
More version details
1.8.0-rc01
Devices that reproduce the issue
- Pixel 2 XL
- Samsung A42,
- Others
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
I create a test inside my fork of media3 because it needs some changes into the compose demo. The idea is to implement the new scrubbing feature of ExoPlayer and try using key-frame if they are available.
I added a Slider to seek when slider value changes and it activate scrubbingMode the first time. When slider finishing we disable scrubbingMode. The player is also configured with SeekParameters.CLOSEST_SYNC when scrubbing.
Before this feature we also implemented something similar waiting seek end before seek to the next position to fast seek in the content. It was working fine until this version of the player. The player error is exactly the same.
Expected result
The HLS content seeking fast while scrubbing and when scrubbing ends, the playback continues.
Actual result
The playback stop with a player error when we stop scrubbing, some times is doesn't have error, but most of the time it has.
15:14:38.032 E playerFailed [eventTime=2647.10, mediaPos=342.00, window=1, period=1, errorCode=ERROR_CODE_UNSPECIFIED (Ask Gemini)
androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:910)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1
at java.util.ArrayList.get(ArrayList.java:439)
at androidx.media3.exoplayer.hls.HlsSampleStreamWrapper.getLastMediaChunk(HlsSampleStreamWrapper.java:1544)
at androidx.media3.exoplayer.hls.HlsSampleStreamWrapper.getNextLoadPositionUs(HlsSampleStreamWrapper.java:759)
at androidx.media3.exoplayer.hls.HlsSampleStreamWrapper.seekInsideBufferUs(HlsSampleStreamWrapper.java:1567)
at androidx.media3.exoplayer.hls.HlsSampleStreamWrapper.seekToUs(HlsSampleStreamWrapper.java:519)
at androidx.media3.exoplayer.hls.HlsSampleStreamWrapper.selectTracks(HlsSampleStreamWrapper.java:464)
at androidx.media3.exoplayer.hls.HlsMediaPeriod.selectTracks(HlsMediaPeriod.java:326)
at androidx.media3.exoplayer.source.MaskingMediaPeriod.selectTracks(MaskingMediaPeriod.java:189)
at androidx.media3.exoplayer.MediaPeriodHolder.applyTrackSelection(MediaPeriodHolder.java:339)
at androidx.media3.exoplayer.ExoPlayerImplInternal.reselectTracksInternal(ExoPlayerImplInternal.java:2235)
at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:742)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
]
The issue happens here, I suspect an race condition issue because it should not have an index=-1 when the list has items.
Media
The HLS media provide in videos.kt
- https://demo.unified-streaming.com/k8s/features/stable/no-handler-origin/tears-of-steel/tears-of-steel-trickplay.m3u8
- https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Activity
icbaker commentedon Jul 10, 2025
Does this mean you see the same error both when using
ExoPlayer.setScrubbingModeEnabledand when using your own hand-rolled scrubbing mode? i.e. it suggests that the change you're seeing is in the HLS stack, rather than being directly related to the new scrubbing mode?StaehliJ commentedon Jul 10, 2025
Totally I didn't go through all changes introduced, but I assume some changes have been done somewhere when player is changing track selection and have seek operation or something like that related.
In my previous implementation, we disable audio and metadata tracks via the track selector and restore them when user stop interacting with the slider. Of course we paused the player and setup the SeekParameters.
The issue is not only related to only scrubbing mode indeed.
tianyif commentedon Jul 11, 2025
@StaehliJ,
I can reproduce this issue on demo app with passing
trueto thePlayerControlView.setTimeBarScrubbingEnabledmedia/libraries/ui/src/main/java/androidx/media3/ui/PlayerControlView.java
Lines 1156 to 1158 in 906eb40
which enables the scrubbingMode when I drags the scrubber.
The scrubbingMode just makes the issue easily reproducible though, the problem is in the
HlsSampleStreamWrapperitself. When scrubbingMode enabled, the audio disabled, so theHlsSampleStreamWrapperfor audio clears themediaChunks:media/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsSampleStreamWrapper.java
Lines 414 to 430 in 906eb40
But when audio is restored after scrubbing, its
HlsSampleStreamWrapperattempts to find the next load position among from the last loaded chunk, but themediaChunkshas been emptied (elsecondition, where we already passed anullchunk due to no chunks available).media/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsSampleStreamWrapper.java
Lines 1559 to 1570 in 906eb40
We will be providing a fix for it.
[HLS] Do not try to seek inside buffer when no chunks are in the buffer
[HLS] Do not try to seek inside buffer when no chunks are in the buffer