Repository navigation
fix(studio): a sealed drag sends each step to the preview as the pointer moves - #8899
Conversation
…ter moves Chrome dispatches pointermove inside the task that paints the frame, so a step a sealed drag sent from pointermove reached the preview after that paint. The step now goes from pointerrawupdate, which fires in its own task before the rendering. On a 4x slowed CPU this puts the step in the preview before its frame is drawn in 166 of 400 frames instead of 2; the rest still arrive a frame late, because the rendering task often starts right after the raw update. pointermove still draws where that event is missing, and a step drawn twice is sent once.
Edit accuracy: accurate 273 (base branch 271), smooth 71 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) Unstable (1)
|
vanceingalls
left a comment
There was a problem hiding this comment.
Changes requested at 7193aff: the Comments check is red on this head and the failure is this PR's own lines. The code itself is clean.
Blocker (Comments / A package file's comment share may not rise, run 45772855162):
packages/studio/src/components/editor/previewDrafts.ts: comment share rose from 3.6% (8/225) to 3.8% (9/236). One comment line added; cut it or move it into a name (the doc line ondrawsNothingNewis the new one).packages/studio/src/components/editor/rawPointerSteps.ts: new file at 15.0% (3/20), over the package's 9.2%. Cut to one comment line.
Not main's red: both lines are added by this diff.
Code review, no findings:
- Ordering: the raw path and pointermove compute the step through the same
snappedDragDelta, and raw events come before the pointermove that carries the same or a newer position, so the preview only moves forward. A pointermove equal to the last drawn step is dropped bydrawsNothingNew, never a different one. - Pointerup: the commit still uses
lastSnappedDx/Dyfrom pointermove and draws it throughapplyManualOffsetDragCommit->drawPreviewDraft.drawsNothingNewreturns false oncesavingis armed, and a commit that differs from the last raw draw is sent, so the final preview equals the committed offset.gestureRefis nulled first, so a raw update after release draws nothing and removes its listener. - Cancel:
clearPointerStaterestores throughrestoreStudioPathOffset->endPreviewDraft("restore"), which deletes thedrawnentry, so the next drag cannot be skipped as a repeat. - Hover raw updates are ignored (
movesGestureneeds the primary button), and a missingpointerrawupdatefalls back to pointermove. - fails without the fix lines are in the body and both tests exist at the head.
Merge hold: the hold for the 70+30 board is Miguel's, not mine. Once Comments is green and Producer integration tests and CodeQL (pending now) finish, I would approve this as it is.
vanceingalls
left a comment
There was a problem hiding this comment.
Approved at 560e9f4.
The change since 7193aff is two files and only removes or shortens comments: one doc line cut in previewDrafts.ts, and the header comment in rawPointerSteps.ts cut to one line plus one doc line removed. No code changed. The ordering, pointerup and cancel code I found clean last time is untouched.
Every check is green at this head: Comments, Producer: integration tests, CodeQL (all Analyze jobs) and the rest. 59 passed, 22 skipped, none red or pending.
The merge hold for the 70+30 board is Miguel's.
What
On a sealed preview, a dragged element now reaches the pointer's position in the same frame more often. On a 4x slowed CPU, the preview had the step when the frame was drawn in 166 of 400 drag frames, up from 2 of 400.
This does not close the lag: the other 234 frames still show the element one frame behind the pointer, where an unsealed preview never is.
Why
Chrome dispatches pointermove inside the task that draws the frame. A sealed drag sends each step to the preview over the preview's channel, and the preview can only take that message after the task ends, so every step reached it after the frame it belonged to had been drawn. An unsealed drag moves the element inside the pointermove handler, so it is drawn in that frame.
pointerrawupdatefires in its own task as the input arrives, before that drawing task. A step sent from it reaches the preview before the frame is drawn, unless the drawing task starts right behind it. In Studio at 4x it often does (0 to 2 ms later in the traces), which is why this is a partial fix.Related work
None.
How
useDomEditOverlayGestures.ts: during a single drag on a sealed preview, apointerrawupdatelistener sends the drag's step to the preview. It is set up on the drag's first pointermove and removes itself on the first raw update after the drag ends. Everything else the drag draws (outline, readout, guides) stays on pointermove.snappedDragDelta.ts: the drag's axis lock and edge snapping, moved out unchanged so pointermove and the raw update compute the same step.previewDrafts.ts: a draw equal to the last one is not sent again, unless a save is waiting on it, so the pointermove that follows a raw update adds no message.pointerrawupdatedoes not exist (it is feature-detected; WebKit has none, and it needs a secure context), pointermove sends the step as before.Test plan
sealedRawDragStep.test.ts"draws each step after the first from the raw pointer update", andpreviewDrafts.test.ts"posts a step drawn twice once". Both fail on main and pass with the fix.src/components/editor/187 files, 2214 tests pass in 4 runs, the last on this head. Studio typecheck clean.Edit accuracy
seqnudge-none-px-r0-root-z100, sealed, CPU 4x, 10 rounds on main and 10 with the fix, interleaved, with a performance trace of each drag:In the desktop app's Studio page,
pointerrawupdateexists and fires once per pointer move (a loopback origin, which is a secure context).Before
After