Repository navigation
fix(studio): a sealed gesture recording keeps the layer's offset and the film's scale - #8568
Conversation
Edit accuracy: accurate 271 (base branch 271), smooth 48 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (2)
|
terencecho
left a comment
There was a problem hiding this comment.
P2 — Revalidate the target after the sealed frame answers. useGestureCommit.ts:442 starts an asynchronous base read, but its completion calls begin with the captured selection and iframe. If the user switches layers, reloads the frame, leaves the project, or enters read-only mode before the reply, that callback can still start recording. It can pair the old target with the current selection’s animation list, or attach document listeners after the hook has unmounted. Invalidate the pending start on those changes and check the current preview and target before arming it. Add a deferred-reply test through the commit hook.
P2 — Clamp the recorded samples at the layer end. useGestureRecording.ts:440–445 caps only the seek. The sample still uses elapsed wall time, until the separate stop interval observes the seek. A recording started at 2 s on a layer ending at 2.5 s can seek to 2.5 s but save a 0.9 s sample. The commit uses that last sample as its duration. The new test checks the seek alone. Please cap the saved samples and assert the resulting recording duration.
Static review.
— tai (automated review)
|
Both fixed in 8c9abab.
The touched hook files pass 3 runs in a row (32 tests); Studio |
terencecho
left a comment
There was a problem hiding this comment.
P2 — Frame snapping can still put a saved sample past the layer end. The tick now clamps elapsed time, but useGestureRecording.ts:145–147 rounds that time to the nearest composition frame before saving it. I changed the new boundary test to start at 2 s with the layer ending at 2.52 s. The seek correctly stopped at 2.52 s, but the last sample was 0.533333 s at 30 fps, and the commit derives its duration from that sample. Please keep the final saved sample at or before the boundary after snapping, and pin an off-frame end in the test.
The pending-start guards address the earlier stale-reply finding. All 27 targeted tests passed before the off-frame variation.
— tai (automated review)
|
Fixed in d7abc12: when snapping to the nearest frame would put a sample past the layer end, New row in |
terencecho
left a comment
There was a problem hiding this comment.
The sample stays on its nearest frame when that frame fits and uses the previous frame when rounding would exceed the layer end. The regression now checks the 2.52 s off-frame boundary alongside the existing on-frame case. All 28 targeted gesture tests passed locally. Required CI is still running.
— tai (automated review)
terencecho
left a comment
There was a problem hiding this comment.
The reviewed gesture files are byte-for-byte identical after the merge. The producer's packed limit stays in place, and the new unpacked limit is the verifier's prescribed 5% headroom over the reported 3,526,322 bytes. Three focused verifier tests passed, and feeding the reported sizes to the verifier fails the old limit and passes the new one. I did not repack locally. Required CI is still running.
— tai (automated review)
What
On a sealed preview, a recorded gesture now starts from the layer's real GSAP position and scales the pointer by the film's own width. While it records, the film's playhead moves, so the recording stops by itself at the layer's end. Before, a sealed recording started from 0/0 on an assumed 1920-wide film. The saved keyframes dropped the layer's offset and were the wrong size on any film that isn't 1920 wide, the playhead never moved, and it ran until stopped by hand. "Recorded N keyframes" still showed.
Why
useGestureRecordingread the frame directly:iframe.contentWindow.gsap, which a sealed frame doesn't expose, so acatchleft 0/0/1/1;contentDocument, which is null, so it fell back to 1920.With no in-frame runtime it also never moved the playhead, and the auto-stop in
useGestureCommitwatches the playhead.Related work
Refs #7846 (Studio's preview sealed by default).
How
editingGestureStart.ts,editingPort.ts): a newgesture-baserequest answers GSAP's x, y, opacity and scaleX for each handle, animated or static, the samegsap.getPropertyreads the unsealed recorder makes. It's its own request, not an option ongesture-start: that read deliberately never asks GSAP about a layer no tween touches, because asking GSAP for x folds a CSS translate into its transform, and the next drag would then read the layer as GSAP-owned. Only a recording asks, as it does unsealed.useGestureCommitasksgesture-basefor the selection's handle (previewGestureBase) and starts the recording from that answer. Unsealed reads the live GSAP throughgetIframeGsapand starts in the same task, as before.previewStageSize, the size the frame's runtime posts. Unsealed reads the composition'sdata-widthas before.requestSeek, the same seek the timeline uses). The film moves, the playhead follows, and the existing auto-stop fires.gesture-basestarts only if, when the answer lands, it's still the latest start, the same preview frame, the same layer, Studio is still mounted, and the preview hasn't turned read-only.gesture-base) or the film's size, the recording doesn't start, and Studio shows "Preview not ready. Try again", the message it already shows when there's no preview. It never records from defaults.scripts/package-size-budgets.json):gesture-baseships in the runtime the producer bundles, adding 319 bytes to its unpacked size. Measured on Linux withpnpm pack, main's producer is 3,526,003 bytes unpacked, 265 bytes under the 1% tolerance over its 3,491,355 budget, so any runtime change past that fails the check. The budget moves to 3,702,639, which is the script's own 5% headroom over this branch's 3,526,322. The packed budget doesn't change (977,466 against 993,551).No visible change
On a sealed preview, recording a gesture saves the motion where the layer is and at the film's scale, and stops at the layer's end. The interface itself doesn't change.
Test plan
fails without the fix:
packages/studio/src/hooks/useGestureRecording.sealed.test.tsx: "starts from the layer's GSAP offset the frame reported", "scales the pointer by the film's own width, not 1920", "moves the film's playhead with the recording, up to the layer's end, so auto-stop can fire", "refuses to record when the frame hasn't reported the layer's values", "refuses to record when the frame hasn't reported the film's size", "scales from a static scale the same sealed as unsealed";packages/studio/src/hooks/useGestureCommit.test.tsx: "doesn't start once another layer is selected before the frame answers", "doesn't start once Studio unmounts before the frame answers";packages/studio/src/hooks/useGestureRecording.sealed.test.tsx: "saves no sample past a layer end that falls between frames" (a layer ending at 2.52 s, recorded from 2 s at 30 fps: the last sample is 0.5 s; before, rounding saved 0.533 s);packages/core/src/runtime/editingGestureStart.test.ts: "reads GSAP's x, y, opacity and scale for a layer no tween touches", "answers null without GSAP, or for an element this load does not have".useGestureCommit.test.tsxandnewTweenTargetHooks.test.tsxmock the recorder; their mock's start now answers that it started.useGestureRecording.sealed.test.tsx,useGestureRecording.test.tsx,useGestureCommit.test.tsx,newTweenTargetHooks.test.tsx(33 tests) andeditingGestureStart.test.ts(19 tests) pass three runs in a row on Linux. Against main's sources the six recorder rows and the twogestureBaserows fail.src/runtime(164 files, 3,597 tests) passes, withgesture-baseadded to the request lists ineditingAgent.test.tsandeditingPort.test.ts. Core and Studio typecheck clean.src/hooksandsrc/components/editor(4,047 tests) pass with the review fixes. In the full run before it, every file passed butTimeline.virtualization.test.tsx, whose 11 tests failed in the full parallel run (one timed out at 31 s). The file passes 11/11 run alone, twice with this branch and once on main's sources; this branch doesn't touch the timeline.