Repository navigation
fix(studio): the edit bench reads a sealed preview through its editing port - #8010
Conversation
793ba9e to
acde455
Compare
…release or the next drag
…he pointer at that moment
…lement by time, not arrival
…easured the element
acde455 to
37b8e38
Compare
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 37b8e38. No blockers.
Scope: three bench files under studio/tests/e2e/edit-accuracy/ (teleport.mjs, sequences.mjs, teleport.test.mjs). No shipped code changes.
No new port surface: the bench only uses request kinds that already exist (query, watch-geometry, computed-styles) through the existing editingAgent parsers, and core's isGeometry already checks the geometry replies. There are no bench-only port requests to gate. The bench's request ids start at 1e9, so they can't collide with Studio's.
Measurement: for unsealed previews the bench measures the same thing as before. Only the read path changes: geometry now arrives as port pushes, each paired with the pointer by its own timestamp. The gate job at head reports "accurate 267 (base branch 267)", which matches the body.
Verified:
- All 13 edit-accuracy test files pass, 116/116.
- With main's
teleport.mjsunder this PR's tests, 8 of 29 fail. That's one more than the body's "7", but the count is only cosmetic. - CI: 0 failed, cancelled or pending. All 15 edit-accuracy shards and the gate are green.
Nit (non-blocking): watches are tracked per port. If Studio ever watches geometry on its own port, the bench's rec.unwatch() in stopFrames would silently replace that watch. A comment there would help.
Need from author: nothing.
— Rames
What
The edit-accuracy bench's frame sampler reads the dragged element through the preview's editing port, not by reaching into the preview frame's document. With Studio's opaque-origin preview on (
VITE_STUDIO_OPAQUE_PREVIEW_ENABLED=true), the bench can measure teleport again.Why
The sampler found the element by reading
contentWindow.locationanddocumentof each preview frame. An opaque-origin preview refuses those reads, so every frame was dropped, the sampler found no element, and teleport failed on every case, whatever Studio actually drew. The wait for a manual-edit gesture to finish (sequences.mjs) read the same document, so on an opaque preview it passed without waiting.How
This builds on #8052, which adds the
watch-geometryrequest: a preview pushes the named elements' geometry once per frame, measured in its ResizeObserver step (just before paint) and stamped withperformance.timeOrigin + performance.now().teleport.mjs: the page script opens an editing port of its own to each preview frame (the sameediting-connecthandshakecreateEditingPortClientuses). It asksqueryfor the element and the composition root once, thenwatch-geometryfor both. Every push becomes one sample, paired by its own stamp with what this page showed at that moment. The top page keeps two short histories on the same clock: the pointer (from its pointer events), and Studio's crop and press-waiting outlines (read each frame). A late push is never scored against a later pointer or a later outline, which is the pairing the direct read gets for free by reading both in one paint.computed-styles, the latest reply. It only scales clip-path insets, and every sequence case passes with it.addEventListener, leavesonmessagealone, and starts its request ids at 1e9.sequences.mjs: the manual-edit wait asks each preview over the port; a preview that cannot answer yet counts as not clear.createEditingPortClient(it is a string run throughevaluateOnNewDocument), so it keeps a small client of its own.Test plan
fails without the fix:
teleport.test.mjs. On main'steleport.mjs, 7 of its tests fail, starting with "measures the element from the preview's pushes, in top-frame px, and Studio keeps the shared port". The test preview'sdocumentandlocationthrow, as a cross-origin frame's do, and it answers only over a realMessageChannel. On this branch, all 29 tests pass 3 runs in a row.Each rule, removed from
teleport.mjsone at a time, fails a test:All 13 edit-accuracy unit test files pass.
oxfmtandoxlintare clean.Bench, every
cropcase atr0-root-z100(24 cases), unsealed: tracking and teleport 24/24 in each of 3 runs. Without the measured-frame wait, 2 or 3 of 4 cases failed by one 2 px pointer step, where main's harness passed 4/4 in 3 runs on the same build.Bench, every sequence case (
--grid pr --filter '^seq', 73 cases), unsealed build, against main's harness on the same build:undo is 73/73 on both in this run.
undo: the
seqplainkeyscases fail undo now and then on both harnesses on the same build. The undo itself lands with the right bytes, but the box read just after it is about 240-312 px off. Across the other runs, main's harness failed it in 1 of 2 and this branch in 2 of 4. That flake predates this change and gets its own fix.Sealed build (
VITE_STUDIO_OPAQUE_PREVIEW_ENABLED=true), one build at this PR's base, the 32 cases of theseqresize,seqab,sequndo,seqheldtwice,seqplainkeysandseqinflightsequences. Each harness ran twice:Main's harness can't measure teleport on a sealed preview at all. Every other check reads the element through Playwright's element handles, which this PR doesn't change; they vary by a case or two between runs on both harnesses. Each case where this branch fails teleport, next to the handle-read checks that fail in the same case:
seqheldtwice-tlhold-px-r0-nested-z100seqheldtwice-tlhold-px-r0-root-z100seqplainkeys-none-center-r0-nested-z100seqplainkeys-none-center-r0-root-z100seqplainkeys-none-pct-r0-nested-z100seqplainkeys-none-pct-r0-root-z100seqplainkeys-none-px-r0-nested-z100seqplainkeys-none-px-r0-root-z100seqresize-none-center-r0-root-z100seqresize-none-pct-r0-nested-z100seqresize-none-px-r0-root-z100sequndo-none-center-r0-nested-z100sequndo-none-center-r0-root-z100sequndo-none-pct-r0-nested-z100sequndo-none-pct-r0-root-z100sequndo-none-px-r0-nested-z100sequndo-none-px-r0-root-z100Every teleport failure here falls in a case and run where the branch's own handle reads also fail, so none of them is the sampler's alone. Those failures happen on main's harness too, on the sealed build only (every sequence case passes unsealed):
seqheldtwice, drop, reload and undo fail.Those are separate fixes in Studio's sealed preview, not this PR's.