Repository navigation
fix(studio): a corner resize saves the same position whether or not the preview is sealed - #8824
Conversation
…he preview is sealed
…-formula # Conflicts: # packages/core/package-subpaths.json # packages/core/package.json
…-formula # Conflicts: # packages/core/src/runtime/editingGestureStart.ts # packages/studio/src/components/editor/previewGestureStartRead.ts
Edit accuracy: accurate 273 (base branch 271), smooth 61 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.
Approving at 51743646.
An unsealed corner resize now pins its centre with the same resizeAnchor the sealed path uses, with grow measured by the same measureGrowResponse probe, so the two modes save the same digits. I read all 18 files at this head.
- Sealed behaviour is unchanged. The new live measure (
measureLiveGrow) runs only when!previewFrameOpaque(frame), and an opaque frame still goes throughresolveUnmeasuredResizeDraftas before. So nothing sealed gets looser, and an opaque frame's document is never read. - It fails soft. If the overlay scale or the grow can't be measured,
resizeGrowis undefined and the pin falls back to half the size change. The probe restores the inline size infinally. - All four corners go through the same press-time grow and
pressFromCorner. The deleted convergence code (resolveResizeAnchor,computeNextResizeAnchor,overlayCornersCentroid,resolveResizeCenterAnchorOffset,resizeFixedCenterStart) has no remaining callers. - The body has the
fails without the fix:line. The two tests it names (domEditOverlayStartGesture"pins its centre by the grow the sealed frame would report" andpreviewGestureStartRead"measures the grow the sealed frame reports for the same element") each cover a changed line. It also has the "No visible change" note. - The deletion check that was red on
bd2f6536is fixed at this head by theALLOWED_DELETIONSentry for the removed test. All checks are green on51743646, including typecheck, edit accuracy and the studio and core tests.
Per Miguel's hold this merges after 0.9.94.
|
Smoothness, measured again on this head after the merge with main: the unsealed resize grid (
Smooth passing: main 113, 86, 123; this change 115, 99, 122. Across the three pairs, main's range is smooth 86 to 123, frames over 8 ms 0.06% to 0.54%, worst frame 8.41 to 10.12 ms. This change runs smooth 99 to 122, frames over 8 ms 0.08% to 0.48%, worst frame 8.25 to 9.99 ms: inside main's range on each measure (the 8.25 ms worst frame is below it). Pair by pair, this change passes more cases smooth in pairs 1 and 2 and one fewer in pair 3. Other single-case benches shared the box during all three pairs, not evenly: in pair 1 a second bench ran through most of the main run. |
What
A corner resize of a GSAP-scaled box now saves the same position whether the preview is sealed or not. Before, the same drag saved
x: 0.263sealed andx: 0.264unsealed, and the move after it96.867against96.868. Unsealed now saves the sealed values to every digit.Why
A corner resize pins the box's centre by moving it back by how far the drawn size moved it. The two modes worked that pin out differently:
grow), and the pin is computed from that and the size being drawn.The two agree on the pixel but not on the digits: on the same drag the anchor differed by 1.2e-4 px, enough to round the saved offset differently. Two ways of computing one pin will keep drifting apart like this, so this change keeps one.
Related work
None open on this path.
How
refactor(core): the grow probe and the helpers it shares with the resize draft (measureGrowResponse,computedTranslateAxes,movedTranslate,writeDrawnSize,SIZE_PROPERTIES) move fromeditingDraft.ts/editingGestureStart.tstopackages/core/src/runtime/drawnBox.ts, exported as@hyperframes/core/drawn-box, so a parent that scripts the frame can run the same probe. Frame behaviour is unchanged. The one textual change:getComputedStyleis read from the element's own window.fix(studio)(two commits): an unsealed corner resize measures grow on the live element at the press (measureLiveGrow,previewGestureStartRead.ts:42) with the same probe the frame runs (editingGestureStart.ts:225→drawnBox.ts:85) and the same overlay mapping the sealed reply uses (growOnOverlay,previewGestureStartRead.ts:38, used at:95). It reads the overlay scale with the frame's document, as the other live readers do (domEditOverlayGeometry.ts:139). Both modes then pin withresizeAnchor(resizeDraft.ts:68, wassealedResizeAnchor).resolveResizeAnchor,computeNextResizeAnchor,overlayCornersCentroid,resolveResizeCenterAnchorOffset,resizeFixedCenterStart) and their tests.growandpressFromCorner.Test plan
Unit. fails without the fix: two new tests, each run against the code before its fix.
domEditOverlayStartGesture.test.ts, "pins its centre by the grow the sealed frame would report": withdomEditOverlayStartGesture.tsas on main it fails (expected "vi.fn()" to be called with arguments, 1 failed, 10 passed); with the change, 11 passed.previewGestureStartRead.test.ts, "measures the grow the sealed frame reports for the same element": the same card measured live and through a sealed frame must give the same grow. With the overlay scale read without the frame's document it fails (expected null to deeply equal { a: -0.25, b: 0, c: 0, d: 0.25 }, 1 failed, 12 passed); with the change, 13 passed.Files touching this path, one file per run, all exit 0:
previewGestureStartRead13,domEditOverlayStartGesture11,resizeDraft4,DomEditOverlay21,domEditOverlayGeometry12,anchoredResizeCommitFeedsOffset11,previewOverlayRects32. The repo's pre-commit (typecheck, lint, format, fallow) passed on each commit.Real Studio, both modes. Built from this branch and from its base on a Linux box, served by the built CLI, driven headless: a 240 x 160 box GSAP holds at
scale: 1.25; drag its bottom-right corner, then move it; read the savedindex.html. Two runs per mode.x: 0.263, y: 0.176x: 0.264, y: 0.176x: 96.867, y: 30.478x: 96.868, y: 30.478x: 0.263, y: 0.176x: 0.263, y: 0.176x: 96.867, y: 30.478x: 96.867, y: 30.478With this change both modes saved byte-identical files (same sha256) in all four runs. Every input the pin reads at the press was equal to every digit across modes: centre, actual size, edit and content scale, rotation, press offset from the corner, and
grow(a: 0.19305553436279296, d: 0.19305555555555556). The anchor wasdx -49.70661674096906, dy -33.13774813169096in all four.Edit-accuracy bench, unsealed, every resize case (
test:edit-accuracy --grid full --filter '^resize-', 126 cases), base against this change on the same box, each run in a CPU-capped job:Accurate (every check but smooth): base 126/126, this change 126/126. Worst tracking: base 0.236 px, this change 0.236 px; worst teleport: base 0.260, this change 0.260.
Per case: tracking max and teleport max in px, base / this change (16 CPUs)
resize-fromto-px-r0-nested-z100-onresize-fromto-px-r0-root-z100-afterresize-fromto-px-r0-root-z100-midresize-fromto-px-r0-root-z100-onresize-fromto-px-r0-root-z50-afterresize-fromto-px-r0-root-z50-midresize-fromto-px-r0-root-z50-onresize-fromto-px-r30-root-z100-afterresize-fromto-px-r30-root-z100-midresize-fromto-px-r30-root-z100-onresize-fromto-px-r30-root-z50-afterresize-fromto-px-r30-root-z50-midresize-fromto-px-r30-root-z50-onresize-hold-px-r0-nested-z100resize-hold-px-r0-nested-z50resize-hold-px-r0-root-z100resize-hold-px-r0-root-z50resize-hold-px-r30-nested-z100resize-hold-px-r30-nested-z50resize-hold-px-r30-root-z100resize-hold-px-r30-root-z50resize-hold-xpercent-r0-nested-z100resize-hold-xpercent-r0-nested-z50resize-hold-xpercent-r0-root-z100resize-hold-xpercent-r0-root-z50resize-hold-xpercent-r30-nested-z100resize-hold-xpercent-r30-nested-z50resize-hold-xpercent-r30-root-z100resize-hold-xpercent-r30-root-z50resize-idle-px-r0-nested-z100resize-idle-px-r0-nested-z50resize-idle-px-r0-root-z100resize-idle-px-r0-root-z50resize-idle-px-r30-nested-z100resize-idle-px-r30-nested-z50resize-idle-px-r30-root-z100resize-idle-px-r30-root-z50resize-keys-px-r0-nested-z100-onresize-keys-px-r0-root-z100-afterresize-keys-px-r0-root-z100-midresize-keys-px-r0-root-z100-onresize-keys-px-r0-root-z50-afterresize-keys-px-r0-root-z50-midresize-keys-px-r0-root-z50-onresize-keys-px-r30-root-z100-afterresize-keys-px-r30-root-z100-midresize-keys-px-r30-root-z100-onresize-keys-px-r30-root-z50-afterresize-keys-px-r30-root-z50-midresize-keys-px-r30-root-z50-onresize-late-px-r0-nested-z100-onresize-late-px-r0-root-z100-afterresize-late-px-r0-root-z100-beforeresize-late-px-r0-root-z100-onresize-late-px-r0-root-z50-afterresize-late-px-r0-root-z50-beforeresize-late-px-r0-root-z50-onresize-late-px-r30-root-z100-afterresize-late-px-r30-root-z100-beforeresize-late-px-r30-root-z100-onresize-late-px-r30-root-z50-afterresize-late-px-r30-root-z50-beforeresize-late-px-r30-root-z50-onresize-none-px-r0-nested-z100resize-none-px-r0-nested-z50resize-none-px-r0-root-z100resize-none-px-r0-root-z50resize-none-px-r30-nested-z100resize-none-px-r30-nested-z50resize-none-px-r30-root-z100resize-none-px-r30-root-z50resize-scale-px-r0-nested-z100-onresize-scale-px-r0-root-z100-afterresize-scale-px-r0-root-z100-midresize-scale-px-r0-root-z100-onresize-scale-px-r0-root-z50-afterresize-scale-px-r0-root-z50-midresize-scale-px-r0-root-z50-onresize-scale-px-r30-root-z100-afterresize-scale-px-r30-root-z100-midresize-scale-px-r30-root-z100-onresize-scale-px-r30-root-z50-afterresize-scale-px-r30-root-z50-midresize-scale-px-r30-root-z50-onresize-size-px-r0-nested-z100-onresize-size-px-r0-root-z100-afterresize-size-px-r0-root-z100-midresize-size-px-r0-root-z100-onresize-size-px-r0-root-z50-afterresize-size-px-r0-root-z50-midresize-size-px-r0-root-z50-onresize-size-px-r30-root-z100-afterresize-size-px-r30-root-z100-midresize-size-px-r30-root-z100-onresize-size-px-r30-root-z50-afterresize-size-px-r30-root-z50-midresize-size-px-r30-root-z50-onresize-spin-px-r0-nested-z100-onresize-spin-px-r0-root-z100-afterresize-spin-px-r0-root-z100-midresize-spin-px-r0-root-z100-onresize-spin-px-r0-root-z50-afterresize-spin-px-r0-root-z50-midresize-spin-px-r0-root-z50-onresize-spin-px-r30-root-z100-afterresize-spin-px-r30-root-z100-midresize-spin-px-r30-root-z100-onresize-spin-px-r30-root-z50-afterresize-spin-px-r30-root-z50-midresize-spin-px-r30-root-z50-onresize-tween-px-r0-nested-z100resize-tween-px-r0-nested-z50resize-tween-px-r0-root-z100resize-tween-px-r0-root-z50resize-tween-px-r30-nested-z100resize-tween-px-r30-nested-z50resize-tween-px-r30-root-z100resize-tween-px-r30-root-z50resize-tween-xpercent-r0-nested-z100resize-tween-xpercent-r0-nested-z50resize-tween-xpercent-r0-root-z100resize-tween-xpercent-r0-root-z50resize-tween-xpercent-r30-nested-z100resize-tween-xpercent-r30-nested-z50resize-tween-xpercent-r30-root-z100resize-tween-xpercent-r30-root-z50Smooth (no more frames over 25 ms than the blank-page control, and no frame over 8 ms of main-thread work), cases passing out of 126. The bench ran in a CPU-capped job on a shared box, base and this change in turn; other benches ran on the box during the last runs:
At 16 CPUs, per run: worst single frame of main-thread work, frames over 8 ms, cases with frames over 25 ms beyond the control.
The last run of this change overlapped two other benches on the same box (7 browser jobs); none of the base runs did. Base's own runs range from 95 to 121 passing, and this change's from 82 to 108. The failures fall on frames in the middle of the drag, not the press, and on different cases each run. Before the fix commit, with the same per-frame code, an uncapped run passed 126 against the base's 124.
The grid has no
transform-originaxis, so a resize around a moved origin is not covered here.Press cost, unsealed, 10 corner presses, pointer-down to the first frame after it: base median 24.65 ms, max 32.1; this change median 23.85 ms, max 31.2. Pointer-down to its handlers done: base 9.2 / 16.0 ms, this change 8.0 / 15.2 ms.
Package.
@hyperframes/coregainsdist/runtime/drawnBox.jsand its types: +499 bytes packed.verify:packed-manifests, run before the merge with main, reported only@hyperframes/engine, at the same 517,176 bytes on the base. Main has since raised that budget. CI runs the check on the merge.No visible change
Nothing draws differently: the saved offsets move by 0.001 px, and the change is TypeScript only (no
.tsx,.cssor.html). The tables above are the evidence.