mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-23 11:29:54 +00:00
fix(renderer): add yields between frames to prevent main thread lockup
- iframe-pool: setTimeout(0) yield after each captured frame - SnapDOM source: requestAnimationFrame after seek() before capture to ensure layout/paint is processed This prevents Chrome from becoming unresponsive during long renders, keeping CDP, DevTools, and UI interactions functional. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
09363f1898
commit
7d36ab38e3
@@ -70,6 +70,9 @@ export class IframePool {
|
||||
const time = frameTimes[i]!;
|
||||
const bitmap = await source.capture(time);
|
||||
onFrame({ bitmap, index: i, time });
|
||||
// Yield to event loop every frame so Chrome can process CDP,
|
||||
// repaint UI, and handle user interactions during long renders
|
||||
await new Promise<void>((r) => setTimeout(r, 0));
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -85,6 +85,9 @@ export class SnapdomFrameSource implements FrameSource {
|
||||
|
||||
this.hf.seek(time);
|
||||
|
||||
// Wait for seek to take effect — one rAF cycle for layout + paint
|
||||
await new Promise<void>((r) => requestAnimationFrame(() => r()));
|
||||
|
||||
if (this.videoInjector) {
|
||||
await this.videoInjector.injectFrame(time);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user