Skip to content

fix(audio): prevent browser OOM crash during waveform generation by skipping decoding on files larger than 100MB #1506

Open
AdityaNarayanPadhi wants to merge 2 commits into
magic-peach:mainfrom
AdityaNarayanPadhi:fix-audio-oom-1501
Open

fix(audio): prevent browser OOM crash during waveform generation by skipping decoding on files larger than 100MB #1506
AdityaNarayanPadhi wants to merge 2 commits into
magic-peach:mainfrom
AdityaNarayanPadhi:fix-audio-oom-1501

Conversation

@AdityaNarayanPadhi
Copy link
Copy Markdown

Summary

This PR fixes a browser-crashing out-of-memory (OOM) vulnerability caused by decodeAudioData when loading and parsing very large video files (500MB to 2GB+) in the browser's heap space (#1501).

Changes

  • Introduced a 100MB file size ceiling check inside extractWaveform in useAudioWaveform.ts.
  • If a file exceeds 100MB, the hook returns an empty waveform array and immediately sets isLoading to false without allocating buffer memory or decoding PCM channels.
  • WaveformCanvas gracefully handles empty samples arrays by showing a clean placeholder track line, maintaining standard visual timeline alignment.

Verification

  • Uploading small files (e.g. <50MB) continues to generate and render custom audio waveforms seamlessly.
  • Uploading large video files (e.g. 500MB to 2GB) no longer freezes browser tabs or triggers out-of-memory errors; it falls back cleanly to the placeholder track line.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

@AdityaNarayanPadhi is attempting to deploy a commit to the magic-peach1's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

⚠️ PR Format Issues — @AdityaNarayanPadhi

Please fix the following before your PR can be reviewed:

  • ⚠️ No linked issue found. Add Closes #<issue-number> to your PR description.

Push new commits after fixing — this comment will update automatically.

📖 CONTRIBUTING.md

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

👋 Thanks for your PR, @AdityaNarayanPadhi!

Welcome to Reframe — a browser-based video editor built for everyone 🎬

What happens next

  1. 🤖 Automated checks — build & TypeScript typecheck will run automatically
  2. Vercel preview — a preview deployment will be created (requires maintainer authorization for fork PRs)
  3. 👀 Code review — a maintainer will review your changes
  4. 🚀 Merge — once approved, your PR will be merged!

Quick checklist

  • PR title follows Conventional Commits (e.g. feat: add dark mode)
  • Linked the issue this PR closes (e.g. Closes #123)
  • Tested the changes locally (bun run dev)
  • Build passes (bun run build)

Useful links

Happy coding! 🎉

@github-actions github-actions Bot added level:beginner Beginner level - 20 pts type:bug Bug fix type:security Security labels Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:beginner Beginner level - 20 pts type:bug Bug fix type:security Security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant