8000 fix(preview): drop seeking-guard that froze playback in all 3 previews by johannboehme · Pull Request #44 · johannboehme/tk-1 · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions frontend/src/components/arrange/CamPreviewArrange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ export function CamPreviewArrange() {

useEffect(() => {
if (!videoEl) return;
// Skip while the element is recovering from a previous seek; stacking
// another `currentTime` write tears the decoder open mid-flight on
// huge phone recordings — same anti-stutter rule the Triage preview
// uses. `prevMasterT` stays unchanged so the next non-seeking tick
// sees the full delta and classifies the situation correctly.
if (videoEl.seeking) return;

const action = decideCamPreviewAction({
masterT: currentTime,
syncOffsetMs,
Expand Down
10 changes: 0 additions & 10 deletions frontend/src/components/triage/CamPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@ export function CamPreview() {

useEffect(() => {
if (!videoEl) return;
// Skip while the element is still recovering from a previous seek.
// Stacking another `currentTime = X` on top of an in-flight seek
// tears the decoder open mid-flight on huge phone recordings —
// exactly the post-seek stutter loop the user reports.
if (videoEl.seeking) {
// Don't update prevMasterT — we want the NEXT non-seeking tick to
// see the full delta from before the seek so it can classify it
// as a jump.
return;
}
const action = decideCamPreviewAction({
masterT: currentTime,
syncOffsetMs,
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/editor/render/video-element-pool.test.ts
10000
Original file line number Diff line number Diff line change
Expand Up @@ -305,21 +305,21 @@ describe("VideoElementPool — syncAll behaviour", () => {
expect(fakes[0].currentTime).toBe(10.1);
});

it("skips the entire tick while the element is mid-seek", () => {
// Stacking another `currentTime` write on top of an in-flight seek
// tears the decoder open mid-flight. Pool must NOT touch the
// element while seeking is true; the next free tick handles it.
it("still calls play() to resume after a mid-seek tick (browser pauses implicitly during seek)", () => {
// The browser pauses the element implicitly while it's seeking. If
// we suppress play() during seeking, the element never resumes once
// the seek completes — playback freezes. Browsers handle a fresh
// currentTime write supersession internally; we don't need to skip.
const { pool, fakes } = makePoolWithFakes([
cam("a", { sourceDurationS: 600 }),
]);
pool.syncAll(targets([["a", 10]]), true);
expect(fakes[0].currentTime).toBe(10);
fakes[0].play.mockClear();
(fakes[0] as unknown as { seeking: boolean }).seeking = true;
fakes[0].currentTime = 5; // pretend the element is mid-seek somewhere else
fakes[0].paused = true; // browser implicit pause during seek
pool.syncAll(targets([["a", 20]]), true);
expect(fakes[0].currentTime).toBe(5); // unchanged — no write while seeking
expect(fakes[0].play).not.toHaveBeenCalled(); // no play() during seek
expect(fakes[0].play).toHaveBeenCalled(); // recovery path runs
});

it("re-snaps precisely when a paused-out cam comes back on PROGRAM", () => {
Expand Down
6 changes: 0 additions & 6 deletions frontend/src/editor/render/video-element-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,6 @@ function syncSlot(slot: Slot, sourceT: number, isPlaying: boolean): void {
if (!v.paused) v.pause();
return;
}
// Skip while a previous seek is still resolving. Don't update
// prevTargetSourceT either — we want the next free tick to see the
// full source-target delta from before the seek, so it can keep
// classifying it as the same jump.
if (v.seeking) return;

const drift = Math.abs(v.currentTime - sourceT);
const prev = slot.prevTargetSourceT;
const isJump =
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/local/timing/cam-preview-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@
* and let the element play freely. Browsers keep audio + a muted
* `<video>` close enough on their own clock for triage purposes,
* and small natural drift is invisible.
* • Caller is expected to skip the action when `videoEl.seeking` so
* we don't stack seeks on a still-decoding element.
*
* The caller does NOT need to skip while `videoEl.seeking` — the
* jump-vs-natural classifier above is what prevents the stutter loop.
* A seeking-guard in the caller would break responsive scrubbing and
* loop-wrap (any tick that lands during the 100-400 ms decoder warmup
* would be silently dropped, leaving the video frozen at a stale frame).
* Browsers handle "newer setCurrentTime supersedes in-flight seek"
* internally — the decoder may pay extra cycles, but the visible target
* is always the latest one.
*/

import { camSourceTimeS, type CamTimeRef } from "./cam-time";
Expand Down
Loading
0