Skip to content

Commit 2c84c9a

Browse files
committed
fix(engine,core): wait for async timelines and force rebind before capture
Two fixes for compositions that register timelines after async data loading (e.g. fetch for TopoJSON map data): 1. engine/frameCapture: remove the hosts.length <= 1 early return so the timeline readiness poll runs for ALL compositions, not just multi-composition galleries. Single-composition pages with async setup were silently skipped. 2. core/runtime/init: expose window.__hfForceTimelineRebind() which resets childrenBound and re-runs bindRootTimelineIfAvailable(). The renderer calls this after all timelines are confirmed present, ensuring the root player discovers late-registered timelines from fetch callbacks. Without these fixes, compositions using fetch() to load data at runtime would render blank frames because the root player bound timelines before the async setup completed, and seek() never reached the unbound composition timeline.
1 parent 5aff328 commit 2c84c9a

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎packages/core/src/runtime/init.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,11 @@ export function initSandboxRuntimeModular(): void {
964964
return true;
965965
};
966966

967+
(window as any).__hfForceTimelineRebind = () => {
968+
childrenBound = false;
969+
bindRootTimelineIfAvailable();
970+
};
971+
967972
const emitRootStageLayoutDiagnostics = () => {
968973
const rootNode = resolveRootCompositionElement();
969974
if (!(rootNode instanceof HTMLElement)) {

‎packages/engine/src/services/frameCapture.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ async function pollSubCompositionTimelines(
356356
): Promise<void> {
357357
const expression = `(function() {
358358
var hosts = document.querySelectorAll("[data-composition-id]");
359-
if (hosts.length <= 1) return true;
359+
if (hosts.length === 0) return true;
360360
var timelines = window.__timelines || {};
361361
for (var i = 0; i < hosts.length; i++) {
362362
var id = hosts[i].getAttribute("data-composition-id");
@@ -366,6 +366,13 @@ async function pollSubCompositionTimelines(
366366
return true;
367367
})()`;
368368
const ready = await pollPageExpression(page, expression, timeoutMs, intervalMs);
369+
if (ready) {
370+
await page.evaluate(`(function() {
371+
if (typeof window.__hfForceTimelineRebind === "function") {
372+
window.__hfForceTimelineRebind();
373+
}
374+
})()`);
375+
}
369376
if (!ready) {
370377
const missing = await page.evaluate(`(function() {
371378
var hosts = document.querySelectorAll("[data-composition-id]");

0 commit comments

Comments
 (0)