Repository navigation
fix(studio): a sealed press starts as soon as the frame answers - #8688
Conversation
Edit accuracy: accurate 273 (base branch 271), smooth 49 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) |
jrusso1020
left a comment
There was a problem hiding this comment.
Approving at 3998342.
- Red-first holds. With main's
previewGestureStarts.tsput back,on an opaque frame asks at the press and starts once the frame answers, with no animation framefails withexpected "vi.fn()" to be called once, but got 0 times. At head it passes, along with the rest ofpreviewOverlayRects.test.ts(29/29). - The settle-wait test from #8668 behaves as the body says.
gsapSealedReads.browser.test.tspasses 4/4 at head in real Chrome. Withawait settleGsapSnapshot(iframe)taken out ofreadAllAnimatedProperties, only the sealed case fails (expected {} to deeply equal { rotation: 10 }, 1 failed, 3 passed). - An answer from an earlier frame can't start the press. I wrote a scratch test that held the frame's answer and released it on cue:
- Answer lands after a preview change has begun, then a new iframe replaces the old one: no start while the change runs. The old answer is dropped because
askedOf !== frame. The press asks the new frame and starts exactly once, only after that frame answers. - Press ended before the answer lands:
pollseespress.endedand nothing starts. - The early
poll()in the press event can't start the gesture by itself. The firstchannelStepalways clearsoverChanneland returns "wait", so the start always comes from the answer's callback or a later frame.
- Answer lands after a preview change has begun, then a new iframe replaces the old one: no start while the change runs. The old answer is dropped because
- The waits after a save are the same as on main. An ask goes out only from
channelStep, after both the queued-press check and theisPreviewChanging()check, and both checks come before it in the same order as on main. The only differences are when the first look happens (in the press event instead of on the next animation frame) and that the answer triggers a look right away. A press behind a save still waits on animation frames until the change ends. The non-sealed path still starts throughrequestAnimationFrame(pollFirst), so the shown-frame counting there is untouched.pollNowcancels the pending animation frame before it polls, so a press never has two loops running. - The 18 Studio unit test files that cover the gesture code pass (226 tests), and
tsc --noEmitis clean.
Nit (not from this PR, same on main): if a preview change runs on the same iframe element between the ask and the answer, the press does not ask again once the change ends. It starts from the answer it got before the change, because askedOf === frame. My scratch test shows this at head and on main alike. The window is the 2-18 ms the answer takes, and this PR doesn't widen it. A swapped iframe is handled correctly, as shown above. A possible follow-up is to clear askedOf when a change starts while an ask is out.
What
A press on a sealed preview now starts its gesture as soon as the frame answers, about one frame after the press instead of two.
Why
On a sealed preview Studio cannot read the pressed element itself, so a press asks the frame where it is and starts once the answer comes back. A regular preview reads the element directly and starts in the same event.
The press only asked on its first animation frame. When the answer arrived, the press noticed it only on the frame after that. With no save pending, that cost about 32 ms per press on the edit-accuracy bench (old Mac,
seqheldtwice-tlhold-px-r0-root-z100): ask at +12-16 ms, all three answers 2-3 ms later, start at +32 ms.Related work
Refs #7846 (Studio's preview sealed by default): one of the places a sealed preview must behave as a regular one.
How
components/editor/previewGestureStarts.ts, the sealed path only:A regular preview's waiting press still steps on animation frames: it counts shown frames to decide when to start. The waiting outline after the replay is unchanged. It stays until the frame has drawn the replayed drag, which a test already pins: without it the layer showed at the drag's start for a frame.
Also in this PR: the test owed from #8668, which checks that the keyframe reader waits for the sealed frame's values at the playhead.
Test plan
on an opaque frame asks at the press and starts once the frame answers, with no animation frameinsrc/components/editor/previewOverlayRects.test.tsfailed on main withexpected "vi.fn()" to be called once, but got 0 times. With animation frames stubbed out, the press never started.a commit's read waits for the frame's values at the playhead (sealed)insrc/hooks/gsapSealedReads.browser.test.ts(real Chrome, both modes). It passes at main, where fix(studio): sealed keyframe edits save the same values as a regular preview #8668 added the wait. With that wait removed on the devbox, the sealed case alone fails (1 failed, 3 passed).The remaining ~18 ms is the frame's first answer: asked during the press, it takes one frame. Getting to 0 would mean reading the element before the press.
No visible change
This is a timing change on the sealed path: the gesture starts one frame sooner. Nothing is drawn differently, so there is no capture to compare.