Skip to content

Write HTML. Render video. Built for agents.

fix(engine,core): wait for async timelines and force rebind before capture

Miguel Ángel2c84c9a55d73
diff --git a/packages/core/src/runtime/init.ts b/packages/core/src/runtime/init.ts
index 5c677959ee..a57de988ac 100644
--- a/packages/core/src/runtime/init.ts
+++ b/packages/core/src/runtime/init.ts
@@ -964,6 +964,11 @@ export function initSandboxRuntimeModular(): void {
return true;
};
+ (window as any).__hfForceTimelineRebind = () => {
+ childrenBound = false;
+ bindRootTimelineIfAvailable();
+ };
+
const emitRootStageLayoutDiagnostics = () => {
const rootNode = resolveRootCompositionElement();
if (!(rootNode instanceof HTMLElement)) {
diff --git a/packages/engine/src/services/frameCapture.ts b/packages/engine/src/services/frameCapture.ts
index 313e097a95..ea1b01ec65 100644
--- a/packages/engine/src/services/frameCapture.ts
+++ b/packages/engine/src/services/frameCapture.ts
@@ -356,7 +356,7 @@ async function pollSubCompositionTimelines(
): Promise<void> {
const expression = `(function() {
var hosts = document.querySelectorAll("[data-composition-id]");
- if (hosts.length <= 1) return true;
+ if (hosts.length === 0) return true;
var timelines = window.__timelines || {};
for (var i = 0; i < hosts.length; i++) {
var id = hosts[i].getAttribute("data-composition-id");
@@ -366,6 +366,13 @@ async function pollSubCompositionTimelines(
return true;
})()`;
const ready = await pollPageExpression(page, expression, timeoutMs, intervalMs);
+ if (ready) {
+ await page.evaluate(`(function() {
+ if (typeof window.__hfForceTimelineRebind === "function") {
+ window.__hfForceTimelineRebind();
+ }
+ })()`);
+ }
if (!ready) {
const missing = await page.evaluate(`(function() {
var hosts = document.querySelectorAll("[data-composition-id]");