Skip to content

[BUG] Large video uploads can freeze or crash browser during waveform generation #1450

@Krishnx21

Description

@Krishnx21

Bug Summary

Large uploaded videos are fully loaded into memory and decoded immediately for waveform generation, which can cause severe memory spikes, browser freezes, or tab crashes.

Files

src/hooks/useAudioWaveform.ts (around line 59)

audioContext = new AudioContextCtor();

const audioBuffer = await audioContext.decodeAudioData(
  await file.arrayBuffer()
);

Called automatically from:

src/components/TrimControl.tsx (around line 28)

const { waveform, isLoading: waveformLoading } = useAudioWaveform(file);

Root Cause

Every uploaded video file is immediately:

  1. Read completely into memory using file.arrayBuffer()
  2. Decoded using decodeAudioData()
  3. Processed regardless of whether the user opens the trim feature

This occurs automatically when TrimControl mounts.

Steps to Reproduce

  1. Upload a large video (400–500 MB).
  2. Wait for the editor to initialize.
  3. Observe memory usage in browser task manager/dev tools.
  4. On lower-memory devices, the tab may become unresponsive or crash.

Actual Behavior

The application allocates a full copy of the uploaded file in memory and attempts to decode it immediately.

Large files can cause:

  • Excessive memory consumption
  • UI freezing
  • Browser tab crashes
  • Poor responsiveness

Expected Behavior

Waveform generation should be deferred until needed and should avoid loading extremely large files into memory.

Impact

The application accepts videos up to approximately 500 MB, yet immediately processes the full file.

Real users editing phone or camera footage may experience:

  • Frozen UI
  • Browser crashes
  • Failed editing sessions

before performing any export operation.

Suggested Fix

Possible improvements include:

  • Generate waveforms only when the trim panel is opened.
  • Skip waveform generation for very large files.
  • Downsample audio before processing.
  • Move extraction work into the FFmpeg worker.
  • Add true cancellation support that stops processing instead of only preventing state updates.

Why This Is a Bug

The failure mode is not theoretical. The application accepts large uploads and unconditionally allocates a full in-memory copy, making browser freezes and crashes a realistic user-facing issue.

ASSIGN TO ME UNDER GSSOC2026.
/ASSIGN /GSSOC2026

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions