Skip to content

πŸŽ₯ Make videos programmatically with React

fix(studio): guard timeline waveform draw against zero-width canvas (#7293)

Kellf713f1778eda
diff --git a/packages/studio/src/components/draw-peaks.ts b/packages/studio/src/components/draw-peaks.ts
index 560849f11e..009baab34f 100644
--- a/packages/studio/src/components/draw-peaks.ts
+++ b/packages/studio/src/components/draw-peaks.ts
@@ -18,6 +18,14 @@ export const drawBars = (
const {height} = canvas;
const w = canvas.width;
+ // Skip drawing when the target canvas has not been laid out yet.
+ // `createImageData(0, h)` / `(w, 0)` throws a DOMException, which
+ // surfaces in Studio's console for compositions with many audio
+ // sequences β€” some segments are 0 px wide at certain zoom levels.
+ if (w === 0 || height === 0) {
+ return;
+ }
+
ctx.clearRect(0, 0, w, height);
if (volume === 0) return;