Repository navigation
Description
Problem
When the Silo server restarts briefly (e.g. a deploy / docker compose down/up, ≤ 60s) while someone is watching server-transcoded video, the Android app shows a fatal playback error instead of riding through the blip. The player has a healthy buffer (up to ~120s) and could keep playing while the server comes back, but the first network request that fails during the outage kills the session and playback stops — the viewer sees an error, not a brief pause.
This matters now because the server side has been made restart-resilient: it persists a tiny "recipe card" per transcode session and reconstructs the session on the next request after a restart, so the client's next segment/manifest request succeeds again once the server is back. That work is invisible unless the client retries instead of erroring.
Server-side change (context / tracking): Silo-Server/silo-server#174
(See the spec's "Operating model" and Preconditions — P3: client retry/backoff and Risk #4: client doesn't retry — which call out silo-android/silo-apple as the coordinated follow-up.)
Scope note: the server currently delivers this for the HLS transcode path; remux and the Jellyfin-compat path are in-target but not yet implemented server-side, so this issue is about the transcode path.
Solution
The client must treat a transient request failure during an outage as retryable, not fatal, and keep draining its buffer until the server returns. Audit of the current code (read-only) found the media path has no retry beyond a single 401 auth refresh:
Stack: AndroidX Media3 / ExoPlayer + a dedicated OkHttp client for media (OkHttpDataSource.Factory → AuthenticatedDataSourceFactory); session/control over Ktor REST. No WebSocket.
Findings (file:line):
- No segment/manifest retry. No custom
LoadErrorHandlingPolicyis set (ContinuumPlayerFactory.kt:96-116); the stockDefaultLoadErrorHandlingPolicygives ~3 retries over a few seconds then a fatalPlaybackException, ignoresRetry-After, and can't span a 60s outage. The media OkHttp interceptor only retries401(MediaAuthInterceptor.kt:55-56); no retry interceptor inPlayerOkHttpClient.kt:17-27. - Fatal-vs-transient classification is the crux and it fails.
onPlayerErroris wired to a no-op (PlaybackPreflightListener.kt:23,38-40; constructed withoutonErrorinPlayerScreen.kt:233-237andTvPlayerScreen.kt:226-228), so a single failed media request goes terminal and the ViewModel never even learns of it. - Buffer is fine but wasted.
DefaultLoadControlis 60s/120s withprioritizeTimeOverSizeThresholds(ContinuumPlayerFactory.kt:103-111) — the player could coast through the outage, but the missing retry tears the session down first. - Existing REST outage loop is on the wrong channel.
PlaybackSessionLifecycle.kt:236-282(beginOutageRecovery) has good exp-backoff health probing, but it fires only onApiResult.NetworkErrorfrom the progress-report call (:194-197); a503/404returnsApiResult.Errorand is just logged (:198-201), and it never feeds back into ExoPlayer.
Proposed changes
- Add a custom
LoadErrorHandlingPolicy(highest priority) wired viaDefaultMediaSourceFactory(...).setLoadErrorHandlingPolicy(...)atContinuumPlayerFactory.kt:96. ForInvalidResponseCodeExceptionwith404/500/502/503/504and for connection errors (SocketTimeoutException/ConnectException/SocketException), return a positive backoff (notC.TIME_UNSET) and a large retry count while elapsed outage time is within a ~90s window; honorRetry-Afterfrom the response headers. - Stop treating media
onPlayerErroras a no-op. Pass a realonErrorinPlayerScreen.kt:233/TvPlayerScreen.kt:226that, for transient I/O codes (ERROR_CODE_IO_BAD_HTTP_STATUS,ERROR_CODE_IO_NETWORK_CONNECTION_FAILED/TIMEOUT) within the outage window, callscontroller.prepare()to re-request the (now-reconstructed) manifest/segments instead of surfacing a fatal error; only show a fatal error after the recovery deadline or for non-I/O codes. - Broaden the REST outage trigger in
PlaybackSessionLifecycle.kt:192-203to also start recovery onApiResult.Errorwith502/503/504(and honorRetry-Afterfor the first probe delay). - (Optional, defense-in-depth) a small bounded retry interceptor in
PlayerOkHttpClient.ktfor idempotent GETs on502/503/504honoringRetry-After.
Acceptance criteria
- With a ~120s buffer, restarting the server (≤60s) mid-transcode playback results in seamless or at most a brief stall, never a fatal error, with playback resuming automatically.
- Segment/manifest GETs retry on connection failure,
5xx(esp.503), and404, honoringRetry-After. - Verified by: kill/restart the server (or block the port) for ~45–60s during transcoded playback and confirm recovery.
AI-use disclosure
Drafted with AI assistance (read-only audit of the client + server spec, synthesis).
Activity
CoffeeKnyte commentedon Oct 28, 2026
Fixed on
main. Media loads now go throughSiloMediaLoadErrorHandlingPolicy(android-shared/.../player/MediaLoadRetryPolicy.kt), set on both the default and HLS source factories inSiloPlayerFactory.kt:Retry-Afteris honored.This landed in #36 and was refined in #115, so a brief server restart during transcoded playback should ride through on the buffer. Each HLS segment is its own load and gets a fresh retry window. The remaining restart problem, a second restart in one direct-play session, is tracked in #586.