Repository navigation
fix(core): a held clip's still goes up the moment it comes on screen, not at the copy's next poll - #9115
Conversation
… not at the copy's next poll
terencecho
left a comment
There was a problem hiding this comment.
[P2] packages/core/src/runtime/mediaProxy.ts:640 — The visibility tick can use a still callback after its copy job is obsolete. Replacing a held clip’s source and seeking into its window before the next poll set a poster from the previous source. A quality change similarly set a poster at the old quality. Check the job’s existing live() predicate before requesting its still. Both probes passed with that guard.
The named regression passes and fails when the helper is disabled. It still passes if the visibility-pass call is removed. A paused-seek test through the runtime would cover that wiring.
149 targeted tests passed. The additional checks used mocked copy responses. Native browser timing was outside the test run.
— tai (automated review)
Edit accuracy: accurate 275 (base branch 273), smooth 51 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
… the runtime pass is tested
|
Both points fixed in c41a44f:
More laptop first opens (same CLI, main's runtime vs this branch's): Still check, second clean pair: no still in 271 of 829 undrawn samples on main (33%), 10 of 518 here (1.9%). Stall trace, 3 first opens a side, interleaved, 30 s of playback each:
The first pair, which I did not count, had a branch run stuck at 0.9 s with clips waiting on copies that had no data yet. That run had no stall trace, so I can't name its cause. Its still samples show no held clip among the waiting ones, and held clips are the only ones this change touches (a poster). The same wait shows up on main in the trace above, and none of the six traced runs stuck at the start. |
terencecho
left a comment
There was a problem hiding this comment.
The request-time guard fixes the earlier source and quality cases. The new paused-seek test also fails if the visibility hook is removed.
[P2] packages/core/src/runtime/mediaProxy.ts:443 — A sealed preview can still install an obsolete poster after its fetch resolves. I changed the source or quality while a still was pending, then resolved the request before the next copy poll. Both cases installed the old poster. Recheck liveness before applying the response.
[P2] packages/core/src/runtime/mediaProxy.ts:658 — An obsolete copy's cleanup can clear a replacement copy's pending still. In the overlap probe the replacement response arrived and the poster stayed blank. Scope pending stills and cleanup to their copy job.
151 targeted tests passed. The three additional probes used mocked fetches. Native browser timing and the cause of the laptop stall remain unverified.
— tai (automated review)
|
Both fixed at the root in a7eead8: a still, and a hold, now belong to the copy job for the clip's current source.
On a quality change I kept one thing deliberately, and it's open for you to disagree. A still from a job a quality change made obsolete may still go up. It's the same frame of the same file, only drawn for a different box. The replacement job starts only after the old one settles at its next poll, so refusing it leaves the clip blank for up to that poll, which is what this PR removes. main's own test "drops its still once its file draws again, after a copy that started with no src (origin null)" pins that a held clip keeps a still across a level drop. It failed when I refused these stills, and passes here. So the still's check is the source only, while the copy job's own liveness still includes the level. Tests in
|
terencecho
left a comment
There was a problem hiding this comment.
Keeping a same-source still across a quality change makes sense. That case passed, along with the new stale-response and stale-cleanup tests.
[P2] packages/core/src/runtime/mediaProxy.ts:445 — A pending sealed still is discarded after its own proxy URL is assigned but before the copy first draws. A deferred-response probe left the poster blank in that interval. The prior head displayed the still until loadeddata. Keep the still eligible through its own copy's load.
[P2] packages/core/src/runtime/mediaProxy.ts:758 — A job that started without a src still matches a different source held without a src. Null attribute equality succeeds before the held-source check. In an overlap probe, the old job installed its proxy over the replacement. Require a matching held source for this branch.
153 targeted runtime tests passed. Both remaining findings reproduced with mocked responses. Native browser timing was outside this round’s validation.
— tai (automated review)
|
Both round 3 findings fixed at 8ef5c24 (I've taken this branch over from its author).
Tests, each red on a7eead8 and green here. With either fix reverted alone, only its own test fails:
One thing your overlap probe also showed: |
terencecho
left a comment
There was a problem hiding this comment.
P2 · Wait for the sealed still to finish decoding in the regression test. At packages/core/src/runtime/mediaProxy.test.ts:2019, advancing the fake clock 10 ms can leave jsdom's FileReader callbacks pending on the real event loop. The exact head failed once in the combined runtime run with a null poster, then passed five combined reruns. Await the reader's completion or mock its completion explicitly before asserting the poster. Keep the loadeddata assertion to verify cleanup.
The two previous source-ownership findings are addressed. Both regressions fail when their respective fixes are reverted, and the PR body names the required regression. Validation used mocked runtime tests.
— tai (automated review)
…s never race jsdom
|
Fixed at d3e4d36, for every sealed-still test in the file, not just the new one. The cause: I ran a probe under fake timers. The response's and the Blob's Proof that no test waits on real time now: with every 10 ms step after an answered still cut to 0,
The |
terencecho
left a comment
There was a problem hiding this comment.
The sealed-still tests now use an asynchronous reader stub that completes within the fake clock step and is restored after each test. The late-still case still verifies that the poster shows during its own copy load and clears on loadeddata. The source-ownership regression also passes.
This head adds test code only. Both targeted runtime suites passed five consecutive runs (145 tests per run), and the PR description names the required regression. Validation used mocked runtime tests.
— tai (automated review)
|
The clip hold rules are now written down in one place, at ca148bb: Each finding on this PR, against those rules:
Any future change to how a clip is held or released updates that table in the same PR. |
terencecho
left a comment
There was a problem hiding this comment.
The delta from the approved commit adds the runtime hold rules and a source comment pointing to them. I checked the documented ownership and still lifetime against the runtime. The production behavior and tests match the approved commit, and the PR body still names the regression. The previous review ran both targeted suites five times. This round verified the documentation delta.
— tai (automated review)
What changed
A 4K clip held while its lighter copy is made now shows its still (its own frame at the playhead, from the server) on the tick it comes on screen. Before, the still was asked for only when the copy's progress was next checked, every 2 s (5 s while the copy queue is full), so a held clip arriving between checks showed nothing for up to that long.
mediaProxy.ts: while a copy is made,stillsWhenDuekeeps the still that copy's checks would put up.showStillWhenDue(el, onScreen)puts it up when the clip is on screen. It is the sameshowStillcall, so "due" still means the media sync has the clip inside its window (sourceTimeAtPlayhead), and a clip with a still or poster is left alone.init.ts: the visibility pass calls it next tostandInCaptureStill, the capture page's own per-tick still. That pass runs aftersyncRuntimeMediain the same tick, so the clip's source time is already known.What I measured
fails without the fix:
packages/core/src/runtime/mediaProxy.test.ts"puts its still up on the tick it comes on screen, not at the copy's next poll". A held clip whose copy is being made, with no poll in between: no still before the clip is inside its window, none while it is off screen, the5.0s still once it is on screen. Without the call it fails withexpected null to be '5.0'.mediaProxy.test.tsandinit.buffering.test.tspass 3 runs in a row (139 tests). All ofsrc/runtimepasses (3,944 tests), and core'stsc --noEmitis clean.On a Windows laptop (Edge, a 4K H.264 project with 100 clips, first open with an empty copy cache), the same CLI served either main's runtime or this branch's. One clean pair; another broke on page load and is not counted:
The still now goes up earlier and stays while the playhead moves on, so its frame trails the playhead further (median 3.2 s vs 1.8 s) until the copy plays.
What I did NOT exercise
init.tsin a unit test: the test callsshowStillWhenDuedirectly. The laptop runs went through the real tick.nullorigin) frame: the still goes through the sameshowStill, unchanged here.