Skip to content

fix(player): poll the phone's native subtitle mount deadline - #731

Closed
Quick104 wants to merge 2 commits into
mainfrom
fix/phone-subtitle-mount-deadline
Closed

Quick104 wants to merge 2 commits into
mainfrom
fix/phone-subtitle-mount-deadline

Conversation

@Quick104

@Quick104 Quick104 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: Silo-Server/silo-server#1406
Validation tasks: changes #323 C3, C4

When the phone app switches to a subtitle it plays from the stream itself (a native embedded track or an HLS rendition), it gave the mount a fixed 5 seconds. A replanned stream often hasn't published its text tracks by then, so the app reported a failure that hadn't happened and replanned with subtitle_embedded_failed. The server then extracted the track as a whole-file sidecar, which on large files on slow storage takes minutes and adds the read load described in Silo-Server/silo-server#1406.

The phone now polls the deadline the way Android TV already does.

Approach

Validation

  • ./gradlew testDebugUnitTest: pass, 6,624 tests, 0 failures. New tests cover a stream that has not published text tracks yet and the 30 s cap.
  • ./gradlew :android-shared:lintDebug :androidApp:lintDebug :androidTvApp:lintDebug: pass, no new findings.
  • :androidApp:assembleDebug and :androidTvApp:assembleDebug: pass.
  • Not run locally: the supply-chain scripts (no Ruby on the build machine; this change touches no build, dependency or workflow file), release bundles and release lint. CI runs them.
  • No device or emulator run.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-android/pr-731/

Risks

A text track that never mounts now takes up to 30 s, instead of 5 s, before the app falls back to the sidecar.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated. Nobody has verified it by hand yet, and no device or emulator run happened.
  • Adversarial review: a separate Claude Code agent (claude-opus-5-5) reviewed the whole original branch, which included this change, read-only. It reported nothing to fix in this change.

🤖 Generated with Claude Code

Note

Fix player subtitle mount timeout to poll for native text tracks

The local subtitle mount timeout in MobileSubtitleTransactionAdapter previously failed after five seconds even when the player had not yet published its text tracks. It now polls a track-presence callback every five seconds, and the five-second failure window only starts once tracks are present. Absent tracks fail at a 30-second cap.

  • PlayerScreen reports whether the current Media3 track snapshot has a text track to PlayerViewModel at track-change handling and mounted-subtitle effect execution.
  • PlayerViewModel.onMountedTextTracksChanged stores the current mount's track-presence snapshot and ignores stale mounts; hasMountableTextTracks backs the adapter's query.
  • Adds tests in MobileSubtitleTransactionAdapterTest.kt covering delayed, immediate, and never-present track cases.
  • Risk: the timeout cap moves from 5 seconds to 30 seconds when no tracks appear; check scheduleLocalMountTimeout and the 30-second constant in MobileSubtitleTransactionAdapter.kt.

Macroscope summarized ed3c730.

The phone failed a native or rendition subtitle mount after a fixed 5 s,
even when the replanned stream had not published its text tracks yet. Each
false failure replanned with subtitle_embedded_failed and cost a whole-file
sidecar extraction on the server.

Poll the deadline the way TV does: check every 5 s, count only once the
current mount exposes any text track, and give up after 30 s regardless.
PlayerScreen reports text-track presence for the current mount from
onTracksChanged and the selection effect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Oct 30, 2026
@silo-kody

silo-kody Bot commented Oct 30, 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 Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T17:10:56.013799Z ed3c730 New commits
🔒 Security Review ✅ Completed 2026-10-31T17:11:31.223853Z ed3c730 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 Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 98 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

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: 5feb4217-d5ba-4bb7-aa03-8606729323db
Commits

Reviewing files that changed from the base of the PR and between c7a3caf and ed3c730.

Files selected for processing: 2
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/MobileSubtitleTransactionAdapter.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/MobileSubtitleTransactionAdapterTest.kt

No actionable comments were generated in the recent review.

Recent 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: 374d998e-89bc-4835-a207-104790cefa69
Commits

Reviewing files that changed from the base of the PR and between b29de77 and c7a3caf.

Files selected for processing: 4
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/MobileSubtitleTransactionAdapter.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerViewModel.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/MobileSubtitleTransactionAdapterTest.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.

Walkthrough

The player now tracks text-track availability for each subtitle mount. Local subtitle mount timeouts wait in five-second intervals while tracks are unavailable, with a 30-second cap. Tests cover delayed track publication, mounted selection, and timeout failure.

Changes: Subtitle Mount Timeout

Layer / File(s) Summary
Track availability reporting
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/MobileSubtitleTransactionAdapter.kt, androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerViewModel.kt, androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerScreen.kt
The adapter accepts a track-availability callback. The view model stores text-track presence for the current subtitle mount, and the screen reports track presence when tracks change and when subtitle selection runs.
Track-aware mount timeout
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/MobileSubtitleTransactionAdapter.kt, androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/MobileSubtitleTransactionAdapterTest.kt
The adapter checks track availability every five seconds and proceeds with mount failure when tracks appear or the 30-second maximum wait is reached. Tests cover delayed track publication, successful mounting, and timeout failure.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant PlayerScreen
  participant PlayerViewModel
  participant MobileSubtitleTransactionAdapter
  PlayerScreen->>PlayerViewModel: Report text-track presence for current mount
  PlayerViewModel->>MobileSubtitleTransactionAdapter: Provide mount-aware track availability
  loop Every 5 seconds while tracks are unavailable, up to 30 seconds
    MobileSubtitleTransactionAdapter->>PlayerViewModel: Check mountable tracks
  end
  MobileSubtitleTransactionAdapter->>MobileSubtitleTransactionAdapter: Proceed with mount timeout and report failure if unmounted
Loading

Suggested reviewers: rxwatcher, rhainland

Merge Risk: Moderate · previous review c7a3c

Native subtitles can still fall back to sidecar extraction before a newly published track has had time to mount. Give the track its mount deadline before merging.

Security architecture risk: Minimal · up to c7a3c

The change adjusts when the phone gives up on mounting subtitles without adding access, privileges, or server operations. Existing mount-ownership checks and timeout cancellation remain in place. No material security risk was found to be introduced or worsened.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Stream-controlled track availability can influence how long a pending subtitle mount waits. The downstream outcome remains the existing native or HLS subtitle-failure replan; the PR does not add a new server operation or increase the authority carried by that callback. Server-side extraction behavior was not independently inspected.

Trust Boundaries and Controls

  • inferred — The producer reads live currentTracks after validating the applied mount rather than carrying an event-specific revision. Dependency-level callback ordering remains unverified. Even if stale track presence were accepted, the changed timeout cannot expire before its first five-second wait—the previous unconditional deadline—so this conditional scenario does not establish increased fallback exposure.

Resilience and Maintainability Implications

  • observed — Failure is generation-owned and becomes a no-op for a superseded selection or restore. Starting another local mount invalidates the prior owner; successful selection cancels or invalidates its timeout. Failure invalidates ownership before publishing state and invoking fallback, containing stale timeout effects.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: polling the phone's native subtitle mount deadline.
Description check Passed The description directly explains the subtitle mount timeout problem, the polling approach, affected platform, validation, and stated risk.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 4 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@macroscopeapp

macroscopeapp Bot commented Oct 30, 2026

Copy link
Copy Markdown

The phone app can now wait up to 30 seconds for a native subtitle mount before reporting failure and falling back to a sidecar (MobileSubtitleTransactionAdapter.kt), changing playback timing. Evidence is missing for Android phone, tablet, and foldable (folded and open); please add before/after player-screen captures and a short recording demonstrating the timing on each, labeled with device and build/commit. This androidApp/-only change does not reach Android TV. “Evidence: being published” is not a published evidence link or capture.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@silo-triage silo-triage Bot added bug Something isn't working impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish labels Oct 30, 2026
Comment on lines +1137 to 1144
delay(LOCAL_MOUNT_TIMEOUT_MS)
waited += LOCAL_MOUNT_TIMEOUT_MS
// Only count against the mount once there is something to
// mount; the onTracksChanged callback may not arrive inside the
// window at all, so ask rather than wait to be told.
if (hasMountableTracks() || waited >= MAX_LOCAL_MOUNT_WAIT_MS) break
}
failLocalMount(generation)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug medium

Premature failLocalMount invocation after the first positive hasMountableTracks() poll can trigger native/HLS sidecar recovery before asynchronous selection confirms mounting, especially when tracks appear just before a five-second polling boundary. Start the mount timeout when tracks first become available while preserving the absolute maximum wait enforced by waited >= MAX_LOCAL_MOUNT_WAIT_MS.

Prompt for LLM

File androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/MobileSubtitleTransactionAdapter.kt:

Line 1137 to 1144:

Premature failLocalMount invocation after the first positive hasMountableTracks() poll can trigger native/HLS sidecar recovery before asynchronous selection confirms mounting, especially when tracks appear just before a five-second polling boundary. Start the mount timeout when tracks first become available while preserving the absolute maximum wait enforced by waited >= MAX_LOCAL_MOUNT_WAIT_MS.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

…appear

The phone checks its native and rendition mount deadline every 5 s and
counts it only once the mount has text tracks. It failed at the first
check that found tracks, however recently they had appeared: tracks
published just before a check left the selection a fraction of a second
to confirm, and the false failure replanned for a whole-file sidecar.

The window now starts at the first check that finds tracks, or at once
when the mount already has them, and the 30 s cap still applies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 31, 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

Copy link
Copy Markdown
Contributor Author

Superseded by #770, which combines this change with the rest of the stack for review.

@Quick104 Quick104 closed this Oct 31, 2026
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: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant