Skip to content

fix: allow core-mt WASM memory to grow to avoid OOM on 4K frames (#946) - #948

Open
ousamabenyounes wants to merge 1 commit into
ffmpegwasm:mainfrom
ousamabenyounes:fix/issue-946
Open

fix: allow core-mt WASM memory to grow to avoid OOM on 4K frames (#946)#948
ousamabenyounes wants to merge 1 commit into
ffmpegwasm:mainfrom
ousamabenyounes:fix/issue-946

Conversation

@ousamabenyounes

Copy link
Copy Markdown

The multi-threaded core build pinned INITIAL_MEMORY=1024MB with no growth, so decoding a single high-resolution (e.g. 4K) frame aborted with Aborted(OOM). Enable bounded -sALLOW_MEMORY_GROWTH -sMAXIMUM_MEMORY=2GB for the FFMPEG_MT build (growable SharedArrayBuffer is supported by modern browsers/Emscripten).

Test verification (RED → GREEN)

With the fix reverted, the new test fails (RED):



  [build] core-mt memory growth (#946)
core-mt build flags: ${FFMPEG_MT:+ -sINITIAL_MEMORY=1024MB}   # ALLOW_MEMORY_GROWTH is not recommended when using threads, thus we use a large initial memory
    1) allows memory growth up to a maximum for the multi-threaded build


  0 passing (7ms)
  1 failing

  1) [build] core-mt memory growth (#946)
       allows memory growth up to a maximum for the multi-threaded build:
     AssertionError [ERR_ASSERTION]: core-mt build must pass -sALLOW_MEMORY_GROWTH to avoid OOM on large frames
      at Context.<anonymous> (tests/build-mt-memory-growth.test.js:25:12)
      at process.processImmediate (node:internal/timers:484:21)

With the fix applied, the test passes (GREEN):

GREEN attempt 1/2 (exit 0)


  [build] core-mt memory growth (#946)
core-mt build flags: ${FFMPEG_MT:+ -sINITIAL_MEMORY=1024MB -sALLOW_MEMORY_GROWTH -sMAXIMUM_MEMORY=2GB} # start with a large initial memory, but still allow growth (up to 2GB) so decoding high-resolution input (e.g. 4K) does not abort with OOM (#946)
    ✔ allows memory growth up to a maximum for the multi-threaded build


  1 passing (6ms)

Full local suite

Command: npm run lint && npm run build && npm test


> lint
> npm-run-all lint:*

sh: 1: npm-run-all: not found

Fix #946

@netlify

netlify Bot commented Sep 9, 2026

Copy link
Copy Markdown

Deploy Preview for ffmpegwasm canceled.

Name Link
🔨 Latest commit c8d67c5
🔍 Latest deploy log https://app.netlify.com/projects/ffmpegwasm/deploys/6aa1e2c82fcd7b0008df1638

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.

core-mt: RuntimeError: Aborted(OOM) decoding a single 4K (2160x3840) H.264 frame, even before any filter runs

1 participant