Skip to content

Keep the user informed during playback renegotiation: show a loading state and explanatory copy during replan #79

Open

Description

@CoffeeKnyte

Context: the renegotiation loop itself works, and it's great

Worth stating up front, because this issue is not a bug report against the renegotiation
machinery: the protocol v3 replan loop is genuinely excellent and does exactly what it should.
When a stream turns out to be unplayable — the client claimed a capability it didn't really
have, a decoder rejects the video, an output route changes mid-stream — the client classifies
the failure, tells the server which routes it already tried, and the server walks it down to
something that actually plays. It's careful about the things that are easy to get wrong: audio-sink
failures get a local retry instead of a downgrade, transient network errors get a same-route
retry, attempted plan keys accumulate so the server never re-offers a dead route, and the loop
is guarded against ping-ponging from both ends. Playback that would simply have failed now
recovers on its own.

The gap is purely that we don't tell the user any of this is happening. All the value of
that recovery is invisible, and this issue is about closing that one gap.

Problem

The user is left out of the loop while a renegotiation runs.

When the client renegotiates a stream with the server, the user sees a frozen last frame or a
black screen with no spinner, no text, and no indication that anything is happening — for
anywhere from a couple of seconds to well over a minute. From the outside there is nothing
distinguishing "we're actively fetching you a stream that will work" from "this app has hung."

So the recovery succeeds, but the user may never find out: they're likely to hit Back or
force-quit before the replacement stream arrives, and a feature that worked perfectly reads as
a failure. This is the moment the app is doing its most valuable work and saying the least about it.

Where it shows up: any time the player hits a hard failure and falls back — an unsupported
Dolby Vision profile, a lossless audio track the output can't take, a decoder that rejects the
video, or a wedged decoder caught by the stall watchdog. It affects both the phone and TV
players.

How long the user waits without feedback:

  • Best case — the decoder throws immediately and the server hands back a cheap route: a few seconds.
  • Typical — around 25-40 seconds across two or three rounds.
  • Worst realistic — roughly 80-100 seconds, when each failing route freezes rather than
    throwing (so each round pays the full 20s stall-detector grace) and the final route is a
    CPU-bound 4K encode.

For scale on that last number: the server will not serve a transcode manifest until it has
produced three two-second segments, i.e. six seconds of encoded media
(minManifestSegments/defaultSegmentDuration in silo-server internal/playback/transcode.go),
and it will hold the request open up to 30s waiting for them.

Solution

Show a loading state for the duration of the replan

Nothing is wrong with the replan path itself — the UI simply has no state raised while it runs.
Two things combine to leave the screen looking inert:

  1. A fatal PlaybackException puts ExoPlayer in STATE_IDLE, not STATE_BUFFERING. So
    onBufferingChanged (PlayerViewModel.kt:1499) is never called with true, isBuffering
    stays false, and the normal buffering affordances — PlayerOverlay.kt:194 on mobile, the
    "Buffering" chip at TvPlayerScreen.kt:2303-2330 on TV — never render.
  2. The replan success path only clears the error; it never raises a loading flag.
    PlayerViewModel.kt:1202-1218 and TvPlayerViewModel.kt:1354-1379 do
    _uiState.update { it.copy(error = null, …) } with isLoading untouched.

Proposed change: set an explicit renegotiation state when a replan is dispatched and clear it
when the replacement stream reaches first frame (or the attempt terminates). This should be its
own flag rather than reusing isLoading/isBuffering, so the overlay can carry
renegotiation-specific copy without hijacking the ordinary buffering spinner.

Entry points that should raise it — every caller that dispatches startProtocolV3Replan:

  • decode / player error, PlayerViewModel.kt:1129, TvPlayerViewModel.kt:3110
  • preflight-unsupported and stall-watchdog fallback, PlayerViewModel.kt:983, TvPlayerViewModel.kt:1264
  • output route change, PlayerViewModel.kt:594, TvPlayerViewModel.kt:961

and the seek-recovery path (recoverActiveVideoSessionAfterSeek) should be considered too,
though its copy likely differs.

Surface the notice text we already generate

Most of the work here is already done: we build good human-readable explanations for exactly
these cases, we just don't display them on the success path.
PlayerViewModel.kt:945-955 and TvPlayerViewModel.kt:1224-1234 produce:

  • "This device cannot play Dolby Vision Profile N. Falling back to transcoded stream."
  • "Lossless audio not supported on this output. …"
  • "Audio channel count not supported. …"
  • "Playback did not start cleanly on this device. …"

These are logged (PlayerViewModel.kt:956) and sent to the server as the replan message, but
the only way a user ever sees one is if the replan itself fails (PlayerViewModel.kt:1227-1230).
They should be shown while the replan is in flight — that is where they are useful.

The other invisible notices worth wiring up the same way: "Audio or display output changed.
Revalidating playback." (PlayerViewModel.kt:596), "Applying audio selection." (:2132),
"Applying subtitle selection." (:2103), "Applying playback quality."
(TvPlayerViewModel.kt:2525).

Where a specific notice isn't available, a generic fallback is still far better than a black
screen — something along the lines of "Finding a compatible stream for this device… this can
take up to a minute."

Setting an expectation of duration matters here. Given the numbers above, copy that implies
an instant switch will read as broken.

Move the copy into resources

All of the strings listed above are hardcoded English literals in the ViewModels.
androidApp/src/androidMain/res/values/strings.xml (27 lines) and the TV equivalent (22 lines)
contain only generic entries like action_retry and error_generic — nothing playback-related.
This work should add proper strings.xml entries so the renegotiation copy is localizable,
rather than adding more literals to the ViewModels.

Note: attempt capping is mostly already handled

Worth recording since it comes up when reading this code: there is no absolute cap on
attempt_count, which grows unbounded. In practice the loop still terminates, from two
independent directions:

  • Client: if the server returns a plan whose key is already in attemptedPlanKeys, the
    session stops with replan_loop_detected (PlaybackSessionManager.kt:309-321), and the same
    guard covers the seek-recovery path at :734-742.
  • Server: the route ladder is finite and the server excludes every attempted key, so once
    the rungs are exhausted it returns terminal adaptation_exhausted — "All compatible playback
    recipes have already failed for this output route" (silo-server
    internal/playback/plan_v3.go:446).

So the only way to loop forever is a server that emits an unbounded supply of
distinct-but-broken plans, which isn't a real scenario. A hard cap (3-4 attempts) would be cheap
belt-and-braces, but it is not required for this issue and shouldn't block it. Mentioning it
mainly so the next person reading attempt_count doesn't think it's an open hole.

Out of scope

  • silo-apple: I know you're already working on bringing silo-apple to v3. When it happens, hope we can have the same "show loading state" while renegotiating playback.
  • Server-side changes to how the route ladder is walked.

Verification

  • Reproduce with a source that fails on the selected route (e.g. a Dolby Vision Profile 7 file
    on a device that can't take it, or an H.264 file with conflicting in-band PPS) and confirm the
    renegotiation overlay appears immediately on failure and clears on first frame.
  • Confirm the ordinary buffering spinner is unaffected during normal playback and normal
    rebuffering.
  • Confirm the overlay clears correctly on the terminal path too, so a failed replan shows the
    error screen rather than a stuck overlay.
  • Check both phone and TV players; the two ViewModels are structurally parallel and both need
    the change.

Activity

  1. added
    enhancement
    on Jul 21, 2026
  2. changed the title [-]Playback renegotiation is invisible to the user: show a loading state and explanatory copy during replan[/-] [+]Keep the user informed during playback renegotiation: show a loading state and explanatory copy during replan[/+] on Jul 21, 2026
  3. added
    triaged
    and removed
    triaged
    on Sep 20, 2026
  4. CoffeeKnyte commented on Oct 28, 2026

    @CoffeeKnyte
    Author

    Status on main (4d489a8): partly done. #696 added one centered spinner on phone and TV. It shows while the player is loading, buffering, or reconnecting, which covers a stall that leads to a replan and the buffering of the new stream.

    Still missing:

    • A loading state when the replan follows a fatal error. When a decoder or player error starts the replan, the player goes idle and isBuffering clears. Neither startProtocolV3Replan (PlayerViewModel.kt:2499, TvPlayerViewModel.kt:3149) nor its success path sets a loading flag, so the screen still freezes on the last frame while the server request runs.
    • Explanatory copy. Messages such as "Falling back to transcoded stream" (PlayerViewModel.kt:2191-2202) and "Revalidating playback" (:1420) are only logged and reported to the server. The user sees no text explaining the wait.
    • String resources. That text is hardcoded in the view models rather than in strings.xml.

    Narrowed scope: keep a dedicated replan flag set for the whole replan on phone and TV, show the reason or a general "finding a stream that plays" message while it runs, and move those strings into resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions