Skip to content

perf(cli): check's craft pass skips clips the runtime has hidden - #6627

Merged
miguel-heygen merged 1 commit into
mainfrom
fix/craft-skips-hidden-clips
Oct 28, 2026
Merged

miguel-heygen merged 1 commit into
mainfrom
fix/craft-skips-hidden-clips

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

What

hyperframes check's craft pass no longer walks clips the runtime has hidden. Each craft sample read every element in the composition, on-screen or not, twice: once for its text parts and once for the composition signature. On a long edit with many timed clips that cost grows with the whole timeline at every sample (up to 600 per check).

Why

A long edit's check spent most of its time in the craft pass: one long-form edit took 87 s of craft, about 190 ms per sample, and agents gave up waiting. Profiling a 60 s composition with 120 timed clips and 3,600 text elements put two thirds of each sample in compositionSignature and most of the rest in craftTextParts, almost all of it reading styles of elements inside clips that were not on screen.

Related work

The overlap pass already bounds its work this way (elementsOnScreenScenes in layout-audit.browser.js).

How

  • craftTextParts walks elementsOnScreenScenes(root) instead of every element.
  • compositionSignature treats a [data-hf-clip-hidden] clip like an element with no box: it and its subtree are skipped before any style is read. The composition root is always measured.

Both rely on core's timedClipHide rule, which hides a marked clip's whole subtree. What a hidden clip would add to the signature was already filtered out as not visible, so the signature and text parts are unchanged; only the work shrinks.

Test plan

fails without the fix: layout-audit.chromium.test.ts "reads no style inside a clip the runtime hid, and still reads the text on screen": with main's two browser scripts it fails (expected 4 to be +0, four style reads inside the hidden clip); with this change it passes.

Timings, hyperframes check --json 0.8.210 with the two browser scripts patched in place, Linux, 60 s composition with 120 timed clips (one on screen at a time), 480 craft samples, craft pass only:

composition before after
120 clips + 3,600 text elements 22.1 s 3.5 s
120 clips + 1,200 text elements 8.1 s 2.0 s
120 clips, no text 1.7 s 2.0 s (noise)
  • vitest --project chrome over layout-audit.chromium, motion-sample, motion-signature: 148/148, three runs in a row.

  • vitest --project unit over src/commands/motion*, src/commands/layout-audit*, src/utils/check*: 180/180, three runs in a row.

  • oxfmt, oxlint and fallow audit are clean on the changed files.

  • Unit tests added/updated

  • Manual testing performed

  • Documentation updated (if applicable)

  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

Not exercised: a real long-form edit end to end, and video-heavy edits beyond the timing above (video adds its own per-seek cost that this does not touch).

Why under 100 lines

Small on purpose: a lone urgent fix for checks that go silent for minutes on long edits. Both walks switch to the on-screen walk the overlap pass already uses, plus one test that fails without it; nothing else rides along.

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

Verdict: APPROVE · 0 blocker · 0 important · 0 nits · d2aacd2e

Core's [data-hf-clip-hidden][data-hf-clip-hidden] * rule (timedClipHide.ts) sets visibility: hidden !important on everything inside a hidden clip, so neither the craft parts nor the signature lose anything they would have kept. The fails without the fix: test fails on main's scripts (expected 4 to be +0) and passes at head, along with the rest of layout-audit and motion-signature (140/140). Every Actions run at this head is green.

Scope

Read all 3 files and core's timedClipHide.ts and clipReveal.ts. One edge, outside this PR: when an older shader build is on the page, keepInlineHideRulesForOlderShaders narrows the rule to clips whose inline style still says hidden. A clip such a build reveals keeps the attribute while its contents show. The overlap pass already skips those clips, so this PR makes the craft pass consistent with it.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit 815ff9e Oct 28, 2026
113 checks passed
@miguel-heygen
miguel-heygen deleted the fix/craft-skips-hidden-clips branch October 28, 2026 06:45
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.

1 participant