Repository navigation
@remotion/renderer: Don't deadlock when concurrent renders merge 32+ audio tracks - #12539
Merged
JonnyBurger merged 1 commit intoOct 22, 2026
Merged
Conversation
Contributor
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
packages/renderer/src/merge-audio-track.ts— Moves the module-widepLimit(3)guard off the wholemergeAudioTrackcall and onto the individual FFmpeg invocations (callFffor the merge, pluscreateSilentAudio). A merge that awaits its recursively-invoked chunk merges now holds no slot, so three concurrent 32+-track merges can no longer occupy all three slots while waiting on queued chunk merges. Concurrency stays capped at 3 FFmpeg processes per module.packages/renderer/src/test/merge-audio-track.test.ts— New regression test that fires three concurrent 32-track merges withcallFfmocked, races them against a 2s timeout, and assertsmaxRunning <= 3.
I confirmed the test genuinely detects the bug: it fails against the pre-fix merge-audio-track.ts (resolves as stuck after the full 2s) and passes with the fix. I also checked that external callers (create-audio.ts, merge-inline-audio-tracks.ts) are unaffected since only FFmpeg concurrency — not mergeAudioTrack call concurrency — was the intent, and that oxfmt/eslint pass on both changed files.
deepseek-v4.1-flash | 𝕏
Member
|
Thanks! |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

mergeAudioTrack()runs under a module-widepLimit(3). With 32 or more tracks, it splits them into chunks, merges each chunk with a nestedmergeAudioTrack()call, and then merges the results, all while holding its own slot. When three such merges overlap in one process, for example, three renders with many audio tracks at once, the three outer calls hold all three slots and wait for chunk merges that can never start. The renders hang with no error, and cancelling doesn't help because nothing is running.Now only the FFmpeg calls take a slot. A merge that waits for its chunks holds none, so it can't block them, at any nesting depth or number of renders. There are still at most 3 FFmpeg merges at once.
Added a test that starts three 32-track merges at the same time with
callFf()mocked. It gets stuck on main and passes with the fix, and it checks that no more than 3 FFmpeg calls run at once. I also ran it with real FFmpeg on 3 renders of 40 tracks each: stuck after 60 seconds on main, done in under half a second with the fix.