Repository navigation
fix(playback): reanchor a seek below a restarted window and refuse an anchor-less remux start - #461
Merged
Merged
Conversation
… anchor-less remux start A seek that restarts an HLS generation in place leaves the plan the client holds advertising the window from before the restart. The next backward seek requested a segment below where the new generation begins and got 412 four times; the client then refetched the playlist and clamped the playhead forward (328 s to 931 s in production). - Reject the reuse of a live HLS generation for a seek target before that generation's own start, so the server rebuilds the transport at the target instead of serving a playlist that begins past it. - Translate a 412 for a pending seek into a seek_reanchor at the target instead of retrying the dead URL or refetching a playlist that would clamp it. A 412 during ordinary playback now refetches the playlist with the live sgen token, bounded to two attempts. A progressive remux start that cannot resolve its copy seek anchor degraded to an unanchored stream that produced no bytes for 15 s and froze the playhead. - Answer the existing retryable seek terminal instead of returning that plan; the start path already carries Retry-After, and the next attempt is sized from the probe cost just recorded. Segmented HLS keeps its degrade because its segment layer can wait or restart for the target. - Bound a progressive remux replacement started for a seek to the same first-output window; a stream that produces nothing now surfaces a retry instead of leaving the playhead on the target. Tests: a backward seek after an in-place restart rebuilds at the requested position; a 412 with a pending seek reanchors and does not refetch the playlist; a 412 during playback refetches it; an anchor-less progressive remux start refuses with a retryable seek error. Existing progressive Range, anchor-budget and seek tests still pass.
…or by its seek window The af63a08 matrix run narrowed both seek failures but left four defects. A 412 on the segment route is the server's generation fence. With a pending seek the client reanchored, but hls.js had already queued its own retry of the same fragment, so the dead URL was requested twice and its second answer fell through to the ordinary playlist refetch. On a restarted generation that refetch seeks to the element's media position on the playlist's own clock, which asked for seg_00346 (692 s) while the target was 346 s and left the picture frozen for 35 s. hls.js is now stopped on the first 412, a pending seek never refetches the fenced playlist, and an in-place reanchor that reuses the generation refetches it once with the live token and the target on restart. A progressive remux has no segment layer to wait for the target, so its anchor probe is bounded by the seek's first-output window (8 s) minus the rebuilt transport's share (3 s), not by the probe's own 15 s cap. A probe that cannot answer now returns the retryable transcode_start_failed verdict at the 5 s probe bound instead of after 15-25 s; segmented HLS keeps its adaptive budget. The seek path also had no retry affordance: the player only surfaced a replan error it could attribute to a transport it had torn down. A seek the server refused with a retryable terminal left the old picture and the target on the controls. It now shows the same Try again card as a refused start, pauses the surviving stream, and puts the position back on the seek's origin. A seek replacement also keeps the play intent sampled at request time, so a pause the teardown forces cannot hand it shouldAutoPlay=false, and the controls stop claiming to play until the replacement's own play event. Tests: a 412 with a pending seek stops the transport and answers exactly one reanchor request; a reanchored transport autoplays and does not claim to play before it; a refused seek shows Try again with the position restored; a progressive anchor that cannot answer fails inside its seek window with one bounded probe; a fast transient failure still reserves its retry. Existing seek, Range, and anchor-budget tests pass.
The 09378d9 matrix left five residuals on the seek-fix build. A rapid run of backward reanchors replaced the transport several times. Each replacement paused the element while it loaded, and the next seek sampled that pause as the viewer's intent, handing the following replacement shouldAutoPlay=false: ds-seek and ta-seek ended loaded but paused with nothing on screen explaining it. The player now carries the viewer's play/pause intent sampled when the seek is issued, and the session uses it instead of the transient element state. A refused reanchor showed no retry because a queued track_change (a held pick or a no-op inventory refresh) fired as soon as the seek replan settled, clearing the error, and then held the client for 20-30s. While a retryable refused-seek card is up, automatic track, quality and output replans are held, and a default-audio invalidation is acknowledged without replacing the card. A new seek, a real failure, or the card's fresh start releases it. A 412 on a fenced segment stopped hls.js, but a planRevision effect restarted the stopped instance to refetch its playlist before the asynchronous replacement existed. That second request asked for the same fenced segment and was aborted by the replacement. The restart now requires the same stream URL and transport revision, so a rebuilt generation never re-requests the fence. An audio switch restarted 10s behind the viewer because a non-seek replan preferred the session's last progress report (up to 10s old) over the client's live position. The client's position now wins when it is at least as far along as the session; a value behind the session is still treated as a stale snapshot. The pr-seek start latency (6442ms) is the initial watch-detail fetch plus start request, not the seek-anchor probe; the probe bound only affects seek reanchors. The ta-sub first cue at 12.1s is the next dialogue line in a window whose extraction took 27ms, not provider or client latency. Tests: rapid backward seeks keep carrying play intent; a refused seek keeps its retry card instead of dispatching a queued track change or default-audio reconcile; a reanchor that builds a new generation does not refetch the stopped transport; a fresh client playhead wins over the last progress sample. Existing seek, Range, anchor-budget and audio-replan tests pass.
The tv-seek re-check shows the fenced token requested once (412), then the rebuilt generation requesting the same segment under its own token. Assert that the replacement loads its own playlist, so the allowed direction is covered alongside the existing no-refetch test. The ta-audio re-check shows the replan carries the click position, not the last progress sample. Assert the audio switch sends that position.
randrini
force-pushed
the
fix/seek-after-restart
branch
from
November 21, 2026 15:11
8c937f9 to
646dc23
Compare
A copy-video transport starts at the preceding source keyframe, so an audio switch that rebuilds onto a progressive copy remux presents up to one GOP of earlier content. Record that as a transport invariant with its bound, the client's obligation not to seek it away, the HLS exemption, and why re-encoding the leading GOP was rejected.
randrini
force-pushed
the
fix/seek-after-restart
branch
from
November 21, 2026 15:18
646dc23 to
27275a1
Compare
A retryable copy-video seek-anchor refusal offers the viewer one Try again. The fresh start that button issues was treated as another first attempt: it got the same 5 s progressive probe window and, when that expired, the same card a second time. The user took the only affordance offered, waited another 5 s, and landed on the same wall. - Record the retryable refusal this handler answered, keyed by profile and requested file, and treat the next start for that pair as the viewer's retry. The mark is cleared by a successful timeline and expires after two minutes. - Grant the retry the probe's full 15 s cap instead of the first attempt's 5 s window, with the same 3 s transport reserve. The 18 s retry window stays inside the 43 s start phase and the 45 s client abort. Log it separately with the granted budget. - If the retry's probe still cannot anchor, start the copy stream from the keyframe FFmpeg's input seek resolves instead of refusing again. The unanchored plan keeps the requested position as its origin, so the client cannot jump forward; the pre-roll is the documented up-to-one-GOP offset. - The first attempt keeps its fast 5 s refusal and one card. A retry never returns the same seek refusal: it either plays or answers a different failure.
The retry state-transition test exercises a real timed-out probe, which records a probe-cost lower bound in the playback package's process-wide tracker. Use a source identity no other handler test anchors on so that 15 s mark cannot size a later test's probe budget.
The retry card can stay on screen longer than a couple of minutes. Keep the refusal mark long enough for the viewer to come back to it, bounded and cleared by a successful timeline so an old refusal cannot shape a much later start.
The retry round granted a viewer-initiated retry a longer probe window and a keyframe-origin fallback. On the deployed build it did not converge: - the extended window and the fallback leaked into non-seek replans, so a track_change that replanned in 203 ms spent a 5 s anchor probe, presented no frame, and left the element paused for 24.7 s; - the keyframe fallback was taken but the stream ended 'remux produced no output: EOF', so the viewer got no frame; - when the source could not be resolved at all, the retry showed the same card again. It also lost ground against 8c6cf60 and a8a714a, which are verified: the silent pause after repeated backward seeks is fixed, the fence is handled once, the audio switch plays with its documented one-GOP offset, and the position sampling is correct. This restores that behaviour and drops only the retry attempt. The retry dead end is a known limitation to address separately, not by stacking another patch on a branch that is losing ground. The keyframe-anchor decision stays documented in docs/architecture/playback-protocol-v3.md section 5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Related issue: N/A
Validation tasks: none
The playback matrix run on
af63a080eleft two seek cells failing for fourseparate reasons. The earlier round narrowed both failures but did not close
them.
F1 — transcode video, backward seek after a forward restart (
tv-seek).Item
file_id=1760202, session3f3f561a-aaa9-4b51-99cd-9baf85a2fcdd, routetranscode/server_transcode_hls. A forward scrub to 939.4 s restartsFFmpeg at segment 468. The backward scrub to 347.2 s is answered by a
seek_reanchor(2017 ms) that lands at 346.5 s and plays, but the clientrequests the fenced
seg_00173.tstwice (412 at 20:26:41.944 and again at20:26:42.452) before the replan answers. The second answer falls through to the
ordinary playlist refetch, which seeks the restarted generation on the
playlist's own clock and asks for
seg_00346.ts(692 s). In one of four proberuns (session
f83ab3d1-f987-4d94-9353-1f01c7b1d6e4) that left the contentposition at 346.75 s for 35 s while the UI showed the Pause control: the
element was not advancing and the controls claimed it was.
F2 — progressive remux, forward seek (
pr-seek). Itemfile_id=37985,session
47a20041-c461-4b28-a80f-7e5b38338f48, routeremux/server_remux_progressive. The seek replan now answers the retryabletranscode_start_failedverdict instead of a 15 s no-byte stream, but it takes15.0 s and then 24.9 s to decide, and the seek path shows no retry: the position
stays on the failed target with no error and no
Try again. The start pathshowed the card at 15.1 s and its retry played (
pr-sub). File37985laterlost its probe data, and the matrix substituted
1614887, where the stepspassed; that was the substitution mechanism working, not this repro being
fixed.
The retry this card offers is a known limitation of this change. The card
appears after about 5 s, the viewer presses
Try again, and the fresh startre-runs the same 5 s anchor probe against the same slow source and is refused
again. A fix was attempted and reverted: granting the retry a longer bounded
window plus a keyframe fallback leaked into non-seek replans, turned a 203 ms
track_changeinto a 5 s probe with no frame and a 24.7 s pause, and stilldelivered no frame on the fallback (
remux produced no output: EOF). That workis deferred to its own change. The harness cell
pr-seek-retryexists to proveit when it lands.
Approach
The previous round translated the 412 into a
seek_reanchorbut left hls.js'sown fragment retry in flight, so the fence still saw the dead URL twice. The
second answer then fell through to the playback playlist refetch, which is what
moved the restarted generation to
seg_00346and froze it. The round also sizedthe progressive anchor probe by its own cap, and the player never surfaced the
seek terminal it received.
These changes close the residuals:
is requested exactly once. A pending seek never refetches the fenced
playlist. If the reanchor reuses the same generation, a
planRevisioneffectrefetches that playlist once with the live token and resumes at the seek
target instead of leaving a stopped instance behind.
anchor probe is bounded by the seek's first-output window (8 s) minus the
rebuilt transport's share (3 s): 5 s, not the probe's own 15 s cap. A probe
that cannot answer returns the retryable
transcode_start_failedverdict atthat bound. A fast failure still leaves room for the bounded retry inside the
window. Segmented HLS keeps its adaptive budget because its segment layer can
wait or restart for the requested segment.
pause forced by tearing down the old transport cannot hand the replacement
shouldAutoPlay=false. The controls also stop claiming to play when a seekreplacement attaches, until its own
playevent.Try againcard for a replan the server markedretryable as it does for a refused start, including on the seek path. It
pauses the surviving stream and puts the controls back on the seek's origin,
not the target that never played. A refused subtitle pick keeps its menu
toast.
track_changeno longerfires as the replan settles and clears it. The card stays until a new seek, a
real failure, or its own fresh start. The retry it offers is the known
limitation described above.
can_seek_anywhereis unchanged, there is no/api/v1change, and subtitledelivery is untouched.
Head
8c6cf6000re-checkThe two cells were re-run against the head. The fence and the audio sampling
behave as intended. The audio switch still starts at the copy-video keyframe;
that offset is intended, bounded, and documented below — not an open defect.
tv-seek: what the three requests areSession
12247eef-aeb6-4c7e-92e2-4ed128f7b1bb, item1760202, backward seek toabout 22%.
seg_00173.ts...:5a01800f...:0(displaced)seg_00173.ts...:5d0011f0...:0(rebuilt)ERR_ABORTED, first attemptseg_00173.ts...:5d0011f0...:0(rebuilt)The 412 is the fenced token, requested once. The displaced generation's FFmpeg
process was stopped at 12:26:06.574, before either 200, so neither 200 can be
old-generation bytes. In the reproduction the aborted request and the 200 both
carry the rebuilt generation's token: the new transport's first attempt and its
retry. The rebuilt generation may serve the segment under its own token, and it
does. The matrix verdict now treats that single 412 as the expected fence when
the same segment is served under a different sgen; a repeat of the displaced
sgen still fails.
ta-audio: where the 3.69 s comes fromSession
801f11cb-4614-42f1-8046-444c72c089f3, item1978284, Japanese at66.919 s.
position_seconds: 67.449; the click lands 0.53 safter the harness sample at 66.919. The plan's
source_start_secondsis67.449.
stream_origin_secondsis 63.146, the preceding keyframe, andplayer_start_secondsis 4.303. The first frame is 63.229.progressive remux cannot start within 1 s of 67.449 without re-encoding the
leading GOP or changing delivery. The sampling is at the click; the 3.69 s
is the keyframe pre-roll.
This is intended transport behaviour. The anchor is the last source keyframe at
or before the requested position, so the offset is bounded by the GOP that
contains the click: at most one GOP, not a fixed number of seconds. The client
cannot correct it — any
video.currentTimeseek on that stream restarts at theorigin. Re-encoding the leading GOP was considered and rejected: it changes the
play method and its CPU cost, and a forward skip to the next keyframe would be
worse for the viewer. Segmented HLS does not carry the same offset because its
segment layer can wait for, or restart at, the target. The invariant is
documented in
docs/architecture/playback-protocol-v3.md§5.Far-seek latency
The time goes to the anchor probe and the rebuilt transport, not the client
sampler. Same head, same cells:
ds-seekfar forwardds-seekfar backta-seekfar forwardta-seekfar backThe far-back figure includes playing from the keyframe to the target. The
progressive anchor probe is bounded at 5 s. The last commit's server change is
the non-seek position preference; its client changes only affect play intent,
refused-seek cards, and fenced HLS transports. The 4.5 s matrix number was a
cold probe on the same path, not a structural regression. Removing the
pre-roll would require starting at the next keyframe (a forward skip on sparse
GOPs) or changing delivery; both are separate correctness decisions, so this
change leaves the probe and the pre-roll as they are.
Exercisable
pr-seekUse item
episode-tvdb-74796-1-2,fileId=1614975(DTS-HD 1080p virtual;494047resolves to the same file), or the same-release substitute37973(effective
1614886) when that row is unavailable. Play from the start, waituntil the element is at about 25 s, then scrub to about 919 s (63% of 1462 s).
The copy-video anchor probe on the 4.49 GB remote source exceeds its 5 s
progressive window, the replan answers the retryable
transcode_start_failedverdict, and the player shows
Try againwith the pre-seek position restored.1614975has since been markedfailed_atwithavailable=falseand itspinned candidate is gone, so the substitute is the reproducible path.
37985and
37971no longer start, and38193substitutes1614887and completesthe seeks.
Deferred: the retry after the refusal
The card's
Try againre-runs the same 5 s anchor probe against the same slowsource and is refused again. A fix was built and reverted in
ba74013c8:transport reserve (an 18 s first-output window), and it fell back to the
keyframe origin when the probe still could not answer;
fallback leaked into non-seek replans: a
track_changethat replanned in203 ms spent a 5 s anchor probe, presented no frame, and left the element
paused for 24.7 s. The keyframe fallback was taken but the stream ended
remux produced no output: EOF. When the source could not be resolved at all,the retry showed the same card again.
So the retry leg is a known limitation of this change, not a regression it
introduces: before this branch the seek refusals did not exist at all. Fixing it
is its own piece of work, and the harness cell
pr-seek-retryalready recordsthe first attempt (fast refusal, one enabled card, position continuity) and the
retry leg separately so the follow-up has a bound to prove against.
Validation
go build ./...: passes.gofmtandgo vet ./internal/playback ./internal/api/handlers: clean.go test -count=1 ./internal/playback: passes exceptTestResolveCopySeekAnchorRecordsMeasuredProbeCost, a timing-sensitivecost-tracker test that failed once and passed on rerun. This diff does not
touch
internal/playback.go test -count=1 ./internal/api/handlers: the same three failures asb9ee2f384:TestVirtualMetadataUpdateRecoversEvidenceAfterTransientTimeout,TestAggregateSectionsOmitRowsWithNoAccessibleItemsDB, andTestPluginUploadSeamsOnRealManager(group-writableTMPDIR); 593 s. Thefinal head changes only the retry test fixture path..
tsc -bviaweb/scripts/typecheck.mjs: clean.vitest run src/player/components/VideoPlayer.test.tsx src/player/hooks/usePlaybackSession.test.ts: 514 passed.BASE_REF=b9ee2f384 make lint-changed: 0 issues.make verify-local-paths: passes.ba74013c85911ccb1ce5c1e934f7086b52476317(revert(playback): defer the seek-anchor retry round).44940572215:ghcr.io/kipsilabs/vio:ba74013c85911ccb1ce5c1e934f7086b52476317and...-base, multi-arch.ba74013c8: green.212 ms and plays at −3.68 s (inside one GOP), all seven regression cells
pass, and the retry cell records
known-limitation.Tests added: a 412 with a pending seek stops the transport and answers exactly
one reanchor request; a reanchored transport autoplays and does not claim to
play before it; a refused seek shows
Try againwith the position restored; aprogressive anchor that cannot answer fails inside its seek window with one
bounded probe; a fast transient failure still reserves its retry; a stopped
fenced transport restarts when the reanchor reuses its generation; a rebuilt
generation loads its own playlist under its own token; an audio switch carries
the click position instead of the last progress sample.
Risks
A progressive-remux seek whose anchor genuinely needs more than 5 s fails its
first attempt with the retryable verdict instead of succeeding late. That is the
requested trade. The retry the card offers is a known limitation: it re-runs the
same probe and can be refused again. Fixing that is deferred, because the
attempt to fix it leaked into non-seek replans and broke the audio switch.
The player now pauses the old stream when it shows a retryable refused-replan
card. The card covers the player, so letting audio continue behind it would
leave the visible position disagreeing with playback.
A progressive copy-video start begins at the preceding keyframe, so an audio
switch in the middle of a long GOP presents up to one GOP of earlier content.
That is intended and bounded by the source GOP; removing it needs a delivery
change or a re-encoded leading GOP, a separate play-method decision that does
not belong in this fence-and-retry fix.
Checklist
AI Disclosure
ollama-cloud/deepseek-v4.1-flash:1017