Skip to content

fix(core): root-cause id-less media wash in timingCompiler getAttr, drop the band-aid#1792

Merged
miguel-heygen merged 4 commits into
mainfrom
fix/media-id-getattr-root-cause
Jun 30, 2026
Merged

fix(core): root-cause id-less media wash in timingCompiler getAttr, drop the band-aid#1792
miguel-heygen merged 4 commits into
mainfrom
fix/media-id-getattr-root-cause

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

Follow-up to #1790. That PR fixed the blank-wash/dropped-audio symptom with a producer-side band-aid (assignMissingMediaIds). This fixes the actual root cause and removes the band-aid.

Root cause

timingCompiler.ts getAttr built its regex with no name boundary at all:

tag.match(new RegExp(`${attr}=["']([^"']+)["']`))

So getAttr(tag, "id") matched the trailing id="…" inside data-hf-id="…" and returned a phantom. compileTag saw a "present" id and skipped its existing hf-video-N/hf-audio-N injection, leaving the element with no real el.id — which every render stage keys off (__render_frame_<id>__, runtime frame-swap, audio[id][src]). Hence the blank wash + dropped audio. Same bug family as the lint readAttr \b issue fixed in #1790.

Change

  • getAttr(?<![\w-]) lookbehind (one line). compileTag's auto-id injection now fires for data-hf-id-only media, in both the main composition and sub-compositions (parseSubCompositions runs the same compileTimingAttrs pass).
  • Delete assignMissingMediaIds — redundant once the root is fixed (net −4 lines).
  • Tests: timingCompiler unit tests for the video + audio id-injection boundary; regression fixture baseline regenerated on linux/amd64 (now hf-video-0 from compileTag).

Review findings (from post-merge review of #1790)

  • 🟠 Twin getAttr boundary bug → fixed at root; band-aid removed.
  • 🟡 Audio side untested → covered by a deterministic timingCompiler unit test (id-less <audio>hf-audio-N). The render fixture stays video-only: a synthetic sine/noise audio track anti-aligns under the harness audio cross-correlation (deterministic −1.0); real audio content is unaffected, so a brittle audio render-baseline wasn't worth it.
  • 🟡 Observability → intentionally not added: the band-aid is gone, compileTag auto-id is long-standing intended behavior, and the loud signal is the (now-fixed) media_missing_id lint rule.
  • 🟡 studio_missing_editable_id warning still fires for id-less media — correct and unchanged; a real id remains the contract for Studio targeting / GSAP selectors. The compiler auto-id is a render safety net, not a license to omit id.

…d-aid

The blank-wash/dropped-audio fix in #1790 added assignMissingMediaIds in the
producer to stamp ids onto id-less timed media. That was a band-aid: the real
cause is timingCompiler's getAttr, whose regex had no name boundary at all, so
getAttr(tag, "id") matched the trailing id="…" inside data-hf-id="…". compileTag
saw a phantom id and skipped its existing hf-video-N/hf-audio-N injection,
leaving the element with no real el.id — which the render pipeline keys off of.

Fix getAttr with the same (?<![\w-]) lookbehind used for the lint readAttr fix.
compileTag's auto-id injection now fires for data-hf-id-only media, in both the
main composition and sub-compositions (parseSubCompositions runs the same
compileTimingAttrs pass), so assignMissingMediaIds is removed entirely.

Extends the regression fixture with a standalone id-less <audio> (the dropped-
audio side, previously untested) and raises minAudioCorrelation to 0.9. Adds a
timingCompiler test for the data-hf-id/id boundary.
…udio

A continuous sine anti-aligns under the audio cross-correlation (correlation
-1.0 from a sub-period offset). Broadband seeded noise correlates robustly.
…e video-only

The audio render-baseline used synthetic sine/noise, which anti-aligns under
the harness audio cross-correlation (deterministic -1.0). Real audio fixtures
are unaffected. Cover the audio side of the boundary fix with a deterministic
timingCompiler unit test (id-less <audio> gets hf-audio-N) instead, and keep
the render fixture video-only.
@miguel-heygen miguel-heygen merged commit 0dfedd1 into main Jun 30, 2026
46 checks passed
@miguel-heygen miguel-heygen deleted the fix/media-id-getattr-root-cause branch June 30, 2026 02:07
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