Skip to content

@remotion/studio: Guard timeline waveform draw against zero-width canvas#7293

Merged
JonnyBurger merged 1 commit into
remotion-dev:mainfrom
ke11:fix/studio-waveform-zero-width
May 7, 2026
Merged

@remotion/studio: Guard timeline waveform draw against zero-width canvas#7293
JonnyBurger merged 1 commit into
remotion-dev:mainfrom
ke11:fix/studio-waveform-zero-width

Conversation

@ke11
Copy link
Copy Markdown
Contributor

@ke11 ke11 commented May 7, 2026

Problem

Studio's timeline waveform painter throws

Failed to execute 'createImageData' on 'OffscreenCanvasRenderingContext2D':
The source width is zero or not a number.

whenever an audio sequence is laid out at 0 px — for example when the timeline is mid-resize, a track is collapsed, or many short audio sequences are stacked at a low zoom level. The error is non-fatal but spams the console.

Repro

A composition with ~30+ <Audio> sequences. Open it in Studio; the error fires intermittently while the timeline lays out the audio rows.

Fix

drawBars in packages/studio/src/components/draw-peaks.ts calls ctx.createImageData(w, height) without checking dimensions. createImageData throws a DOMException when either dimension is 0. Add an early return when there's nothing to draw. The same source is inlined into audio-waveform-worker.ts, so this one change fixes both call sites.

Test plan

  • Open a 30+ <Audio> composition in Studio — console stays clean while scrubbing/zooming the timeline.
  • Waveforms still render normally at non-zero canvas widths.

`drawBars` in draw-peaks.ts calls `ctx.createImageData(w, height)`
without checking dimensions. `createImageData` throws a DOMException
when either dimension is 0, which surfaces in Studio's console while
the timeline lays out audio rows on compositions with many audio
sequences (some segments are 0 px wide at certain zoom levels).
Early-return when there is nothing to draw.

The same source is inlined into audio-waveform-worker.ts, so this one
change covers both call sites.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bugs Ready Ready Preview, Comment May 7, 2026 4:31pm
remotion Ready Ready Preview, Comment May 7, 2026 4:31pm

Request Review

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no issues found.

Pullfrog  | View workflow run | Using Claude Opus𝕏

@JonnyBurger JonnyBurger changed the title fix(studio): guard timeline waveform draw against zero-width canvas @remotion/studio: Guard timeline waveform draw against zero-width canvas May 7, 2026
@JonnyBurger
Copy link
Copy Markdown
Member

Thanks!

@JonnyBurger JonnyBurger merged commit f713f17 into remotion-dev:main May 7, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants