[Cast] play() right after setMediaItems() is lost when the receiver already has media, so the new item loads paused
Los mantenedores suelen responder en 4 días
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Version
Media3 1.11.1
More version details
Reproduced on a device with media3-cast 1.9.0 and 1.11.1, and play-services-cast-framework:22.1.0. By reading the source, the same code path is still present on main (@ 31bb0d1), which I haven't run.
Devices that reproduce the issue
Pixel 10, Android 17, casting to a Google Nest Mini on the Default Media Receiver (CC1AD845).
Devices that do not reproduce the issue
n/a. It doesn't depend on the device, only on the receiver already having media when the new load is sent.
Reproducible in the demo app?
Not tested
Reproduction steps
- Start a Cast session to a Default Media Receiver and play any item on the
CastPlayer. - Pause it, so
playWhenReady == false. - Replace the playlist and start playback right away, on the main thread:
A small delay betweencastPlayer.setMediaItems(listOf(otherItem)) castPlayer.prepare() castPlayer.play()setMediaItemsandplay()makes no difference, as long asplay()comes before the receiver reports the new media. We saw it withplay()about 5 ms later.
Expected result
The new item starts playing, as it would on ExoPlayer.
Actual result
The new item loads on the receiver but stays paused, and getPlayWhenReady() goes back to false. Calling play() again afterwards works.
With receiver-side logging (MediaStatus.toJson()), every time:
- The load goes out with
autoplay = false.setMediaItemsbuilds theMediaLoadRequestDatawithsetAutoplay(getPlayWhenReady()), which is stillfalseat that point. play()finds a non-nullgetMediaStatus(), the previous item's status, so it callsremoteMediaClient.play()right away. That request carries the previousmediaSessionId, and the receiver rejects it:W/MediaControlChannel: received unexpected error: Invalid Request.- The receiver reports the new media with a new
mediaSessionId(for example 16 → 17),playerStatePAUSED. updatePlayerStateAndNotifyIfChangedsetsplayWhenReadyfrom!remoteMediaClient.isPaused(), so it becomesfalse.
The relevant code:
setPlayWhenReadyin 1.11.1,RemoteCastPlayer.java#L630-L661. It only skips the RPC whengetMediaStatus() == null. The comment there says that in that case the value "is used to populate autoplay when the client loads media". So the case where nothing is loaded yet is handled, but not the case where a previous item is still loaded and a new load is in flight.- The autoplay flag is read once, when the load is built:
setAutoplay(getPlayWhenReady()). - On
main, the newCastQueueOrchestrator(from #3272) readsPlayerTransferStatewhen it dispatches the load. A load into an idle queue is dispatched immediately, though, andsetPlayWhenReadystill callsremoteMediaClient.play()directly instead of going through the orchestrator. So the order above looks unchanged.
When it does not happen:
- If the player was already playing, the load goes out with
autoplay = true, and the lostplay()doesn't matter. - On a fresh session with no media,
getMediaStatus()is null, so the flag goes into the load's autoplay as intended.
Workaround we use: we note the receiver's mediaSessionId before the load, remember the last user play()/pause() made while the load is in flight, and set playWhenReady again once a status with a new mediaSessionId arrives. It works, but it depends on MediaStatus.toJson() for the session id.
Possible fix: while a load or queue replacement is pending, let setPlayWhenReady update the pending load's autoplay (if it hasn't been sent yet), or defer the play/pause until the receiver reports the new media, for example by queuing it behind the load in CastQueueOrchestrator.
Related, but different: #3373 (failures of these RPCs weren't logged; they are now in 1.12.0-alpha01) and #3272 (queue mutations racing a load).
Media
Not content-dependent. We saw it with live MP3 streams and with regular MP3 files.
Bug Report
- You will email the zip file produced by
adb bugreportto [email protected] after filing this issue.
- Lenguaje dominante
- Java
- Estrellas
- 3.1k
- Forks
- 1k
- Merge medio
- 6 d 4 h
- PR fusionados (30 d)
- 5
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de androidx/media
-
bug needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 4 días
-
CompositionPlayer.release() leaks its playback thread and FrameProcessor when no composition was setPosiblemente ocupada @droid-girl la tomó hace 15 días. Abiertoediting preview
Dificultad 2/5 Medio día Aptitud para principiantes 62/100
androidx/media#3506 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 4 días
-
bug needs triage
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
Los mantenedores suelen responder en 4 días
-
RemoteCastPlayer: receiver stalls in buffering when a single setActiveMediaTracks request changes the audio and the text track during playbackPosiblemente ocupada @tanay187 la tomó hace 1 día. Abiertobug needs triage
androidx/media#3561 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 4 días
-
StuckPlayerException: PLAYING_NO_PROGRESS (1.10.1)Posiblemente ocupada @tonihei la tomó hace 2 días. Abiertoquestion
androidx/media#3559 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 4 días
Todos los issues de androidx/media
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
Vakore/ZappierGames#327 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Radix number block generates NaN after switching a negative or decimal number to binary, octal or hexPosiblemente ocupada @matthewalberto la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
mit-cml/appinventor-sources#4246 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
CatalogueOfLife/backend#1713 ·
Los mantenedores suelen responder en 1 día
-
SystemOneDecisionModel: allow sending chat_template_kwargs to /v1/systemonePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertostatus: waiting-for-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
spring-projects/spring-ai#7427 ·
Los mantenedores suelen responder en 1 día