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:
Miguel Ángel
2026-04-11 04:01:26 +02:00
co-authored by Claude Opus 4.6
parent 09363f1898
commit 7d36ab38e3
2 changed files with 6 additions and 0 deletions
@@ -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));
}
}),
);
+3
View File
@@ -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);
}