Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix: always clear canvas before bailing on empty peaks

Davide Mendolia9f55611f72ca
diff --git a/src/components/video-editor/timeline/BackgroundWaveform.tsx b/src/components/video-editor/timeline/BackgroundWaveform.tsx
index 45426ebfa..05d8e6507 100644
--- a/src/components/video-editor/timeline/BackgroundWaveform.tsx
+++ b/src/components/video-editor/timeline/BackgroundWaveform.tsx
@@ -37,7 +37,7 @@ export default function BackgroundWaveform({ peaks, videoDurationMs }: Backgroun
// Redraw whenever peaks, range, or canvas size changes.
useEffect(() => {
const canvas = canvasRef.current;
- if (!canvas || !peaks || canvasSize.w <= 0 || canvasSize.h <= 0) return;
+ if (!canvas || canvasSize.w <= 0 || canvasSize.h <= 0) return;
const dpr = window.devicePixelRatio || 1;
canvas.width = Math.round(canvasSize.w * dpr);
@@ -49,6 +49,8 @@ export default function BackgroundWaveform({ peaks, videoDurationMs }: Backgroun
ctx.scale(dpr, dpr);
ctx.clearRect(0, 0, canvasSize.w, canvasSize.h);
+ if (!peaks || peaks.length === 0) return;
+
const W = canvasSize.w;
const H = canvasSize.h;
const mid = H / 2;