Skip to content

fix(studio): a corner resize saves the same position whether or not the preview is sealed - #8824

Merged
miguel-heygen merged 6 commits into
mainfrom
fix/resize-one-anchor-formula
Nov 25, 2026
Merged

miguel-heygen merged 6 commits into
mainfrom
fix/resize-one-anchor-formula

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

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.263 sealed and x: 0.264 unsealed, and the move after it 96.867 against 96.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:

  • Sealed, the frame measures at the press how its centre moves per px of drawn width and height (grow), and the pin is computed from that and the size being drawn.
  • Unsealed, Studio measured the four corners on every frame and nudged the pin toward the press-time centroid, converging over frames.

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 from editingDraft.ts / editingGestureStart.ts to packages/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: getComputedStyle is 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 with resizeAnchor (resizeDraft.ts:68, was sealedResizeAnchor).
  • Deleted: the measured convergence (resolveResizeAnchor, computeNextResizeAnchor, overlayCornersCentroid, resolveResizeCenterAnchorOffset, resizeFixedCenterStart) and their tests.
  • The resize start log gains grow and pressFromCorner.

Test plan

  • 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

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": with domEditOverlayStartGesture.ts as 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: previewGestureStartRead 13, domEditOverlayStartGesture 11, resizeDraft 4, DomEditOverlay 21, domEditOverlayGeometry 12, anchoredResizeCommitFeedsOffset 11, previewOverlayRects 32. 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 saved index.html. Two runs per mode.

Sealed Unsealed
Base, resize x: 0.263, y: 0.176 x: 0.264, y: 0.176
Base, move after it x: 96.867, y: 30.478 x: 96.868, y: 30.478
This change, resize x: 0.263, y: 0.176 x: 0.263, y: 0.176
This change, move after it x: 96.867, y: 30.478 x: 96.867, y: 30.478

With 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 was dx -49.70661674096906, dy -33.13774813169096 in 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)
Case Tracking Teleport All but smooth
resize-fromto-px-r0-nested-z100-on 0.047 / 0.047 0.010 / 0.010 pass / pass
resize-fromto-px-r0-root-z100-after 0.038 / 0.038 0.020 / 0.020 pass / pass
resize-fromto-px-r0-root-z100-mid 0.042 / 0.042 0.013 / 0.014 pass / pass
resize-fromto-px-r0-root-z100-on 0.042 / 0.042 0.023 / 0.023 pass / pass
resize-fromto-px-r0-root-z50-after 0.072 / 0.072 0.047 / 0.047 pass / pass
resize-fromto-px-r0-root-z50-mid 0.086 / 0.086 0.024 / 0.024 pass / pass
resize-fromto-px-r0-root-z50-on 0.084 / 0.084 0.049 / 0.049 pass / pass
resize-fromto-px-r30-root-z100-after 0.074 / 0.074 0.021 / 0.021 pass / pass
resize-fromto-px-r30-root-z100-mid 0.087 / 0.087 0.014 / 0.014 pass / pass
resize-fromto-px-r30-root-z100-on 0.074 / 0.074 0.023 / 0.023 pass / pass
resize-fromto-px-r30-root-z50-after 0.188 / 0.188 0.046 / 0.048 pass / pass
resize-fromto-px-r30-root-z50-mid 0.110 / 0.110 0.025 / 0.025 pass / pass
resize-fromto-px-r30-root-z50-on 0.188 / 0.188 0.051 / 0.051 pass / pass
resize-hold-px-r0-nested-z100 0.047 / 0.047 0.018 / 0.018 pass / pass
resize-hold-px-r0-nested-z50 0.100 / 0.100 0.018 / 0.018 pass / pass
resize-hold-px-r0-root-z100 0.064 / 0.064 0.009 / 0.009 pass / pass
resize-hold-px-r0-root-z50 0.084 / 0.084 0.031 / 0.030 pass / pass
resize-hold-px-r30-nested-z100 0.074 / 0.074 0.020 / 0.019 pass / pass
resize-hold-px-r30-nested-z50 0.129 / 0.129 0.017 / 0.017 pass / pass
resize-hold-px-r30-root-z100 0.084 / 0.084 0.012 / 0.012 pass / pass
resize-hold-px-r30-root-z50 0.149 / 0.149 0.030 / 0.031 pass / pass
resize-hold-xpercent-r0-nested-z100 0.039 / 0.039 0.004 / 0.004 pass / pass
resize-hold-xpercent-r0-nested-z50 0.072 / 0.072 0.025 / 0.025 pass / pass
resize-hold-xpercent-r0-root-z100 0.039 / 0.039 0.004 / 0.004 pass / pass
resize-hold-xpercent-r0-root-z50 0.072 / 0.072 0.025 / 0.025 pass / pass
resize-hold-xpercent-r30-nested-z100 0.084 / 0.084 0.007 / 0.007 pass / pass
resize-hold-xpercent-r30-nested-z50 0.152 / 0.152 0.028 / 0.027 pass / pass
resize-hold-xpercent-r30-root-z100 0.084 / 0.084 0.007 / 0.007 pass / pass
resize-hold-xpercent-r30-root-z50 0.152 / 0.152 0.028 / 0.027 pass / pass
resize-idle-px-r0-nested-z100 0.053 / 0.053 0.014 / 0.014 pass / pass
resize-idle-px-r0-nested-z50 0.095 / 0.095 0.014 / 0.014 pass / pass
resize-idle-px-r0-root-z100 0.058 / 0.058 0.015 / 0.015 pass / pass
resize-idle-px-r0-root-z50 0.086 / 0.086 0.027 / 0.027 pass / pass
resize-idle-px-r30-nested-z100 0.056 / 0.056 0.014 / 0.013 pass / pass
resize-idle-px-r30-nested-z50 0.129 / 0.129 0.013 / 0.014 pass / pass
resize-idle-px-r30-root-z100 0.084 / 0.084 0.018 / 0.018 pass / pass
resize-idle-px-r30-root-z50 0.110 / 0.110 0.027 / 0.027 pass / pass
resize-keys-px-r0-nested-z100-on 0.062 / 0.062 0.012 / 0.013 pass / pass
resize-keys-px-r0-root-z100-after 0.047 / 0.042 0.013 / 0.013 pass / pass
resize-keys-px-r0-root-z100-mid 0.052 / 0.052 0.014 / 0.014 pass / pass
resize-keys-px-r0-root-z100-on 0.034 / 0.034 0.010 / 0.011 pass / pass
resize-keys-px-r0-root-z50-after 0.093 / 0.093 0.019 / 0.019 pass / pass
resize-keys-px-r0-root-z50-mid 0.062 / 0.062 0.039 / 0.039 pass / pass
resize-keys-px-r0-root-z50-on 0.074 / 0.074 0.019 / 0.019 pass / pass
resize-keys-px-r30-root-z100-after 0.060 / 0.060 0.013 / 0.013 pass / pass
resize-keys-px-r30-root-z100-mid 0.062 / 0.062 0.013 / 0.013 pass / pass
resize-keys-px-r30-root-z100-on 0.060 / 0.060 0.011 / 0.011 pass / pass
resize-keys-px-r30-root-z50-after 0.145 / 0.145 0.022 / 0.023 pass / pass
resize-keys-px-r30-root-z50-mid 0.194 / 0.194 0.042 / 0.042 pass / pass
resize-keys-px-r30-root-z50-on 0.236 / 0.236 0.034 / 0.034 pass / pass
resize-late-px-r0-nested-z100-on 0.045 / 0.045 0.005 / 0.005 pass / pass
resize-late-px-r0-root-z100-after 0.029 / 0.029 0.006 / 0.006 pass / pass
resize-late-px-r0-root-z100-before 0.058 / 0.058 0.015 / 0.015 pass / pass
resize-late-px-r0-root-z100-on 0.054 / 0.054 0.007 / 0.007 pass / pass
resize-late-px-r0-root-z50-after 0.090 / 0.090 0.007 / 0.007 pass / pass
resize-late-px-r0-root-z50-before 0.086 / 0.086 0.027 / 0.027 pass / pass
resize-late-px-r0-root-z50-on 0.070 / 0.070 0.006 / 0.006 pass / pass
resize-late-px-r30-root-z100-after 0.088 / 0.088 0.006 / 0.006 pass / pass
resize-late-px-r30-root-z100-before 0.074 / 0.084 0.017 / 0.018 pass / pass
resize-late-px-r30-root-z100-on 0.065 / 0.065 0.006 / 0.006 pass / pass
resize-late-px-r30-root-z50-after 0.145 / 0.145 0.007 / 0.007 pass / pass
resize-late-px-r30-root-z50-before 0.110 / 0.110 0.027 / 0.027 pass / pass
resize-late-px-r30-root-z50-on 0.164 / 0.164 0.013 / 0.013 pass / pass
resize-none-px-r0-nested-z100 0.053 / 0.053 0.014 / 0.014 pass / pass
resize-none-px-r0-nested-z50 0.095 / 0.095 0.014 / 0.014 pass / pass
resize-none-px-r0-root-z100 0.058 / 0.058 0.015 / 0.015 pass / pass
resize-none-px-r0-root-z50 0.086 / 0.086 0.027 / 0.027 pass / pass
resize-none-px-r30-nested-z100 0.056 / 0.056 0.014 / 0.013 pass / pass
resize-none-px-r30-nested-z50 0.129 / 0.129 0.013 / 0.014 pass / pass
resize-none-px-r30-root-z100 0.084 / 0.084 0.018 / 0.018 pass / pass
resize-none-px-r30-root-z50 0.110 / 0.110 0.027 / 0.027 pass / pass
resize-scale-px-r0-nested-z100-on 0.051 / 0.051 0.242 / 0.242 pass / pass
resize-scale-px-r0-root-z100-after 0.052 / 0.052 0.054 / 0.054 pass / pass
resize-scale-px-r0-root-z100-mid 0.054 / 0.054 0.184 / 0.184 pass / pass
resize-scale-px-r0-root-z100-on 0.045 / 0.045 0.246 / 0.245 pass / pass
resize-scale-px-r0-root-z50-after 0.071 / 0.071 0.056 / 0.055 pass / pass
resize-scale-px-r0-root-z50-mid 0.102 / 0.102 0.184 / 0.183 pass / pass
resize-scale-px-r0-root-z50-on 0.090 / 0.090 0.254 / 0.254 pass / pass
resize-scale-px-r30-root-z100-after 0.073 / 0.073 0.054 / 0.055 pass / pass
resize-scale-px-r30-root-z100-mid 0.066 / 0.066 0.184 / 0.184 pass / pass
resize-scale-px-r30-root-z100-on 0.075 / 0.075 0.241 / 0.241 pass / pass
resize-scale-px-r30-root-z50-after 0.146 / 0.146 0.053 / 0.053 pass / pass
resize-scale-px-r30-root-z50-mid 0.187 / 0.187 0.179 / 0.179 pass / pass
resize-scale-px-r30-root-z50-on 0.128 / 0.128 0.260 / 0.260 pass / pass
resize-size-px-r0-nested-z100-on 0.045 / 0.045 0.005 / 0.005 pass / pass
resize-size-px-r0-root-z100-after 0.029 / 0.029 0.006 / 0.006 pass / pass
resize-size-px-r0-root-z100-mid 0.045 / 0.045 0.006 / 0.006 pass / pass
resize-size-px-r0-root-z100-on 0.054 / 0.054 0.007 / 0.007 pass / pass
resize-size-px-r0-root-z50-after 0.090 / 0.090 0.007 / 0.007 pass / pass
resize-size-px-r0-root-z50-mid 0.090 / 0.090 0.048 / 0.048 pass / pass
resize-size-px-r0-root-z50-on 0.070 / 0.070 0.006 / 0.006 pass / pass
resize-size-px-r30-root-z100-after 0.088 / 0.088 0.006 / 0.006 pass / pass
resize-size-px-r30-root-z100-mid 0.074 / 0.074 0.008 / 0.008 pass / pass
resize-size-px-r30-root-z100-on 0.065 / 0.065 0.006 / 0.006 pass / pass
resize-size-px-r30-root-z50-after 0.145 / 0.145 0.007 / 0.007 pass / pass
resize-size-px-r30-root-z50-mid 0.144 / 0.155 0.048 / 0.048 pass / pass
resize-size-px-r30-root-z50-on 0.164 / 0.164 0.013 / 0.013 pass / pass
resize-spin-px-r0-nested-z100-on 0.078 / 0.078 0.015 / 0.015 pass / pass
resize-spin-px-r0-root-z100-after 0.084 / 0.084 0.017 / 0.017 pass / pass
resize-spin-px-r0-root-z100-mid 0.104 / 0.104 0.016 / 0.016 pass / pass
resize-spin-px-r0-root-z100-on 0.093 / 0.093 0.016 / 0.016 pass / pass
resize-spin-px-r0-root-z50-after 0.175 / 0.175 0.032 / 0.032 pass / pass
resize-spin-px-r0-root-z50-mid 0.161 / 0.161 0.032 / 0.032 pass / pass
resize-spin-px-r0-root-z50-on 0.156 / 0.156 0.029 / 0.029 pass / pass
resize-spin-px-r30-root-z100-after 0.084 / 0.084 0.017 / 0.017 pass / pass
resize-spin-px-r30-root-z100-mid 0.102 / 0.124 0.019 / 0.019 pass / pass
resize-spin-px-r30-root-z100-on 0.093 / 0.093 0.016 / 0.016 pass / pass
resize-spin-px-r30-root-z50-after 0.175 / 0.175 0.032 / 0.032 pass / pass
resize-spin-px-r30-root-z50-mid 0.086 / 0.086 0.027 / 0.026 pass / pass
resize-spin-px-r30-root-z50-on 0.156 / 0.156 0.029 / 0.029 pass / pass
resize-tween-px-r0-nested-z100 0.033 / 0.033 0.020 / 0.020 pass / pass
resize-tween-px-r0-nested-z50 0.097 / 0.097 0.036 / 0.036 pass / pass
resize-tween-px-r0-root-z100 0.038 / 0.038 0.012 / 0.012 pass / pass
resize-tween-px-r0-root-z50 0.072 / 0.072 0.049 / 0.048 pass / pass
resize-tween-px-r30-nested-z100 0.104 / 0.104 0.025 / 0.024 pass / pass
resize-tween-px-r30-nested-z50 0.208 / 0.208 0.040 / 0.040 pass / pass
resize-tween-px-r30-root-z100 0.066 / 0.066 0.014 / 0.014 pass / pass
resize-tween-px-r30-root-z50 0.167 / 0.167 0.049 / 0.050 pass / pass
resize-tween-xpercent-r0-nested-z100 0.064 / 0.064 0.012 / 0.012 pass / pass
resize-tween-xpercent-r0-nested-z50 0.086 / 0.086 0.022 / 0.023 pass / pass
resize-tween-xpercent-r0-root-z100 0.064 / 0.064 0.012 / 0.012 pass / pass
resize-tween-xpercent-r0-root-z50 0.086 / 0.086 0.022 / 0.023 pass / pass
resize-tween-xpercent-r30-nested-z100 0.076 / 0.065 0.012 / 0.012 pass / pass
resize-tween-xpercent-r30-nested-z50 0.185 / 0.185 0.027 / 0.027 pass / pass
resize-tween-xpercent-r30-root-z100 0.076 / 0.076 0.012 / 0.012 pass / pass
resize-tween-xpercent-r30-root-z50 0.185 / 0.185 0.027 / 0.027 pass / pass

Smooth (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:

CPUs Base This change
8 46 27
16 118, 121, 95 108, 97, 82

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.

Worst frame Frames over 8 ms Cases dropping frames
Base 9.33 ms 7 1
Base 8.87 ms 4 1
Base 10.80 ms 31 9
This change 10.09 ms 18 0
This change 11.15 ms 34 2
This change 10.32 ms 40 17

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-origin axis, 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/core gains dist/runtime/drawnBox.js and 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, .css or .html). The tables above are the evidence.

…-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
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 273 (base branch 271), smooth 61 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Newly passing (2)

  • seqscaletwice-scale-px-r0-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)

  • seqscaletwice-scale-px-r0-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

Quarantined, measured but not gated (0)

@vanceingalls vanceingalls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 through resolveUnmeasuredResizeDraft as 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, resizeGrow is undefined and the pin falls back to half the size change. The probe restores the inline size in finally.
  • 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" and previewGestureStartRead "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 bd2f6536 is fixed at this head by the ALLOWED_DELETIONS entry for the removed test. All checks are green on 51743646, including typecheck, edit accuracy and the studio and core tests.

Per Miguel's hold this merges after 0.9.94.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 25, 2026
@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Smoothness, measured again on this head after the merge with main: the unsealed resize grid (test:edit-accuracy --grid full --filter '^resize-', 126 cases), main and this change run in turn at 16 CPUs, so that whatever else ran on the shared box fell on both.

Pair Build Accurate Smooth Frames over 8 ms of main-thread work Worst frame Cases dropping frames beyond the control
1 Main 126/126 113/126 0.30% (15/4924) 9.51 ms 1
1 This change 126/126 115/126 0.18% (9/4927) 9.31 ms 2
2 Main 126/126 86/126 0.54% (27/5036) 10.12 ms 21
2 This change 126/126 99/126 0.48% (24/5002) 9.99 ms 9
3 Main 126/126 123/126 0.06% (3/4915) 8.41 ms 0
3 This change 126/126 122/126 0.08% (4/4914) 8.25 ms 0

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.

Merged via the queue into main with commit 90f14d0 Nov 25, 2026
105 checks passed
@miguel-heygen
miguel-heygen deleted the fix/resize-one-anchor-formula branch November 25, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants