RemoteCastPlayer silently ignores MediaChannelResult status for setPlayWhenReady, setPlaybackParameters, setRepeatMode and setVolume

Aperta
#3,373 4 commenti 0 reazioni 2 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

@tanay187 ci sta già lavorando.

Dal 14/8/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

cast
Version

Media3 1.11.0

More version details

androidx.media3:media3-cast:1.11.0 with play-services-cast-framework:22.3.1. Findings below come from reading the shipped bytecode of media3-cast-1.11.0.aar with javap -c -p.

Devices that reproduce the issue

Not device-specific. The symptom needs a receiver that rejects a request; mine was a Chromecast Audio on the Default Media Receiver (CC1AD845) with a second sender attached to the same session, which made the receiver answer Invalid Request.

Devices that do not reproduce the issue

n/a

Reproducible in the demo app?

Not tested

Reproduction steps
  1. Cast to a receiver that will reject a request. The reliable way is to join a Default Media Receiver session that another sender is also mutating, so the receiver's sequence numbers stop matching.
  2. Call setPlaybackParameters (or setPlayWhenReady, setRepeatMode, setVolume) on the CastPlayer.
  3. Watch logcat and watch the app.

The Cast SDK reports the rejection:

W/MediaControlChannel: received unexpected error: Invalid Request.
W/MediaControlChannel: Possibility of local queue out of sync with receiver queue.
                       Refetching sequence number. Current Local Sequence Number = 6

Media3 does not, and the app has no callback through which it could learn.

Expected result

An app can tell that a request it issued was rejected by the receiver, so it can retry, reconcile, or tell the user. Media3 already does this for two other request families, which is why the gap reads as an oversight rather than a deliberate contract:

  • RemoteCastPlayer$SeekResultCallback reads Status.getStatusCode() and logs Seek failed. Error code.
  • RemoteCastPlayer$StatusListener logs Session start failed and Session resume failed.
Actual result

The ResultCallback<MediaChannelResult> instances used for the state setters never look at the result. RemoteCastPlayer$1.onResult is representative — it null-checks the client, clears the pending-result bookkeeping and flushes listener events, and that is all:

public void onResult(RemoteMediaClient$MediaChannelResult);
   0: getfield      this$0
   4: invokestatic  RemoteCastPlayer.access$1100   // remoteMediaClient
   7: ifnull        28
  10: ...
  15: invokestatic  RemoteCastPlayer.access$1200   // clear pending callback
  22: invokestatic  RemoteCastPlayer.access$1300   // listeners
  25: invokevirtual ListenerSet.flushEvents
  28: return

RemoteCastPlayer$2 through $5 have the same shape. None of the five references Status, getStatusCode, or isSuccess; by contrast SeekResultCallback does.

Tracing where those five are constructed, they cover:

Callback site Public API
RemoteCastPlayer$1–$5 setPlayWhenReady(boolean), setPlaybackParameters(PlaybackParameters), setRepeatMode(int), setVolume(float), plus updateTracksAndNotifyIfChanged

So a rejected play/pause, playback-speed, repeat-mode or volume change is indistinguishable from a successful one. The player's masked state reverts on the next receiver status, but nothing tells the app why, and nothing is logged.

The practical consequence for me: playback speed set locally did not take effect on the receiver, and there was no way to find out from the library whether the setPlaybackParameters request had been rejected or never mattered. I ended up re-applying the speed after STATE_READY as a workaround, without being able to confirm which of the two it was.

I have not traced the queue-mutation path (queueInsertItems, queueReorderItems, queueRemoveItems, load) to the same level of certainty, so I am not claiming anything about it here — though those also attach a ResultCallback through StateHolder and were what first sent me looking.

Logging a failure the way SeekResultCallback already does would be enough to make this diagnosable. Surfacing it to the app would be better.

Media

Not content-dependent.

Lingua principale
Java
Stelle
3.1k
Fork
1k
Merge medio
8g 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.