Skip to content

The VS Code of video editing, built for agents.

TypeScript

Add command line switches to enhance performance and rendering behavior

konstantin-paulusffc3e9ca09a2
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index 81be8579..06dca411 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -22,6 +22,10 @@ const MACOS_BACKDROP = { blur: 80, red: 0.07, green: 0.07, blue: 0.07, alpha: 0.
app.setName("Diffusion Studio");
app.commandLine.appendSwitch("enable-blink-features", "CanvasDrawElement");
app.commandLine.appendSwitch("enable-features", "SharedArrayBuffer");
+app.commandLine.appendSwitch("disable-background-timer-throttling");
+app.commandLine.appendSwitch("disable-renderer-backgrounding");
+app.commandLine.appendSwitch("disable-backgrounding-occluded-windows");
+app.commandLine.appendSwitch("disable-features", "CalculateNativeWinOcclusion");
let setNativeCornerRadius: ((handle: Buffer, radius: number) => void) | null = null;
let setNativeBackdrop:
diff --git a/apps/web/src/components/engine/decoders/html.ts b/apps/web/src/components/engine/decoders/html.ts
index d2db17d7..ab28f249 100644
--- a/apps/web/src/components/engine/decoders/html.ts
+++ b/apps/web/src/components/engine/decoders/html.ts
@@ -32,12 +32,24 @@ export function isHtmlInCanvasSupported(): boolean {
let pendingRenderingUpdate: Promise<void> | null = null;
export function nextRenderingUpdate(): Promise<void> {
- pendingRenderingUpdate ??= new Promise(resolve => {
- requestAnimationFrame(() => setTimeout(() => {
- pendingRenderingUpdate = null;
- resolve();
- }, 0));
- });
+ pendingRenderingUpdate ??= Promise.race<void>([
+ new Promise(resolve => {
+ requestAnimationFrame(() => setTimeout(() => {
+ pendingRenderingUpdate = null;
+ resolve();
+ }, 0))
+ }),
+ // A little slower than 60fps (20ms ≈ 50fps): comfortably past a 60Hz vsync so a
+ // live rAF wins the race and we keep waiting for the real paint, while still
+ // capping the per-frame wait when rAF is paused (hidden/headless).
+ new Promise(resolve => {
+ setTimeout(() => {
+ pendingRenderingUpdate = null;
+ resolve();
+ }, 1000 / 50);
+ }),
+ ]);
+
return pendingRenderingUpdate;
}