Skip to content

fix(adapter-hyperframes): inject Hyperframes runtime before page.goto() so data-composition-src templates render#18

Open
249469326i-lang wants to merge 1 commit into
nexu-io:mainfrom
249469326i-lang:fix/composition-src-runtime-injection
Open

fix(adapter-hyperframes): inject Hyperframes runtime before page.goto() so data-composition-src templates render#18
249469326i-lang wants to merge 1 commit into
nexu-io:mainfrom
249469326i-lang:fix/composition-src-runtime-injection

Conversation

@249469326i-lang

Copy link
Copy Markdown
Contributor

Summary

Fixes #16 — 10 of 21 shipped templates use data-composition-src to load content from compositions/*.html. This attribute requires the Hyperframes runtime to be injected before page load. Without it, the resulting MP4 is completely blank/white.

Changes

  • Resolve Hyperframes runtime path via createRequire (ESM-safe, since hyperframes is a CJS peer dep)
  • Inject runtime via page.addInitScript({ path }) before page.goto()
  • Graceful fallback: if hyperframes is not installed, inline-only templates still render correctly
  • Update file header comment to reflect the runtime injection step

Affected templates (verified via grep)

frame-decision-tree frame-nyt-graph frame-kinetic-type frame-swiss-grid
frame-play-mode frame-vignelli frame-warm-grain frame-product-promo
frame-product-promo-30s frame-liquid-bg-hero

Verification

  • tsc -p packages/adapter-hyperframes/tsconfig.json --noEmit passes ✅
  • Existing inline templates (frame-bold-signal, etc.) are unaffected

Testing

Hyperframes is an optional peer dep — users who have it installed will get the runtime injected; users who don't will continue to render inline templates as before.

Templates using data-composition-src (10 of 21) render blank MP4 because
the Hyperframes runtime that interprets the attribute is never injected.

- Resolve hyperframes/dist/hyperframe-runtime.js via createRequire
- Inject via page.addInitScript() before page.goto()
- Graceful fallback when hyperframes peer dep is not installed
- Update file header comment to reflect runtime injection step

Fixes nexu-io#16
@lefarcen

lefarcen commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Thanks @522700967-wq for doing the end-to-end verification and writing it up so concretely.

The file:// fetch failure does look like the current blocker on this head, and your note makes the remaining gap much clearer: injecting the Hyperframes runtime is the right prerequisite, but render still needs an HTTP-served path (or equivalent inlining of the referenced compositions) for data-composition-src templates to resolve during recording.

@249469326i-lang, please take that path into the next revision together with the regression check around a data-composition-src template. Once that lands, we can re-check this branch.

@249469326i-lang

Copy link
Copy Markdown
Contributor Author

Thanks for taking a look and requesting review. I’m happy to adjust the implementation if needed.

For context, this PR fixes the blank MP4 output for templates using data-composition-src by injecting the Hyperframes runtime before page.goto(). I also verified that tsc -p packages/adapter-hyperframes/tsconfig.json --noEmit passes and inline-only templates remain unaffected.

@lefarcen

lefarcen commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for the clarification, @249469326i-lang.

At this point I wouldn't ask you to keep iterating on this branch: the broader fix has already landed on main in #22, which is why this PR now shows up as DIRTY and effectively superseded from the maintainer side.

So there’s nothing more you need to adjust here unless you want to open a fresh follow-up for something that #22 still misses. For this branch specifically, we’ll treat it as overtaken by the merged fix.

@249469326i-lang

Copy link
Copy Markdown
Contributor Author

Thanks for the clarification and for taking the time to review this PR.

I’m glad the issue has been addressed by the broader fix in #22. I appreciate the feedback and will keep an eye out for any remaining gaps where I can contribute in the future.

Thanks again!

HycJack pushed a commit to HycJack/html-video that referenced this pull request Jun 8, 2026
…-end

Add @html-video/adapter-remotion, the first cross-paradigm backend after
hyperframes: deterministic frame-by-frame rendering via @remotion/renderer,
bridging existing HTML/CSS/GSAP frames onto Remotion's frame clock through an
iframe-srcdoc time-driver. Peer deps are optional — the CLI registers the
engine only when Remotion is installed, so a bare checkout never lists an
engine that would throw.

The adapter was written but unverified; end-to-end render testing surfaced two
stacked bugs that produced all-black output (DOM correct, pixels 0,0,0):

1. Seek timing — HtmlFrameDriver opened a single delayRender on mount, so only
   the first frame was synced; later frames screenshotted before the async
   re-seek landed. Fixed with a per-frame delayRender, a tightened ready check
   (require registered animations / non-empty body, not just readyState), and a
   rAF settle before continueRender.

2. Render-blocking external resources — a template's <link rel=stylesheet> to
   Google Fonts kept the srcdoc iframe from painting in headless chromium and
   never resolved, so Remotion captured black frames. neutralizeBlockingResources
   converts blocking external stylesheets to non-blocking async loads
   (media="print" + onload swap); fonts apply if they arrive, CSS fallback
   renders otherwise, paint is never blocked. (Same family as the file:// fetch
   issue in nexu-io#16/nexu-io#18.)

Verified by rendering real templates and measuring pixels (ImageMagick): the
animation template frame-bold-signal now renders at ~15→23% luminance matching
the hyperframes control's 24.8% (was 0% black across the whole clip); three
further diverse templates render non-black. Adds 8 unit tests for
neutralizeBlockingResources. Full workspace build + tests green.

Also lands RFC-08 (Remotion adapter spec) and RFC-09 (multi-engine product/UX).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk/medium Medium risk size/S Size S (20-99 LOC) type/bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Templates using data-composition-src render as a blank MP4 — Hyperframes runtime is never injected by adapter-hyperframes

2 participants