Skip to content

fix(core): a film without a declared size reports its measured size to a sealed Studio - #8578

Merged
miguel-heygen merged 5 commits into
mainfrom
fix/sealed-measured-root-size
Nov 23, 2026
Merged

miguel-heygen merged 5 commits into
mainfrom
fix/sealed-measured-root-size

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

What

On a sealed preview of a film whose root declares no data-width and data-height, Studio now draws the selection box and accepts drags and arrow-key nudges. Before, nothing showed: no selection or hover box, a press fell back to the drawn rect, and nudges were dropped without a word, for as long as the film was open. Unsealed, the same film works because Studio measures the root.

A press or nudge that comes before the frame's size arrives on any film now waits for it, up to the press's existing wait, instead of giving up. If the frame still hasn't answered after that wait, the press or nudge says so with the notice a blocked move already uses, instead of doing nothing:

  • the frame posted its timeline but never a size (a root at 0x0, or not laid out): "This composition has no size, so Studio can't move its layers. Give its root a width and height.";
  • otherwise: "The preview didn't answer, so Studio can't move this layer. Try again."

Why

Studio scales its overlay by the film's size. Unsealed, computeOverlayRootScale reads the root's declared size or measures its box. Sealed, Studio can't reach the frame's document, so it uses the size the runtime posts (previewStageSize). The runtime posted stage-size only for a declared size (postTimeline in init.ts), so a root that declared none never had one sealed.

Related work

Refs #7846 (Studio's preview sealed by default).

How

  • Runtime (init.ts): for a root that declares no size, stage-size carries measuredSize, the root's layout box (offsetWidth/offsetHeight, so a GSAP transform on the root doesn't skew it). It's posted with every timeline post and again when a ResizeObserver sees the root change; teardown disconnects it. A declared root's message is unchanged.
  • Own field, not width/height: the player and Studio's useCompositionDimensions size the iframe from width/height, and a measured root follows the iframe, so feeding it back would loop. They read only width/height, so they skip a measuredSize message as they are, and a new runtime beside an older player changes nothing. The protocol only grows.
  • Studio (bridgePlayback.ts): the frame mirror behind previewStageSize takes measuredSize when there's no declared size.
  • Studio (previewGestureStartRead.ts): askShownGestureStarts, the read every sealed press and nudge goes through, waits for the frame's size (whenPreviewStageSized) for up to PRESS_WAIT_MAX_MS, now defined there and re-exported from previewGestureStarts.ts. An older runtime that never sends a size still gives up after that wait, but now says so.
  • Studio (previewGestureStarts.ts, useDomEditNudge.ts): when that read comes back unanswered and there's no drawn box to start from, the press and the nudge call onBlockedMoveRef, the one blocked-move notice. unansweredMoveReason picks the message: the frame mirror records that the runtime posted its timeline, so a frame that answered without a size is told apart from one that never answered.

No visible change

On a sealed preview of a film without a declared size, the selection box shows and moves work as they do unsealed. The interface itself doesn't change.

Test plan

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

fails without the fix:

  • packages/core/src/runtime/init.test.ts: "posts its measured layout box as measuredSize, with no width or height a host would size by", "posts the box again when the root resizes, and stops at teardown";
  • packages/studio/src/components/editor/previewGestureStartRead.test.ts: "scales the overlay by the root's measured box, as the unsealed overlay measures the root", "waits for the frame's size before reading a press, instead of giving up", "tells a frame that answered without a size from one that never answered";
  • packages/studio/src/components/editor/previewOverlayRects.test.ts: "says the preview didn't answer when it never does and no box was drawn";
  • packages/studio/src/components/editor/useDomEditNudge.sealed.test.tsx: "says the preview didn't answer when a sealed nudge's read never does".

"leaves measuredSize off a root that declares its size" (init.test.ts) and "leaves the frame's size alone for a root's measured box, which follows the frame" (packages/player/src/runtime-message-handler.test.ts) pass on main too. They pin that a declared root's message and today's player don't change.

  • With the fix, those rows and their files pass three runs in a row on Linux. Studio's src/components/editor and src/player (402 files, 4,880 tests) pass and typecheck clean at the latest commit.
  • Core src/runtime (164 files, 3,601 tests), player (20 files, 639 tests), Studio (833 files, 9,415 tests), producer unit (1,540 tests) and engine (218 files, 3,640 tests) pass. Core, Studio and player typecheck clean.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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

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

Quarantined, measured but not gated (0)

Unstable (1)

  • seqplainkeys-none-px-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

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

Compared the head against #8588's merge (2cc423b): pressOutline.ts is byte-identical, and the poll still replays the press and then ends the outline's draw wait (replay(false) returns false immediately), with the new "why it didn't start" notice only when no replay starts. So #8588's behaviour is kept. The new measuredSize field is ignored by the player and useCompositionDimensions, which require finite width/height. Fix-line tests cover the runtime post, the size wait and the unanswered notice. Approving.

Non-blocking: a root that stays 0x0 (or an older runtime) makes every press and nudge wait the full 10 s before the notice; a shorter wait once the timeline is known to have posted without a size would be kinder. Conflicts with #8596 in previewOverlayRects.test.ts; second to merge rebases.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 19f98a3 Nov 23, 2026
101 checks passed
@miguel-heygen
miguel-heygen deleted the fix/sealed-measured-root-size branch November 23, 2026 20:18
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