Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
perf(website): coalesce the resize measurement into one frame
Etienne Lescotffe0513a31b8
diff --git a/website/src/components/Recreation/driver.ts b/website/src/components/Recreation/driver.tsindex f2e4ab81c..bb5077edf 100644--- a/website/src/components/Recreation/driver.ts+++ b/website/src/components/Recreation/driver.ts@@ -699,9 +699,19 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {});};+ // Coalesced into a frame, like the scroll. `measure()` opens all five beats,+ // reads a rect for every `data-t` node and forces layout to do it; a window+ // drag fires resize many times a second, and running that work per event was+ // the one thing on this element's main thread that could take longer than+ // the frame it was in.+ let resizeRaf = 0;const onResize = () => {- measure();- onScroll();+ if (resizeRaf) return;+ resizeRaf = requestAnimationFrame(() => {+ resizeRaf = 0;+ measure();+ onScroll();+ });};let detached = false;@@ -736,6 +746,7 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {cam.removeEventListener("loadeddata", onCamLoaded);cam.removeEventListener("seeked", onCamSeeked);if (raf) cancelAnimationFrame(raf);+ if (resizeRaf) cancelAnimationFrame(resizeRaf);};}