Fix video export crashing Chrome by using deterministic frame capture

Replace realtime captureStream(60) with manual captureStream(0) +
requestFrame at 30fps, suspend the live render loop during export,
prefer VP8, and cap bitrate to avoid STATUS_BREAKPOINT tab crashes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonxlnx
2026-06-10 00:46:24 +02:00
parent 1fc88c1c4e
commit b0a040fcd0
3 changed files with 89 additions and 30 deletions
+10
View File
@@ -4,6 +4,7 @@
var Engine = (function () {
var canvas, gl, program, uniforms = {};
var playing = true;
var suspended = false;
var loopT = 0; // seconds into current loop
var lastTick = 0;
var fps = 60, fpsAcc = 0, fpsN = 0, fpsCb = null;
@@ -119,6 +120,8 @@ var Engine = (function () {
}
function tick(now) {
if (suspended) return;
var dt = Math.min((now - lastTick) / 1000, 0.1);
lastTick = now;
@@ -157,6 +160,13 @@ var Engine = (function () {
readPixels: readPixels,
currentPhase: currentPhase,
resetTime: function () { loopT = 0; },
setLoopTime: function (t) { loopT = t; },
suspend: function () { suspended = true; },
resume: function () {
suspended = false;
lastTick = performance.now();
requestAnimationFrame(tick);
},
setPlaying: function (v) { playing = v; lastTick = performance.now(); },
isPlaying: function () { return playing; },
onFps: function (cb) { fpsCb = cb; },