You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(player): renew direct play retries after sustained progress - #993
Android could recover from a dropped direct-play stream, play another 11 minutes, then give up immediately on the next interruption. The 90-second retry window still ran from the first failure because Media3 used the same load task for the whole movie.
Related issues: #586 and #981. The original Freebox report lacks the exception that triggered the player restart.
Validation tasks: none
Other clients: Apple N/A (AVPlayer); Roku N/A (Roku video player); Web N/A (browser player). The defect is in Android's Media3 retry policy.
Approach
Give a later interruption its own 90-second retry window when one HTTP request delivered at least 512 KiB and successful reads on that request span at least 20 seconds. Time spent waiting for a read that times out does not count. When a previous request delivered that much, the new end offset must differ by at least 512 KiB. Each request counts its own bytes, including when Media3 seeks within a load task. This lets a resumed stream recover again while keeping repeated short reads and cuts at the same offset on the original budget.
Playback diagnostics now record the Media3 error code when available and the exception class chain. The report omits exception messages, which can contain stream addresses or credentials.
Validation
All 7,245 debug unit tests passed.
Shared, phone, and TV debug lint and both release lint checks passed.
Both supply-chain checks passed. The phone and TV debug APKs built successfully.
On the parent commit, the regression test simulated 11 minutes and 1 GB of successful transfer between interruptions. The second failure returned TIME_UNSET. On ee3f3f535, the same failure gets a one-second retry delay.
In a separate Media3 integration test, a local HTTP server cut the response twice, halfway through the file and again at three quarters. With 11 minutes between failures on the policy clock, the player resumed from both byte offsets, sent the original ETag in both If-Range headers, and reached the end. Device and proxy behavior on the reporter's Freebox still needs confirmation.
Risks
A second interruption within 20 seconds shares the first window. On a slow stream, a later interruption can also share the window if the attempt delivered less than 512 KiB.
Checklist
I read and can explain the complete diff.
This pull request addresses one concern.
The Evidence section gives the before and after retry decisions and observed HTTP behavior.
AI Disclosure
Harness: T3 Code with Codex and Claude Agent.
Tool(s): Codex, Claude Agent, Git, GitHub CLI, Gradle, Robolectric, and MockWebServer.
Model(s): gpt-6.2-astra and claude-fable-5-2.
Involvement: Codex wrote the implementation and tests. Fable reviewed the diagnosis before implementation.
Adversarial review: Fable checked whether the proxy configuration and WebSocket reconnect explained the two reports. It identified an unconfirmed exception-classification gap on the Freebox. The patch adds diagnostics for that case. Codex reproduced Kody’s finding that a socket timeout could renew the window and CodeRabbit’s finding that an extractor seek could distort the end offset. Both regression tests pass with the revised policy.
Note
Renew direct play retry window only after sustained read progress
Reworks SiloMediaLoadErrorHandlingPolicy retry handling in MediaLoadRetryPolicy.kt. Retries for resumable progressive direct play now use per-load-task retry windows instead of a first-error timestamp.
A new data-source factory wrapper records per-open bytes read for progressive direct-play requests. The window renews only when a substantial read (≥512 KiB) is sustained for 20 seconds and ends far enough from the previous substantial-read offset. Short bursts, rereads of the same region, and non-progressive loads do not renew the window.
Diagnostics playback and load-error logs now include the Media3 error code and cause class names, without exception messages, via the new DiagnosticsPlaybackLogger.failureDetails formatter.
Adds unit tests in DirectPlayRetryWindowTest.kt covering window renewal and exhaustion, and extends the integration test to exercise two progressive-stream interruptions.
Behavioral Change: retry attempt counts for resumable direct play are now bounded by the window's failure count, and retry logs report the failed open's resume offset and window-based attempt count. HLS media sources do not use the read-tracking wrapper.
The pull request changes progressive direct-play retry tracking and playback error logging. The retry policy tracks failure windows per load task. The diagnostics logger records sanitized exception details, and tests cover retry behavior and logged error details.
Changes: Progressive direct-play retry windows
Layer / File(s)
Summary
Retry-window policy and unit tests android-shared/src/androidMain/.../MediaLoadRetryPolicy.kt, android-shared/src/androidUnitTest/.../DirectPlayRetryWindowTest.kt
The policy tracks retry windows per load task and starts a fresh window after qualifying read progress. Unit tests cover window renewal, repeated reads, frequent cuts, small progress, and non-progressive loads.
The integration test injects a clock and checks two interrupted responses, resumed byte ranges, and If-Range values.
Playback error diagnostics
Layer / File(s)
Summary
Exception details in playback logs android-shared/src/androidMain/.../DiagnosticsInstrumentation.kt, android-shared/src/androidMain/.../PlaybackAnalyticsListener.kt, android-shared/src/androidUnitTest/.../DiagnosticsInstrumentationTest.kt
The analytics listener passes caught exceptions to the diagnostics logger. The logger records error codes and cause class names without exception messages. The test checks the logged details and confirms that private exception-message text is excluded.
Silo-Server/silo-android#981: The PR changes progressive direct-play retry windows and adds exception-class diagnostics, which relate to the reported proxy-connection load error. The provided context does not confirm that this PR fixes the proxy-reload case.
Possibly related PRs
Silo-Server/silo-android#635: Both PRs change playback error diagnostics by recording Media3 error codes and exception class information.
Suggested labels:bug
Suggested reviewers:rxwatcher
Merge Risk: Moderate · up to 24f4f
Direct-play recovery after a later interruption can still fail permanently on streams where the player seeks between errors. The retry-window renewal then uses a miscalculated read endpoint and refuses to renew. Fix the endpoint tracking before merging; the logging changes look safe.
Security architecture risk: Minimal · up to 24f4f
The inspected changes preserve task isolation and require sustained read progress before renewing retries. Newly added diagnostic details exclude exception messages. No introduced or worsened risk materially affecting security, failure containment, rollback or ownership was established.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — A server controlling the selected original-file stream can influence read progress and transport failures, thereby prolonging progress-qualified recovery for that playback. Renewal eligibility is restricted to the exact URI recorded for ORIGINAL_HTTP delivery. The inspected change extends recovery duration, not credential authority or the set of eligible stream URIs.
Trust Boundaries and Controls
observed — Renewing the window does not bypass the existing retryability decision: EntityChangedException is rejected, and HTTP response codes must remain in the existing retryable set, which excludes 401, 403 and 416. New diagnostic strings pass through the existing SiloLog dispatch, whose structured-output renderer sanitizes messages and limits them to 2,048 bytes; platform logging occurs before that renderer.
Resilience and Maintainability Implications
observed — Inspected regression tests assert renewed recovery after sustained progress and exhaustion after frequent cuts, small reads, same-offset rereads and non-progressive loads. Integration-test assertions cover resumed byte ranges, If-Range identity headers, and termination on changed entities or HTTP 416. These provide source-level counterevidence to weakened recovery containment, not independently executed validation.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: direct play retry windows are renewed after sustained playback progress. The raw summary confirms this change to SiloMediaLoadErrorHandlingPolicy, which adds a new ret…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description is specific and related to the changeset. It explains the problem (Media3 90-second retry window continuing from the first failure during direct-play recovery), the approach (per-reque…
Full details: Title check
Explanation
The title names the main change: direct play retry windows are renewed after sustained playback progress. The raw summary confirms this change to SiloMediaLoadErrorHandlingPolicy, which adds a new retry window when at least 512 KiB was read and 20 seconds elapsed. The title follows the conventional commit format and is specific enough to scan history.
Full details: Description check
Explanation
The description is specific and related to the changeset. It explains the problem (Media3 90-second retry window continuing from the first failure during direct-play recovery), the approach (per-request retry windows gated by at least 512 KiB read over at least 20 seconds, with an end-offset difference check), added diagnostics that record the Media3 error code and exception class chain while omitting messages, validation results, evidence of the integration test, and risks. It matches the files in the summary, including MediaLoadRetryPolicy, DiagnosticsInstrumentation, and the retry window tests.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
The visible effect is progressive direct-play recovery after a later stream interruption (android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/MediaLoadRetryPolicy.kt). The policy is used by both apps, so evidence is missing for Android phone, tablet, foldable folded and open, and Android TV. The described tests show how it was checked, but the Evidence section has no recording or evidence link showing the playback behavior. Suggested fix: add a recording demonstrating recovery on each affected device, with the device and build or commit identified for each capture.
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.
I closed #992, which fixed the same window, in favour of this one. One piece from it that this PR doesn't cover might be worth adding.
The Freebox report in #981 has no progressive direct-play retry line at all, so its failure was classified as not retryable rather than out of window. One likely cause, unconfirmed: on Android a peer that resets a TLS connection mid-read can surface as a bare javax.net.ssl.SSLException ("Read error … Connection reset by peer") with no SocketException cause. isRetryableMediaLoadFailure never retries that. #992 treated SSLException (except SSLHandshakeException) as a resumable transport failure after byte progress, next to StreamResetException and EOFException:
The sidecar policy shares that check, so a TLS cut on a subtitle load would then count against its extraction budget like a socket reset does. Your new exception-class logging would confirm or rule this out on the next report.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bugSomething isn't workingimpact: playbackCan't play, stalls, or wrong mediapriority: P1Core-path bug; painful workaround — next after P0size/L200–499 added + deleted lines (all files); change volume, not priority.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Android could recover from a dropped direct-play stream, play another 11 minutes, then give up immediately on the next interruption. The 90-second retry window still ran from the first failure because Media3 used the same load task for the whole movie.
Related issues: #586 and #981. The original Freebox report lacks the exception that triggered the player restart.
Validation tasks: none
Other clients: Apple N/A (AVPlayer); Roku N/A (Roku video player); Web N/A (browser player). The defect is in Android's Media3 retry policy.
Approach
Give a later interruption its own 90-second retry window when one HTTP request delivered at least 512 KiB and successful reads on that request span at least 20 seconds. Time spent waiting for a read that times out does not count. When a previous request delivered that much, the new end offset must differ by at least 512 KiB. Each request counts its own bytes, including when Media3 seeks within a load task. This lets a resumed stream recover again while keeping repeated short reads and cuts at the same offset on the original budget.
Playback diagnostics now record the Media3 error code when available and the exception class chain. The report omits exception messages, which can contain stream addresses or credentials.
Validation
Evidence
Evidence: https://evidence.siloserver.org/r/silo-android/pr-993/
On the parent commit, the regression test simulated 11 minutes and 1 GB of successful transfer between interruptions. The second failure returned
TIME_UNSET. Onee3f3f535, the same failure gets a one-second retry delay.In a separate Media3 integration test, a local HTTP server cut the response twice, halfway through the file and again at three quarters. With 11 minutes between failures on the policy clock, the player resumed from both byte offsets, sent the original ETag in both
If-Rangeheaders, and reached the end. Device and proxy behavior on the reporter's Freebox still needs confirmation.Risks
A second interruption within 20 seconds shares the first window. On a slow stream, a later interruption can also share the window if the attempt delivered less than 512 KiB.
Checklist
AI Disclosure
gpt-6.2-astraandclaude-fable-5-2.Note
Renew direct play retry window only after sustained read progress
SiloMediaLoadErrorHandlingPolicyretry handling in MediaLoadRetryPolicy.kt. Retries for resumable progressive direct play now use per-load-task retry windows instead of a first-error timestamp.DiagnosticsPlaybackLogger.failureDetailsformatter.Macroscope summarized ee3f3f5.