Repository navigation
fix(studio): a clip deleted while the preview reloads leaves the frame on screen - #8819
Conversation
…ir elements through a reload
…the frame now shown
|
Real-app walk at a79fce9 (desktop app built locally against this branch's packages, which include #8817; Linux). A clip dragged past the film's end, then deleted right after the save:
Counted from Studio's own log of each delete's lookup and the frame's reply. No frame held the deleted clip afterwards in any sealed run. On main, the same walk left a sealed delete unanswered in 3 of 11 runs. Known timing cost, not changed here: after a promotion, a sealed refresh first asks the new frame to swap scenes. A film without scene parts refuses, and the refresh then reloads as an unsealed one does at once. That extra round trip measured 43, 50, 54 and 82 ms over 4 refreshes in 2 sealed runs. Those runs used an earlier build; this PR does not touch the refresh path. |
|
Removal time on screen, same walk at a79fce9:
The sealed time is the round trip through the editing port: look up the clip, then remove it. The two figures are measured differently, so compare the size of the gap, not single values. |
vanceingalls
left a comment
There was a problem hiding this comment.
Reviewed at a79fce9, own diff against #8817's branch. Comment only, not an approval: this PR is stacked on #8817, so I approve after #8817 merges and this retargets main.
The code reads right. SECOPS-3848 is a sealed clip delete dropped without a word when the shadow reload swaps frames between the lookup and the removal. announcePreviewPromoted records which frame replaced which, shownPreviewFrame follows that record, and removeIframeTimelineElements acts on the shown frame in both modes. The sealed path reruns the lookup and the removal once on the new frame when a lookup went unanswered (undefined) and its load was replaced. I checked that undefined means no reply and null means not found in previewSelection.ts, so a clip that is simply gone is not retried. The promotion chain cannot loop, because each promotion's live frame is a new slot element keyed by gen. The retry fails closed: one rerun, then nothing removed.
One gap, not a blocker for a comment review but worth closing before this merges: the rerun only fires on found.includes(undefined). If every lookup is answered on the old load and the swap lands before remove-elements goes out, replaced is true but the code still sends the old load's handles to the retired frame, and the delete is dropped the same way. Retrying on replaced && !retried alone would cover that window too. Please confirm whether leaving it out was deliberate.
fails without the fix: is present and names previewTimingPatch.browser.test.ts at 7f262e0 with the 3 new cases, and "No visible change" is stated. CI on this head shows no Studio test or typecheck jobs, since the base is a PR branch, so the real-Chrome test has not run in CI here. It will on the retarget.
…ad promoted before its removal
…oad promoted mid-delete
|
Two additions at 005da51:
fails without the fix: |
vanceingalls
left a comment
There was a problem hiding this comment.
Re-reviewed at 005da51 (delta a79fce9...005da51: previewTimingPatch.ts and its browser test).
The gap I raised is closed. removeSealedElements now reruns whenever the load was replaced before the removal (!sameLoad() || shownPreviewFrame(given) !== iframe), whatever the lookups answered. The rerun is bounded: retried is set on the second pass, so there is one retry and no loop. The rerun re-resolves the handles against the newly shown frame, so handles from the retired frame are not sent. The new test ("lookups answered just before the reload is promoted") delivers the held answers and promotes in one task, so every lookup answers and the swap lands before remove-elements. The old condition required an unanswered lookup, so on the old code the delete would go to the retired frame and the clip would stay in the new one. I read that as red-first, though I did not run it.
The duration readout change reads correct. The sealed path syncs from a fresh document copy after remove-elements is awaited, and it does not re-enter inOrder, so there is no deadlock. The unsealed path syncs only when something was removed, since findTimelineElementInIframe returns null on a miss. The new case covers both modes: clip A ended the film at 4 s, and both the reported duration and the readout drop to 2 s.
Two small things, neither blocking. If a second swap lands during the retry, that pass is not retried again. If the delete empties the film, syncContentDuration returns early on end <= 0 and the readout keeps the old value. The body's fails without the fix: line still describes the earlier test commit, so please add the new cases to it.
CI on this head: 10 checks passed, 0 failed. The Studio jobs (Preflight lint/format, regression shards, perf shards) show as skipped, as expected on a PR-branch base, so the browser tests did not run in CI. I am relying on the author's local runs.
I'm commenting rather than approving because this is stacked on #8817's branch (#8817 is still open). Approval follows once #8817 merges and #8819 retargets main and the Studio jobs run. Nothing else blocks.
|
Thanks. On the three notes:
|
Edit accuracy: accurate 273 (base branch 271), smooth 53 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) |
vanceingalls
left a comment
There was a problem hiding this comment.
#8817 merged and this now targets main, so Studio CI ran. At 005da51 Test (studio 2/3) fails, and I'm not approving past it.
useTimelineEditing.test.tsx > "rolls back the store duration and live root when a delete persist fails" gets expected 2 to be 4 at line 971. That test is green on main (Studio 1/3, 2/3 and 3/3 all pass there), so the change causes it.
Cause: the new unsealed branch of removeIframeTimelineElements calls syncContentDuration when it removes something. That call sets the store duration to the shrunk value synchronously. In useTimelineDeleteOps.ts the removal runs at line 145, but captureDurationRollback is only taken at line 193. So the rollback snapshot is already the shrunk 2s, and a failed delete persist no longer restores the 4s readout and live root. That is a real regression for a failed delete in an unsealed preview.
Fix: take the rollback snapshot before the removal, or drop the sync from removeIframeTimelineElements and let useTimelineDeleteOps do its own sync after capture. The sealed path syncs after the await, so check it keeps the same order.
The rest still reads right, and my earlier comment on the sealed rerun stands. I'll approve once this is green.
vanceingalls
left a comment
There was a problem hiding this comment.
Requesting changes at 005da51, now that this targets main and Studio CI ran: Test (studio 2/3) fails on useTimelineEditing.test.tsx ("rolls back the store duration… when a delete persist fails", expected 4, got 2), and it passes on main. The new unsealed-removal duration sync in useTimelineDeleteOps.ts (line 145) runs before the rollback snapshot is taken (line 193), so a failed delete no longer restores the duration readout. Take the snapshot before the sync (or include the duration in it). The rest still reads right per my earlier comment.
…oss-promotion # Conflicts: # packages/studio/src/player/lib/previewChannel.ts
|
Fixed at b1489d9. The delete now takes its duration snapshot before fails without the fix: Also ran: every test under |
vanceingalls
left a comment
There was a problem hiding this comment.
Approving at b1489d9. The earlier blocker is fixed.
useTimelineDeleteOps.ts:captureDurationRollbacknow runs at :145, beforeremoveIframeTimelineElements, so the snapshot holds the pre-delete length and a failed persist puts it back. The sealed removal's duration sync and the rollback both go throughinOrder, so the rollback lands after the sync. The unsealed sync is synchronous and the rollback sees the shortened value. studio 2/3 and 3/3 are green,useTimelineEditingincluded.- Frame-swap fix:
shownPreviewFrameand the one-time rerun inremoveSealedElementslook right. The rerun redoes lookup and removal together, so handles from the old load are never reused. - The browser tests cover the unsealed and sealed swap cases and the film-shortening case. The "fails without the fix" line in the PR body covers the 3 swap cases at 7f262e0.
Required checks are green on this head. The one red is Comments (comment ratchet): useTimelineDeleteOps.ts rose from 14.5% to 14.8% because of the new comment above captureDurationRollback. It is not a required check. Please cut that line or move the explanation into a name, so the ratchet is green before merge.
Nit: the PR body says nothing about the new behaviour where a delete shortens the film and the readout, and its "Not changed" notes are stale. Add a line for it.
What
A clip deleted while the preview reloads now leaves the frame on screen. Studio sends the delete to the frame that replaced the old one, instead of a frame that is no longer shown. In a sealed preview, a delete still waiting for its lookup when the reload swaps frames runs again, once, on the new frame.
Why
A preview reload loads the film in a hidden second frame and swaps it in when it is ready (
useShadowPreviewReload.ts,promoteWhenReady). Studio then retires the old frame's editing client. A sealed delete looks its clips up over that client before it removes them. When the swap lands between the two, the lookup gets no answer, and the delete was dropped without a word. The clip stayed drawn until the next load.In the desktop app, saving a timeline edit reloads the preview in both modes, and the swap lands about half a second later. A sealed delete made right after a move missed this way in 1 of 20 instrumented real-app runs. An unsealed delete acts at once on the frame it is given. The same stale frame, handed to it after a swap, removed the clip from a frame no longer on screen.
Related work
Stacked on #8817, whose
samePreviewLoadthis uses to see that a load was replaced. Refs #8816 (the selection box after a sealed reload). Like those,previewChannel.tsstays the one place that knows which client answers for the frame on screen.How
player/lib/previewChannel.ts:notePreviewPromoted(retired, live)records which frame replaced which, andshownPreviewFrame(iframe)follows that record to the frame on screen.player/sceneSwap.ts:announcePreviewPromoted, which every promotion already calls, records the swap.hooks/previewTimingPatch.ts:removeIframeTimelineElementsacts onshownPreviewFrame(iframe)in both modes. A sealed delete whose lookup went unanswered because its load was replaced runs again once, on the frame now shown. Element handles belong to one load, so the lookup and the removal both run again; neither is re-sent alone.Test plan
previewTimingPatch.browser.test.ts(real Chrome): a delete given the frame a reload just replaced removes the clip from the frame now shown (unsealed and sealed). A sealed delete still waiting on its lookup when the reload is promoted removes the clip from the new frame.fails without the fix:
packages/studio/src/hooks/previewTimingPatch.browser.test.ts, run at the test commit 7f262e0 alone, fails all 3 new cases (the shown frame drops the deleted clip: expected true to be false); the 4 others pass.Dropping the record in
announcePreviewPromotedfails all 3 again. Dropping only the rerun fails the sealed lookup case.The browser test passed 3 runs in a row.
previewChannel.test.ts,sceneSwap.test.ts,sceneSwap.sealed.test.ts,previewTimingPatch.test.ts,timelineTimingSync.test.ts,timelineTimingSync.sealed.test.ts,useTimelineSyncCallbacks.test.tsanduseTimelineSyncCallbacks.sealed.test.tspass (110 tests). The Studio type check passes.Unit tests added/updated
Manual testing performed
Documentation updated (if applicable)
Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug
No visible change
A layout or style capture would show nothing new. The change decides which frame a delete goes to while a reload swaps frames, and the clip ends up gone in both cases. Before, it stayed drawn until the next load.