Repository navigation
fix: bound stalled seeks and recover sparse cache holes - #129
superuser404notfound merged 2 commits into
Conversation
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 59cd4472-c79d-4e7c-92ff-98a00996ca3c
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 59cd4472-c79d-4e7c-92ff-98a00996ca3c
superuser404notfound
left a comment
There was a problem hiding this comment.
Thanks for another carefully built PR. I went through the timing-sensitive paths in detail, since this touches the #37/#65/#93/#122 recovery machinery. Verdict: the logic holds up everywhere I probed.
What I verified:
- The normal landing still retires the pending recovery target at finalize, and the rendered-time sink only takes ownership after
pendingRecoverySeekDeadlineExpired. That split is cleaner than the old behavior, where a near-target rendered publication could retire the target while the seek was still in flight. - The MainActor ordering race between the seek completion and the resumed deadline continuation is handled in both orders: if the completion publishes
renderedTimefirst (the sink still seesdeadlineExpired == false), the catch-up branch settles it; otherwise the later publication settles through the sink. The generation guard inNativeAVPlayerHost.seekkeeps a superseded seek's completion from settinglatestSeekRenderedTimePublishedfor the wrong generation. - #122 stays fixed: a paused scrub lands with
transportIntentIsPlaying == false, soshouldReassertPlayDuringRecoverycan never fire andseekRecoveredStatereturns.paused. Your reconcile actually closes a small pre-existing hole too: a starved deadline landing withtcs == .pausedand playing intent used to latch.paused(the tcs-sink reassert keys onengineStateIsPlaying, which was false by then); now the bounded window reasserts it. - #115/#93 recovery aim preserved:
recoveryAnchorPositionstill lets a pending backward target win, and the producer re-anchor stays authoritative over stale scrub targets. - The provider-side change matches the #93-residual backstop semantics exactly (same coverage predicate, now shared via
activeProducerCovers), and skipping the wait for an unreachable interior hole is strictly better: the old 2 s wait could never be filled by a producer marching from above the hole. - Local verification on a trial merge with current main (the PR is based on 5.3.1): full suite 634/634 green,
-strict-concurrency=completebuild clean, tvOS Simulator build clean.
Two behavior notes, neither blocking:
reconcileNativeSeekTransportreads livetimeControlStatusinstead of the durable intent, which is what makes external AVKit/MediaRemote commands during a seek win. The trade-off is that a momentary post-landing.pausedblip (with the recovery window closed) publishes a transient.pauseduntil the tcs sink heals it on the next status publication. I could not construct a persistent failure from it since the sink reconciles immediately, but it is the one spot I will watch on device.- The deadline path now returns the caller at 8 s with the clock reconciled to the rendered position, so a heavily starved seek visibly bounces the scrubber back and then jumps forward when the late landing settles. That is the documented intent (bounded interactive wait) and I agree with the trade-off; just noting it as a UX-visible change.
One cleanup I will do post-merge on main: seekFinalizeState has no production callers left after this PR (only Issue122PausedSeekTests references it), so I will remove it and re-pin the #122 regression against seekRecoveredState.
f5a7548
into
superuser404notfound:main
…State (#129 follow-up) seekFinalizeState lost its last production caller when #129 moved the native seek finalize onto reconcileNativeSeekTransport. Remove it and port Issue122PausedSeekTests to the surviving decision surface (seekRecoveredState + shouldReassertPlayDuringRecovery) so the #122 regression stays pinned against code that actually runs. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018PEEQm5QvBSZ97YZZo4BLv
|
Merged, and released in 5.4.1. Both consumers (Sodalite, AetherPlayer) are already on the new pin. The announced cleanup landed on main as 2cb6fae: Thanks again for the thorough work here, especially for keeping the recovery intent alive across the deadline instead of stacking a second unbounded seek, and for the focused tests around the ordering race. Two PRs in two days, both in the hardest corners of the engine. Much appreciated. |
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018PEEQm5QvBSZ97YZZo4BLv
…rub bands A far-forward VOD seek whose target sat just above a dead scrub band's resident top parked in 3x30 s cache-miss serve timeouts (restarted=false), tore the connection into -1017 item death, and only reached the target via stage-2 reload ~108 s after the seek command (issue superuser404notfound#141, n=1 device log). Two layers misread the geometry: - VideoSegmentProvider's forward-wait branch (r.1 < index <= r.1 + window) read the resident max as "the producer is about to write this". With the superuser404notfound#93 retention budget, r.1 can belong to a dead producer's band far above the active march (band 150-158 from a 600 s scrub; producer re-anchored at 75, front ~79; request seg159). The branch now keys on the active producer's write front, max(highWater since restart, lastRestartIndex), and re-anchors when the request is beyond the reachable window. In normal single-band operation the front equals r.1, so behavior there is unchanged. - The 8 s seek-deadline path (superuser404notfound#129) kept the "progressing" producer because the old position still had forward buffer (seekIsWedged=false), blind to the pending target sitting ~330 s beyond the march. The deadline backstop now also re-anchors when the pending target lies beyond active march coverage (activeMarchCovers via producerCoversPlaylistTime); a healthy march filling toward a reachable target still keeps its progress. The 30 s forward backpressure wait is now injectable for tests (production default unchanged). New Issue141FarForwardSeekTests pin the device geometry (restart fires, no 30 s park), healthy catch-up backpressure, and the march-coverage predicate; RecoverySeekTargetTests pins the extended deadline decision table. Fixes superuser404notfound#141. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NAPCg4tCDdSqkK6tPkNptw
I ran into cases where native seeks could leave the caller waiting for a long time, plus interior cache holes that waited even when the active producer couldn't fill them.
This bounds the seek wait, restarts only when the producer appears genuinely starved, and reconciles transport state, clocks, and subtitles if the original seek lands later. It also skips the sparse-hole wait when producer coverage says a restart is needed.
I tested the main behavior on a real Apple TV with network-backed media and added focused engine tests for the recovery paths. There are several timing-sensitive cases here, so I'd appreciate another set of eyes on the logic.
Related context: #65, #79, and #93. This is additional hardening around the same seek-recovery paths.