Skip to content

fix(player): renew direct play retries after sustained progress - #993

Merged
Quick104 merged 3 commits into
mainfrom
fix/investigate-reverse-proxy-reports
Nov 18, 2026
Merged

Quick104 merged 3 commits into
mainfrom
fix/investigate-reverse-proxy-reports

Conversation

@Quick104

@Quick104 Quick104 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

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

  • 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.

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. 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.

Macroscope summarized ee3f3f5.

@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 18, 2026
@silo-kody

silo-kody Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T16:56:09.960566Z ee3f3f5 New commits
🔒 Security Review ✅ Completed 2026-11-18T16:58:07.903495Z ee3f3f5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

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.
Repeated-interruption resume integration
android-shared/src/androidUnitTest/.../ProgressiveDirectPlayResumeIntegrationTest.kt
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.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Possibly related issues

  • 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

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed 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

@silo-triage silo-triage Bot added bug Something isn't working impact: playback Can't play, stalls, or wrong media priority: P1 Core-path bug; painful workaround — next after P0 labels Nov 18, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 18, 2026

Copy link
Copy Markdown

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.

Posted via Macroscope — Visible change evidence

@silo-kody

silo-kody Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f683775e-1808-4ed3-bd70-b09aef6bd90b
Commits

Reviewing files that changed from the base of the PR and between db87f83 and 24f4f9a.

Files selected for processing: 6

  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsInstrumentation.kt
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/MediaLoadRetryPolicy.kt
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/PlaybackAnalyticsListener.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsInstrumentationTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/DirectPlayRetryWindowTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/ProgressiveDirectPlayResumeIntegrationTest.kt

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.

@silo-kody

silo-kody Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit bb59172 into main Nov 18, 2026
10 checks passed
@Quick104
Quick104 deleted the fix/investigate-reverse-proxy-reports branch November 18, 2026 17:19
@Rhainland

Copy link
Copy Markdown
Contributor

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:

(this is SSLException && this !is SSLHandshakeException) ||

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.

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

Labels

bug Something isn't working impact: playback Can't play, stalls, or wrong media priority: P1 Core-path bug; painful workaround — next after P0 size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants