Repository navigation
fix(player): refresh direct-play credentials without reloading the player - #759
Conversation
…ayer Direct play opens with static headers, so every access-token rotation forces a full player reload at the current position after the next successful progress report. Server HLS with video already resolves the current credential for each request. Pass the request-authorization resolver to direct play with video (original_http and server_remux_progressive) as well as to server HLS with video. Audio-only media, HLS or progressive, still gets no resolver and keeps its existing reload-after-rotation and 401-reload recovery. AetherAuthenticationRecoveryPolicy.resolvesRequestCredentials holds the rule for both the load spec and the player view model. Not safe to merge on its own: the AetherEngine pin on main ignores the resolver for direct media, while a spec that carries one skips the app's reload recovery. This needs an engine pin that includes Silo-Server/AetherEngine#12 first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 14 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Evidence is currently descriptive only. Because this changes user-visible direct-play behavior, add before/after evidence for the same playback flow and data, naming the platform and build; include a short recording covering token rotation and the resulting playback behavior. A published Evidence link is acceptable. Do not merge this PR until AetherEngine#12 is merged and the Apple dependency pin is updated. |
…tials resolvesRequestCredentials listed the same four deliveries that PlaybackProtocolV3.PlanDelivery.supported already holds. Use the set so the rule follows the canonical list. No behavior change: both callers only see plans that already passed the supported-delivery check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104
left a comment
There was a problem hiding this comment.
Review of c92734f. Two findings are on the diff below. The first is the merge gate the description already names, with what a sandbox run showed.
Low, rare path, needs your call: scrub previews keep the opening headers. AetherScrubPreviewProvider.activate and begin build the FrameExtractor from spec.options.httpHeaders. Before this PR, the rotation reload re-ran activate(spec) with fresh headers. With that reload gone for direct play with video, nothing refreshes them, and AetherEngine#12 also leaves scrub thumbnails on static headers. The extractor only runs when engine.supportsCacheBackedStills is false, which for a remote software session means the engine's packet cache is unavailable (for example, the device is low on disk). The effect: scrub previews stop appearing once the opening token expires. Playback is not affected, and server HLS with video already has the same exposure. Options: resolve current headers when begin builds the extractor, or accept the gap and note it. I'm not changing this.
Checked and fine:
- Subtitle sidecars and fonts on direct play now use the strict subtitle resolver. Every sidecar and font URL the server mints passes
SubtitleScope, the same as server HLS today. - The resolver scope admits the direct-play URL the server mints (
/api/v2/stream/<session>); the sandbox runs playedoriginal_httpwith it attached. - Android already refreshes credentials on every direct-play request (
RefreshingHttpDataSource), so this change brings Apple closer to Android. No Android change is needed.
AI disclosure: written by Claude Code (claude-opus-5-5) running /silo review; the sandbox and simulator results above come from that run.
| httpHeaders: effectiveHeaders, | ||
| httpRequestAuthorization: isServerHLS && plan.effectiveRecipe.videoCodec != nil | ||
| ? requestAuthorization : nil, | ||
| httpRequestAuthorization: AetherAuthenticationRecoveryPolicy.resolvesRequestCredentials( |
There was a problem hiding this comment.
High, disclosed: merging before the engine pin bump breaks token recovery for direct play.
At the pinned engine (87f85740), only the native remote-HLS stand-in reads httpRequestAuthorization. The direct-play AVIOReader keeps the headers it opened with. Attaching a resolver here turns off both app recovery paths for original_http and server_remux_progressive with video, because PlayerViewModel gates them on httpRequestAuthorization == nil (lines 1862 and 1912). A range request sent after the opening token expires gets a 401, attemptProtocolV3AuthenticationReload returns false, and the failure goes to the failure_recovery replan, which excludes the direct-play route.
On a sandbox with 2-minute access tokens (iPhone simulator, same title and start point for both builds):
- PR base: the token refreshed at 17:26:39Z and the app reloaded the plan at that moment. The picture jumped back 2.4 s, froze for 2.6 s, and the engine downloaded the file again (67 range requests).
- This branch: the token refreshed at 17:39:33Z with no reload and no freeze. The engine had already cached the whole 1.5 GB file, so it sent nothing with the expired token. A file larger than the engine's packet cache, or a slower link, would reach the 401 path above.
Repair: keep this unmerged until AetherEngine#12 is rebased and merged, and put the pin bump in this PR rather than a separate one. #12 is 472 commits behind the current pin and conflicts with engine main, so the rebase should cover readers added since its base. I'm not changing this here; it waits on the engine.
The new comments at lines 74-77 and in PlayerViewModel (1849-1850) describe the behavior after #12. Once the pin moves they hold, except for scrub thumbnails, which #12 leaves on static headers (see the review body).
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
/silo review summaryReviewed head: b8b6f6c (c92734f plus one cleanup commit from this review). Fit: 9/10 · Readiness: 4/10 — not ready Not ready because merging before AetherEngine#12 and an engine pin bump would leave direct play with video without working credential recovery. That is the dependency the description already names. The rest of the change is sound. Findings
Verification
Validated featuresNo passed case on the 1.0 validation board reaches this code; the passed cases cover Calendar, person pages and server branding. User manualUnaffected. No setting, screen or default changes, and the docs don't describe player reloads on token refresh. Apple and AndroidAndroid already sends fresh credentials on every direct-play request, so it needs no matching change. This PR brings Apple closer to Android. FitThe change removes a stall from the core playback path at every token refresh. It reuses the per-request credential resolver server HLS already uses, adds no setting or API surface, and puts the fix in the engine's reader instead of reloading the player. Once #12 lands and the pin moves in this PR, re-check on a simulator or device with a file larger than the engine's cache, so a range request actually goes out after the old token expires. AI disclosure: written by Claude Code (claude-opus-5-5) running /silo review. |
Direct play stalled about an hour into a session: the engine kept sending the access token it opened with after the app refreshed it, so every range request got a 401 until the engine gave up and the player replanned. #759 gave direct play a per-request credential resolver and skipped the app's reload-after-rotation path, but AetherEngine asks that resolver only for HLS (the direct-play side, AetherEngine#12, never merged). AetherEngine 7.37.0 (upstream #792) lets a host replace a running session's request headers (updateRequestHeaders) and publishes the first refusal of a header set (sourceAuthorizationRefused). The controller now uses both for direct play with video: - after each successful progress report it asks the resolver for the current headers and pushes them when the token has rotated, ahead of the old token's expiry; - on a refusal it hands the refused set back to the resolver, which refreshes the token first, and pushes the answer while the engine's reader still retries; - answers apply in the order asked, so a slow earlier answer never replaces a later one. Server HLS keeps resolving per request and audio-only media keeps the reload-after-rotation path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
Related issue: N/A (split from #611)
Validation tasks: none
Direct play reloads the player every time the access token rotates. Server HLS with video gets a per-request credential resolver, so it picks up the new token on its next request. Direct play opens with static headers. After the next successful progress report, the app sees that the
Authorizationheader changed and reloads the whole player at the current position. Viewers see a stall and a rebuffer at each rotation.Approach
This PR passes the same resolver to direct play when the media has video (
original_httpandserver_remux_progressive), so the engine can ask for current headers on each range request. Server HLS with video behaves as before. Audio-only media, whether server HLS or progressive, still gets no resolver. It keeps its opening headers and the existing reload-after-rotation and 401-reload paths, as #346 intended. A newAetherAuthenticationRecoveryPolicy.resolvesRequestCredentials(delivery:hasVideo:)holds this rule.AetherLoadSpecandPlayerViewModelboth call it, so the load options and the resolver they build stay in agreement.Do not merge this alone. At main's AetherEngine pin (87f85740), the engine ignores
httpRequestAuthorizationfor direct media. Once a direct-play spec carries a resolver, the app skips its reload-after-rotation and 401-reload paths, because both requirehttpRequestAuthorization == nil. Merged on its own, this change would leave direct play using expired headers with no recovery.Dependencies
fix/direct-play-range-auth) has to be rebased onto engine main and merged first. That PR makes the direct-play reader resolve headers on every range request and retry a 401 once at the same byte.iosApp/project.yml,Package.resolved,THIRD_PARTY_NOTICES.mdandiosApp/Resources/OpenSourceLicenses/README.txt.Validation
AetherPlaybackBoundaryTestson an iOS 27 simulator (schemeSilo,-only-testing:SiloTests/AetherPlaybackBoundaryTests): 63 tests, 0 failures.AetherPlaybackBoundaryTestson a tvOS 27 simulator (schemeSiloTV,-only-testing:SiloTVTests/AetherPlaybackBoundaryTests): 64 tests, 0 failures.xcodebuild build -scheme SiloMac -destination platform=macOS CODE_SIGNING_ALLOWED=NO: build succeeded.testMediaWithVideoResolvesCredentialsButAudioOnlyKeepsReloadPathchecks the rule for all four deliveries, with and without video.testDirectPlayWithVideoResolvesCredentialsPerRequestbuilds a direct-playAetherLoadSpecfrom the v2 fixture and checks that the resolver is attached when the media has video and left off when it is audio-only. On main the direct-play spec with video gets no resolver, so the second test fails there.AetherPlaybackBoundaryTestsat b8b6f6c on an iOS 27.0 simulator: 63 tests, 0 failures.Risks
Evidence
Evidence: https://evidence.siloserver.org/r/silo-apple/pr-759/
During direct play, an access-token refresh no longer reloads the player. On the PR base, the refresh reloads the plan: the picture jumps back 2.4 s and freezes for 2.6 s. On this branch, playback continues through the refresh. The page has before and after recordings from the same simulator, title and start point, with app and server log excerpts.
Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Fix direct-play credential refresh to cover all video Protocol V3 delivery modes
Adds
AetherAuthenticationRecoveryPolicy.resolvesRequestCredentialsin AetherLoadSpec.swift as a shared predicate. It returns true for media with video in any of the four Protocol V3 delivery modes (original HTTP, progressive remux, remux HLS, transcode HLS).AetherLoadSpecinitializer and the Protocol V3 request-authorization builder in PlayerViewModel.swift with this shared policy.Macroscope summarized c92734f.