Repository navigation
Closed
Labels
Description
Version
Media3 main branch
More version details
main, Tested with different versions, seems to be unrelated
Devices that reproduce the issue
Seems to be device unrelated. Can be reproduced on Android 14 emulator, Pixel 7a with Android 15 and other devices.
Emulators seem to reproduce the issue faster than physical devices though.
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
- modify AdaptiveTrackSelection to switch qualities often, e.g. by doing
Index: libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.java
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.java (revision 10fd1ee2704e2e8b669ae0c3120cf37b62291759)
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.java (date 1743068827615)
@@ -482,7 +482,15 @@
reason =
newSelectedIndex == previousSelectedIndex ? previousReason : C.SELECTION_REASON_ADAPTIVE;
selectedIndex = newSelectedIndex;
+
+ if(lastCalledTimeStamp + 5_000 < System.currentTimeMillis()){
+ selectedIndex = 0;
+ lastCalledTimeStamp = System.currentTimeMillis();
+ }else {
+ selectedIndex = 1;
+ }
}
+ private long lastCalledTimeStamp = System.currentTimeMillis();
@Override
public int getSelectedIndex() {
- play media shared via e-mail e.g. on android emulator Pixel 8 Pro Android 14
- observe freeze, usually within ~1 minute
Expected result
No freeze on quality switch OR freeze is reported as player error to enable recovery.
Actual result
After a quality switch the video frame freezes while audio and the playhead continue. This happens regardless of the quality being switched from/to.
- after the freeze MediaCodedAdapter.dequeueInputBufferIndex always returns
-1indicating that the decoder is stuck - overwriting the decoder reuse evaluation on quality switch to
REUSE_RESULT_NOfixes the problem but drops frames on every quality change reducing the overall quality of experience
Media
Will be send via e-mail
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Reacted by Mohammed Adham
Activity
tianyif commentedon Apr 2, 2025
Thanks for the sample media and perfetto traces, and I can easily reproduce this issue on emulator with more aggressive track updating frequency (changing
5_000in your code snippet to1_000).The

DecoderCounter.queuedInputBufferCountandDecoderCounter.renderedOutputBufferCountdidn't increase from the freezing point (0:30):With adding some logs when debugging, it looks like the
MediaCodec.Callback.onInputBufferAvailable / onOutputBufferAvailablewere no longer triggered for video once the playback freezesmedia/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecCallback.java
Lines 214 to 236 in 51efcad
I assume this may be related with the frequent reconfiguration of the
codec. Assigning to my colleague for more insights.strangesource commentedon Apr 3, 2025
Thanks @tianyif, that aligns with our observations.
It does seem to happen also if the codec reconfiguration happens less often but it takes longer - not sure if it's the same "chance" to freeze on every quality switch or if the likelihood is influenced by frequent reconfigurations.
luckygoyal-bitmovin commentedon May 23, 2025
Hi @tonihei , is there any update on this ticket please? Since this behaviour impacts real devices and not just emulator, will really appreciate your thoughts on probable root cause and next steps.
tonihei commentedon May 23, 2025
Thanks for brining it back to our attention :)
I found a minute to take a look and it seems that
luckygoyal-bitmovin commentedon May 23, 2025
Hi @tonihei , thanks for looking into it. Will eagerly await ant further updates/insights. Please let us know if we can provide any further data or any other assistance to root cause the issue.
tonihei commentedon May 27, 2025
There are two main issues here:
Fixing both issues seems to resolve the problems reported for the streams here and in #1285. When playing them very close to the live edge, the only remaining hiccup is an occasional buffering at the track switch points if the pipeline runs out of data (which is more working as intended and goes through the normal state transitions, unlike the issue reported here).
Discard trailing preload hint data when switching tracks
tonihei commentedon May 29, 2025
Both changes are now submitted, will close the issue. Please feel free to reopen or file a new one if anything doesn't look fixed.
strangesource commentedon Jun 2, 2025
Thanks for the fast investigation & fix, much appreciated.
strangesource commentedon Jun 12, 2025
He @tonihei, took me a while to validate the fix but unfortunately I still see freezes happen. I'll be sending a new e-mail with a new test stream as the old one is expired, could you please have another look?
I tested on the latest main branch, at the time of testing this was 6d49937
Reproduced on Pixel 8 Pro emulator API level Level 34
tonihei commentedon Jun 20, 2025
Thanks - I can see the remaining problem as well. We stopped switching tracks if we already know the splice won't succeed. However, it might be that we are reading samples from the data we intend to discard, and then are prevented from discarding it later.
Avoid splice in HLS chunks if it can be fulfilled by discarding
tonihei commentedon Jun 25, 2025
Submitted an additional fix that makes the constantly switching track selection work well with the stream above.
strangesource commentedon Jun 25, 2025
Thanks @tonihei I'll give it another shot. 🙇
Avoid splice in HLS chunks if it can be fulfilled by discarding