Skip to content

@remotion/studio: Selection outline respects transforms#7844

Merged
JonnyBurger merged 3 commits into
mainfrom
fix/selection-outline-transform-7832
May 31, 2026
Merged

@remotion/studio: Selection outline respects transforms#7844
JonnyBurger merged 3 commits into
mainfrom
fix/selection-outline-transform-7832

Conversation

@JonnyBurger
Copy link
Copy Markdown
Member

@JonnyBurger JonnyBurger commented May 30, 2026

Fixes #7832

What

Selection outlines in Studio now follow CSS transforms (rotation, translate, scale, etc.) on the selected element instead of drawing an axis-aligned bounding box.

How

  • Added getBoxQuadsPonyfill() that uses native getBoxQuads() when available, otherwise geometry adapted from getBoxQuadsPolyfill (MIT) as a ponyfill (no global monkey-patching).
  • SelectedOutlineOverlay measures the selected refForOutline target’s border box as a DOMQuad relative to the overlay SVG and renders a <polygon>.
  • Falls back to axis-aligned getBoundingClientRect() when quad calculation fails.

Tradeoffs

  • Adds ~2.4k lines of adapted ponyfill internals to @remotion/studio for Chromium, where getBoxQuads() is unavailable. Scope is limited to selected outline measurement (not all timeline sequences).
  • Layout reads (getBoundingClientRect, offsetWidth, computed style, etc.) run on each animation frame for selected items, but avoid DOM mutation like web-renderer’s transform-stripping approach.
  • SVG/text/multi-fragment/3D/perspective cases are best-effort via the ponyfill; unsupported cases use the axis-aligned fallback.

Test plan

  • Open the centered-solid composition in Studio
  • Select the <Solid> sequence on the timeline
  • Confirm the blue outline is rotated with the element (not axis-aligned)
  • Zoom/pan the preview and confirm the outline stays aligned
  • Select a non-transformed sequence and confirm the outline still looks correct
  • Select multiple sequences and confirm each outline renders

Use a getBoxQuads ponyfill for Chromium so rotated and translated
elements show a correct quad outline instead of an axis-aligned box.

Fixes #7832

Co-authored-by: Cursor <cursoragent@cursor.com>
@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog Bot commented May 30, 2026

Pullfrog stalled

The agent stopped emitting events for 304s and was killed by the activity-timeout watchdog. 154 events were processed before the failure.

Recent agent stderr
INFO  2026-05-30T10:31:53 +1ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +0ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +0ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +0ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +0ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +1ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +273ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +14ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +1ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +1ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +0ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +1ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +0ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +0ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +0ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:53 +0ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:54 +742ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:54 +2ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:54 +0ms service=bus type=message.part.delta publishing
INFO  2026-05-30T10:31:54 +8ms service=bus type=message.part.updated publishing

Pullfrog  | Rerun failed job ➔View workflow run | via Pullfrog | Using Kimi K2𝕏

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bugs Ready Ready Preview, Comment May 30, 2026 11:57am
remotion Ready Ready Preview, Comment May 30, 2026 11:57am

Request Review

@JonnyBurger JonnyBurger changed the title @remotion/studio: Selection outline should respect transform @remotion/studio: Selection outline respects transforms May 30, 2026
@JonnyBurger JonnyBurger marked this pull request as ready for review May 30, 2026 10:26
Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — the PR replaces the custom transform-based outline calculation in @remotion/studio with a getBoxQuads ponyfill so selection outlines correctly follow CSS transforms.

  • Replace manual outline quad calculation with getBoxQuads ponyfill — removes custom transform parsing and projection in SelectedOutlineOverlay.tsx in favor of an adapted MIT-licensed ponyfill.
  • Add get-box-quads-polyfill-internals.js — ~3k line adaptation from jogibear9988/getBoxQuadsPolyfill with 14 documented performance fixes.
  • Add getBoxQuadsPonyfill wrapper — uses native API when available, falls back to ponyfill, and silently falls back to axis-aligned bounding box on error.
  • Update CenteredSolid example — adds 3D transforms and starburst effect for manual testing.
  • tsconfig.json — enables allowJs to import the ponyfill .js module.

ℹ️ Ponyfill fork maintenance

The get-box-quads-polyfill-internals.js file (3k+ lines) is effectively a long-term fork of an actively maintained upstream library. Consider recording the exact upstream commit hash in the file header alongside the repository URL so future maintainers can diff against upstream bug fixes.

ℹ️ Nitpicks

  • packages/studio/src/helpers/get-box-quads-polyfill-internals.js exports addPolyfill, which patches window.__getBoxQuadsPolyfillFns and Node.prototype. The file header claims "does not patch globals", but this exported function contradicts that. Removing the unused export or updating the header comment would keep them aligned.

Pullfrog  | View workflow run | Using Kimi K2𝕏

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — the PR replaces the custom transform-based outline calculation in @remotion/studio with a getBoxQuads ponyfill so selection outlines correctly follow CSS transforms.

  • Replace manual outline quad calculation with getBoxQuads ponyfill — removes custom transform parsing and projection in SelectedOutlineOverlay.tsx in favor of an adapted MIT-licensed ponyfill.
  • Add get-box-quads-polyfill-internals.js — ~3k line adaptation from jogibear9988/getBoxQuadsPolyfill with 14 documented performance fixes.
  • Add getBoxQuadsPonyfill wrapper — uses native API when available, falls back to ponyfill, and silently falls back to axis-aligned bounding box on error.
  • Update CenteredSolid example — adds 3D transforms and starburst effect for manual testing.
  • tsconfig.json — enables allowJs to import the ponyfill .js module.

ℹ️ Ponyfill fork maintenance

The get-box-quads-polyfill-internals.js file (3k+ lines) is effectively a long-term fork of an actively maintained upstream library. Consider recording the exact upstream commit hash in the file header alongside the repository URL so future maintainers can diff against upstream bug fixes.

ℹ️ Nitpicks

  • packages/studio/src/helpers/get-box-quads-polyfill-internals.js exports addPolyfill, which patches window.__getBoxQuadsPolyfillFns and Node.prototype. The file header claims "does not patch globals", but this exported function contradicts that. Removing the unused export or updating the header comment would keep them aligned.

Pullfrog  | View workflow run | Using Kimi K2𝕏

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JonnyBurger JonnyBurger merged commit 7b6bd59 into main May 31, 2026
18 checks passed
@JonnyBurger JonnyBurger deleted the fix/selection-outline-transform-7832 branch May 31, 2026 10:26
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.

Selection outline should respect transform

1 participant