RemoteCastPlayer: receiver stalls in buffering when a single setActiveMediaTracks request changes the audio and the text track during playback

Aperta
#3,561 3 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@tanay187 ci sta già lavorando.

Dal 18/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug needs triage
Version

Media3 1.11.0

More version details
  • media3-cast 1.11.0, RemoteCastPlayer wrapped in CastPlayer, with a custom CastTrackSelector
  • play-services-cast-framework 22.3.1
Devices that reproduce the issue
  • Sender: Redmi Note 8 Pro running Android 11 (also seen with a Pixel 6)
  • Receiver: TV Stick (SDMC), Android TV 10, Chromecast built-in 3.72.446070
Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

Not tested in the demo app (the Cast demo has no CastTrackSelector, so it never sends track changes)

  1. Cast a DASH stream with at least two audio languages and one subtitle track, using RemoteCastPlayer with a CastTrackSelector that applies the preferred languages, for example:
    class LanguageCastTrackSelector : CastTrackSelector() {
        override fun evaluate(request: CastTrackSelectorRequest): CastTrackSelectorResult {
            val params = request.trackSelectionParameters
            fun pick(type: Int, language: String?) =
                request.trackGroupList.firstOrNull { it.type == type && it.getFormat(0).language == language }
            val audio = pick(C.TRACK_TYPE_AUDIO, params.preferredAudioLanguages.firstOrNull())
            val text = pick(C.TRACK_TYPE_TEXT, params.preferredTextLanguages.firstOrNull())
            val kept = request.currentlySelectedTrackGroups.filter {
                (it.type != C.TRACK_TYPE_AUDIO || audio == null) && (it.type != C.TRACK_TYPE_TEXT || text == null)
            }
            return request.buildResultUpon().setSelections(ImmutableSet.copyOf(kept + listOfNotNull(audio, text))).build()
        }
    }
    
  2. While the receiver is playing, change the audio and the subtitle at once:
    player.trackSelectionParameters = player.trackSelectionParameters.buildUpon()
        .setPreferredAudioLanguage("<other audio language>")
        .setPreferredTextLanguage("<subtitle language>")
        .build()
    
    RemoteCastPlayer sends one setActiveMediaTracks([audioId, textId]) (a single EDIT_TRACKS_INFO message).
  3. Watch the receiver.
Expected result

The receiver switches both tracks and playback goes on.

Actual result

The receiver never resumes playback and RemoteCastPlayer stays in STATE_BUFFERING. Receiver logcat (cast_shell), with the sender log aligned on it (the two clocks are not synchronized):

  1. The receiver starts playing: Effective playback rate changed from 0 to 1.
  2. The sender sends one setActiveMediaTracks([2, 3]): audio track 2 and text track 3.
  3. The receiver switches the audio: it empties the audio SourceBuffer (remove start=0 end=3826), seeks to the current position (kSeek 2054.58) and goes BUFFERING_HAVE_NOTHING. The system media session reports STATE_BUFFERING with speed 0.
  4. It appends the new audio init segment and 4 audio segments, video and audio go back to BUFFERING_HAVE_ENOUGH, and kPlay is logged twice.
  5. Then nothing happens: no Effective playback rate changed from 0 to 1, no further appendBuffer on either SourceBuffer for the remaining 21 s of the capture, and the media session stays in STATE_BUFFERING. The sender never leaves buffering.

Log excerpt attached (excerpt.txt); full sender and receiver logcats available.

Sending the same change in two requests works every time: setActiveMediaTracks with the new audio only, then, once the receiver status reports that audio as active, setActiveMediaTracks with the new subtitle. We use this as a workaround in our CastTrackSelector.

Is this a known receiver limitation? Since RemoteCastPlayer sends the whole selection in one request, should media3 (or CastTrackSelector) apply audio and text changes one after the other, or is this a CAF receiver bug to report to the Cast SDK team?

Media

Widevine-protected DASH stream, multi-period (pre-roll ad period, then main content).

Bug Report
  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.
Lingua principale
Java
Stelle
3.1k
Fork
1k
Merge medio
6g 4h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di androidx/media

Tutte le issue di androidx/media

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.