Skip to content

test(studio): the edit bench reads a nudge burst's box once a sealed preview has drawn it - #8822

Open
miguel-heygen wants to merge 3 commits into
mainfrom
fix/edit-bench-reads-drawn-nudge
Open

miguel-heygen wants to merge 3 commits into
mainfrom
fix/edit-bench-reads-drawn-nudge

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

The edit accuracy bench reads a nudge burst's box once the preview has drawn the keys, instead of right after them. In a sealed preview that read sometimes came before the draw, and seqrotatenudge-*-nested cases then failed drop and reload by 3 px against a correct saved file.

Stacked on #8809, which touches the same nudge step.

Why

With a sealed preview, seqrotatenudge-none-{center,pct,px}-r0-nested-z100 failed drop and reload at 3.02 to 3.07 px in some runs, with 2 saves and undo true. The saved file and the reloaded box were right. The box the step recorded was not: it was the box from before the nudges.

The sequence's nudge step recorded the box once, right after the keys and one frame. A sealed preview draws a nudge a frame round trip after its keys. A probe that read the box every frame after the keys, with Studio built at main 614ece8b, sealed, 24 case-runs:

  • In 9 of the 24, the step's one read came before the draw: dx 0 instead of 2.98 to 3.02 px, then the nudges showed one or two frames later, well before the save. Each of those 9 failed drop and reload at 3.02 to 3.07 px.
  • In the other 15, the first read already showed the nudges, and every one passed.

So the step's "intended" box was the un-nudged one, and drop and reload compared a correct file with it.

Related work

Refs #8809 (base of this PR).

How

  • case.mjs: shownAfterKeys(read, from, frame) reads the box until it is 0.5 px or more off from (the box before the keys) and has held for 2 more reads. After 2 s it returns whatever shows, so keys that never draw still fail the step.
  • The sequence's nudge step reads from before the keys and records intended through it. The single-nudge gesture reads its box through it, from the box it measured before the keys.
  • Not settled(): a box that hasn't been drawn yet holds still too, and a settle that restarts on the save's move would hide a save that shifts the box.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments"

fails without the fix: packages/studio/tests/e2e/edit-accuracy/saves.test.mjs "is the drawn box, not the one shown before the preview drew the keys" fails on a single read with expected [ [ +0, +0 ], …] to deeply equal [ [ 3, +0 ], …]. Dropping the "moved off from" condition fails it again. "gives up at its deadline with the undrawn box when the keys never draw, so the step still fails" fails when the deadline is cut to 200 ms.

npx vitest run tests/e2e/edit-accuracy/ in packages/studio: 13 files, 133 of 133, three runs in a row.

The bench, Studio built at main 614ece8b, this branch's bench, the 48 seqrotatenudge-*, seqnudge-*, seqab-* and nudge-* cases, pr grid, --jobs 1, the preview frame's self.origin logged in every case (null sealed):

Preview Run 1 Run 2 Run 3
sealed 48/48 48/48 48/48
unsealed 48/48 48/48 48/48

These runs are at ff3dee8c. The head (811f8e86) differs only in reading the pre-key box before the step starts its smoothness recording instead of just after.

Before this change, on the same build with #8809's bench: sealed 48/48, 48/48, 46/48, and both run-3 failures were seqrotatenudge-*-nested drop and reload 3.02 px.

Not measured: how long a sealed preview takes to draw a nudge after its keys. The probe's times include the bench's own work before each read: unsealed, which draws inside the keydown, came out the same as sealed, about 60 ms. A page-side measurement follows in a comment.

No visible change

…rst into two saves

The bench pressed each nudge key, then waited for a frame. On CI the frame after
the first nudge following a rotate can take 400+ ms (GPU-side), longer than
Studio's 400 ms burst window, so the burst saved twice and the undo walk came
up one short. The keys of a burst now go back to back through one helper.
…preview has drawn it

A sealed preview draws a nudge a frame round trip after its keys. The bench read
the box once, right after the keys, and in some runs that read came before the
draw: the un-nudged box became the step's intended box, and drop and reload
scored 3 px against a correct file.
@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

The sealed draw delay the body lists as not measured. Time from the last nudge keydown to the first sampled frame showing the burst, both read on Studio's page clock. A sealed frame is read through the bench's own port into it. Studio built at main 614ece8b, the 12 seqrotatenudge-* and seqnudge-* cases, --jobs 1:

Preview Run Median Max Bursts drawn
sealed 1 26.8 ms 68.2 ms 12/12
sealed 2 26.4 ms 29.3 ms 12/12
sealed 3 26.7 ms 28.1 ms 12/12
unsealed 1 7.9 ms 11.9 ms 12/12
unsealed 2 10.0 ms 29.7 ms 12/12
unsealed 3 9.4 ms 14.9 ms 12/12

A sealed preview shows a nudge about one frame later than an unsealed one. The sampler takes one sample per frame, so each figure can be off by up to a frame. This is reported here, not changed: the bench now waits for the draw, and the delay itself is a separate Studio timing question.

jrusso1020
jrusso1020 previously approved these changes Nov 25, 2026

@jrusso1020 jrusso1020 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.

Verdict: APPROVE at 811f8e86ed9edb7858842771823c319eb3be8f46.

The cause and the fix match. The nudge step recorded intended from one read right after the keys and a single frame. A sealed preview draws a nudge one frame round trip after its keys, so that read could still show the box from before the keys. Drop-and-reload then compared a correct saved file against the un-nudged box.

  • shownAfterKeys(read, from, frame) reads until the box is ≥ 0.5 px off from and has held (< 0.01 px) for two more reads.
  • After 2 s it returns whatever is showing, so keys that never draw still fail the step.
  • Both the sequence's nudge step and the single-nudge gesture now take the box before the keys and read through it.
  • Not reusing settled() is the right call: an undrawn box also holds still.

The new tests use fake timers. The "fails without the fix:" line names the drawn-box test, and the deadline test pins the 2 s give-up. The diff is against its base #8809 (bench code and tests only). The checks that ran on this stacked base are green.

Non-blocking: waiting up to 2 s for the draw means the bench no longer notices a sealed preview that is slow to draw a nudge, as long as it draws within that window. Logging the time from keys to drawn box per case would keep that visible.

Need · Size · Reuse · Simpler · Structure: removes a measured bench false-fail (9 of 24 sealed runs) · +70/−3, bench only · reuses measure, nextFrame and quadDistance · ok · ok
Risk: low. Test bench only.

— Rames

Base automatically changed from fix/edit-bench-nudge-keys-one-burst to main November 25, 2026 09:23
@miguel-heygen
miguel-heygen dismissed jrusso1020’s stale review November 25, 2026 09:23

The base branch was changed.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 273 (base branch 271), smooth 53 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)

# Conflicts:
#	packages/studio/tests/e2e/edit-accuracy/case.mjs
#	packages/studio/tests/e2e/edit-accuracy/saves.test.mjs

This branch has not been deployed

No deployments
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