Skip to content

fix(studio): a sealed drag's outline moves in the same frame as the layer - #8962

Open
miguel-heygen wants to merge 7 commits into
fix/sealed-drag-chrome-in-framefrom
fix/sealed-drag-chrome-studio
Open

miguel-heygen wants to merge 7 commits into
fix/sealed-drag-chrome-in-framefrom
fix/sealed-drag-chrome-studio

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

On a sealed preview, the selection outline now moves in the same frame as the layer you drag. Studio hands its outline to the frame for the length of the drag, keeps only the part that lies outside the frame, and takes it back on release.

Stacked on #8961 (the frame side). Review that one first.

Why

In stock Chrome a sealed preview renders out of process, so Studio's outline and the dragged layer are two compositor surfaces shown independently. Since #8912 the layer's step reaches the frame before Studio's next frame, so the outline shows the step before. On the 4x CPU bench, outline minus layer sits at +0.68 to +1.09 steps per drag sealed and 0.00 open. Only an outline the frame paints in the same turn as the layer can share its compositor frame.

Related work

Refs #8909, #8919, #8921, #8931, #8912.

How

  • frameDragChrome.ts (new): paintChromeInFrameWhile(iframe, overlay, held) starts with a sealed drag's raw steps. With the first draft it sends a copy of Studio's chrome as structured data: tag (div, span, svg, path), the computed look, SVG geometry attributes. With every later draft it sends only each node's inline placement. The copy is checked with the core's own parseDragChrome before it rides a request, so a copy the frame would refuse never takes the drafts down with it, and Studio simply keeps its whole chrome.
  • Once the frame answers a request that carried the copy, Studio clips its chrome plane to everything outside the frame's rect (clip-path: path(evenodd, ...)), so the part over the stage is painted only by the frame. The part outside the stage (handles past the edge, the box when the layer hangs off stage) stays Studio's.
  • On release Studio removes the clip first, then sends a chrome-only clear on the next animation frame, so the outline never blinks. A later drag's chrome is not cleared by an earlier release.
  • previewDrafts.ts: the draft queue carries the chrome on each request it already sends (microtask-batched, one in flight). No extra message per step.
  • gestureSteps.ts: the raw step now moves Studio's outline (single box, and group members plus group box) before the draft goes out, so the frame copies this step's outline, not the last one.
  • DomEditSelectionChrome.tsx: the selection and group chrome render inside one plane element (data-dom-edit-chrome-plane) that the clip applies to.
  • Studio keeps pointer capture and the edit itself. The frame's copy is paint only (pointer-events: none), and saves, history, captures and stage reads never see it (see the core PR).

Not covered here:

  • The frame's place in the overlay is read once per drag; a zoom or scroll mid-drag is not followed.
  • A frame reload mid-drag shows no in-frame outline until release; Studio's own outline is back at release.
  • Rotate keeps its existing angle lag.

Test plan

Proof: 4x bench pending. The close bar: outline minus layer at most 0.1 per drag sealed, and pooled outline vs pointer no worse than open, at 4x CPU; the off-stage part's lag measured on its own. Numbers and Before/After captures land here when the run is done.

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

fails without the fix:

  • frameDragChrome.test.ts "is painted by the frame with each draft at that step's place, and Studio keeps only what is outside" (sealed frame with the real agent) fails with carryPreviewDraftChrome removed, with the clip removed, and with the release clear removed.
  • "is left to Studio when the frame would refuse the copy, and the drafts still land" fails with the parseDragChrome check removed.
  • "of a later drag stays when an earlier drag's release clears the frame" fails with the current-carrier check removed from endPreviewDraftChrome.
  • sealedRawDragStep.test.ts raw-step outline cases fail with the outline writes removed from drawGestureStep and the group raw step.

On current main: packages/studio editor and player folders 5087 passed; the touched test files 3 runs in a row; tsc --noEmit, oxlint, oxfmt, fallow clean.

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Give the outline back to Studio if a later chrome copy fails validation (packages/studio/src/components/editor/frameDragChrome.ts:154). After a successful mounted draft, Studio clips out the part over the frame. If a later DOM copy exceeds the wire limit, read() omits chrome, so the layer still moves but the frame keeps painting the old outline and Studio stays clipped. I reproduced this by starting a sealed drag, waiting for the clip, then growing the chrome tree past the limit before the next draft. Restore the full Studio outline and clear the old frame copy on this transition while allowing the draft through.

All 21 focused tests passed. The added stand-in case reproduced the stale outline. The PR body still lists the 4× compositor benchmark as pending, so the measured parity claim is unverified.

— tai (automated review)

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Fixed in e9b288d0: an over-cap copy after a shown one now hands the outline back to Studio.

  • In frameDragChrome.ts read(): when the copy would be refused and the frame holds an earlier copy, Studio removes its clip and the request carries chrome: null. The drafts still go out in the same request, and the frame clears its copy in that turn. If the copy shrinks under the cap again, the next request sends a fresh copy and the clip returns once the frame has painted it.
  • New test in frameDragChrome.test.ts: "goes back to Studio when a later copy would be refused, and the drafts still land". It starts a sealed drag, waits for the clip, grows the chrome to 70 nodes, then moves. It then checks that the request carries null, the layer moves, the frame host is gone and the clip is removed. Before the fix it fails with expected undefined to be null. It passed 3 runs in a row, and the touched Studio test files pass 60/60.

The 4x bench proof is still pending. It will come as a comment here.

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