Repository navigation
fix: harden HDR and TrueHD playback recovery - #81
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (17)
📝 WalkthroughWalkthroughThe changes harden loopback playback across remux duration handling, restart-time audio buffering, delayed VOD segment responses, AVPlayer recovery, demux timeouts, origin fetches, teardown, and credential-bound server replacement. New tests cover the added policies and recovery paths. ChangesPlayback hardening
Server session profile replacement
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant AVPlayer
participant LoopbackSegmentServer
participant LoopbackSegmentStore
participant AVPlayerBackend
AVPlayer->>LoopbackSegmentServer: request missing VOD segment
LoopbackSegmentServer-->>AVPlayer: send early response headers
LoopbackSegmentStore-->>LoopbackSegmentServer: provide progressive segment bytes
AVPlayer->>AVPlayerBackend: report seek timeout or item-death evidence
AVPlayerBackend->>AVPlayerBackend: gate completion and record recovery evidence
AVPlayerBackend-->>AVPlayer: reload item or escalate after bounded attempts
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
ReviewOverviewSix coordinated playback-hardening fixes closing #75–#80 from the AetherEngine gap audit: (1) fMP4 video sample durations derived from forward DTS via a one-packet look-behind in the loopback writer, (2) bounded retention/replay of selected-audio preroll across VOD restart keyframe gates, (3) AVPlayer seek deadlines + item-death (-12889/-15628) reload recovery, (4) early VOD response headers after 2 s (the #76 design choice: early headers over 503), (5) AVAudioSession activation moved off the main thread behind a generation-tracked coordinator, and (6) demux watchdog pause-awareness plus scrub-state cleanup. The pattern of extracting pure policy types ( Confirmed issues1. High — the demux watchdog exemption disables wedge detection during startup and seeks, not just pause (
This partially reopens the wedge-recovery-chain gap — the one high-severity finding in the audit this PR is remediating. PlayerCore already has the precise signal: 2. High — audio-session coordinator loses cross-backend ordering ( The old code ran 3. Medium — a superseded initial seek permanently latches There is a single seek-deadline generation shared by two distinct state machines (initial and interactive), and Worth noting (lower severity)
Correctness verifiedI specifically checked and found these sound: the pre-gate audio replay keeps timestamps on the source axis (packets cloned before Tests & validationPolicy-level coverage is well-targeted and matches the repo's testing guidance (critical shared logic only). Two notes: the early-headers test costs ~3 s of real wall time (sleeps past the 2 s delay over a real socket) — fine as a one-off; and none of the tests exercise the three findings above, all of which live in the glue rather than the extracted policies — which is the usual blind spot of this extraction pattern. The PR's honest documentation of the simulator limitation (loopback route rejected with -11868/-17223, rendering verified only on the fallback engine) is appreciated; findings 1 and 2 are exactly the kind of thing the pending Apple TV hardware pass won't reliably catch either, since both are timing races. Verdict: solid, well-structured work with genuinely good test hygiene — but findings 1 and 2 should be fixed before merge; both are small changes, and both undermine the recovery guarantees this PR exists to strengthen. 🤖 Generated with Claude Code |
- Scope the demux I/O watchdog exemption to explicit user pause (userPaused) instead of playbackClock.rate == 0. The clock also reads rate 0 during startup opens and seek restarts, and the interrupt callback is the only escape from a wedged av_read_frame there; the broader predicate silently disabled wedge detection in exactly those windows. - Share one serial work queue across AVPlayerAudioSessionCoordinator instances. AVAudioSession is a process-wide singleton; per-instance queues let an old backend's teardown deactivation land after the next backend's activation and kill the new playback's audio route. - Release isInitialSeekInFlight when a newer seek supersedes an in-flight initial seek's deadline generation. The superseded completion is ignored and its deadline work item is cancelled, so nothing else cleared the flag and attemptInitialPlaybackStart stayed gated forever. - Trigger pre-gate audio replay from the pending-packet drain path too, mirroring the main loop. - Log when an early-committed VOD response is aborted on a terminal miss so retry loops are diagnosable. Co-Authored-By: Claude Fable 5 <[email protected]>
…e authorization Companion device authorization can install a different user's credentials for an already-saved server URL. persistServer now upserts the registry entry without inheriting the existing profileId (new addOrUpdate(preservingProfile:) seam) and clears the TokenStore profile selection at the same boundary, so the new account starts without the old account's profile. Ordinary metadata upserts keep preserving the profile, covered by a new ServerSessionPersistenceTests case. Co-Authored-By: Claude Fable 5 <[email protected]>
Summary
Root causes
Validation
git diff --check origin/main...HEADis clean.Simulator limitation
Finding Dory does not prove end-to-end SiloPlayer playback in the Simulator:
siloPlayerLoopbackwas selected and began source/cache work.-11868/ CoreMedia-17223.playerCoreDirect(Compatibility Player).The local tests cover deterministic muxing, recovery-policy, timeout, seek, and loopback-server behavior. Dolby Vision, TrueHD/Atmos output, sustained high-bitrate A/V sync, and real SiloPlayer recovery still require validation on physical Apple TV hardware.
Closes #75
Closes #76
Closes #77
Closes #78
Closes #79
Closes #80
Summary by CodeRabbit