Skip to content

remotion: Keep shared <Html5Audio> active when parent component remounts - #13541

Closed
EnesKartal wants to merge 1 commit into
remotion-dev:mainfrom
EnesKartal:fix/shared-audio-remount-13538
Closed

EnesKartal wants to merge 1 commit into
remotion-dev:mainfrom
EnesKartal:fix/shared-audio-remount-13538

Conversation

@EnesKartal

Copy link
Copy Markdown
Contributor

Root Cause

When a parent component containing <Html5Audio>\ remounts (for example via a \key\ change):

  1. During the render phase, the new <Html5Audio>\ instance calls
    egisterAudio\ with the same deterministic \�udioId\ while the old instance is still mounted, so
    egisterAudio\ returns the existing shared \AudioElem\ slot.
  2. During the commit phase, the old instance's cleanup runs \unregisterAudio(id), which frees the slot, removes it from \�udios.current, and resets the <audio>\ element's \src\ to \EMPTY_AUDIO.
  3. The new instance's \updateAudio\ then finds no entry in \�udios.current, leaving the shared <audio>\ element permanently empty and silent until reload.

Fix

  • Track per-instance owners (\Map<number, Set>) for each shared audio slot in \SharedAudioTagsContextProvider.
  • Add \claimAudio(elem, owner)\ called in \useSharedAudio's mount effect (before \updateAudio): it records the mounted instance as an owner of the slot and re-registers the slot (restoring \ akenAudios, \�udios.current, and the <audio>\ element's props) if the previous instance's cleanup already freed it.
  • Update \unregisterAudio(id, owner)\ to remove only that instance's owner token and only release/empty the shared <audio>\ slot when no active owners remain.

Tests

  • Added unit tests in \packages/core/src/test/shared-audio-tags.test.tsx\ covering parent \key\ remounts (including repeated remounts,
    umberOfAudioTags={1}, \React.StrictMode, and multiple simultaneously mounted identical <Html5Audio>\ instances).
  • Added a <Player>\ integration test in \packages/player/src/test/shared-audio-remount.test.tsx.

Fixes #13538

@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
bugs Ready Ready Preview Nov 19, 2026 1:27pm UTC
remotion Ready Ready Preview Nov 19, 2026 1:27pm UTC

Request Review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Approach: sound — commit-time ownership and reclamation repair the shared-audio lifecycle race without changing the public API.

Reviewed changes across all three files, including registration, cleanup, and component integration.

  • Shared-slot lifecycle: Per-instance owners prevent premature release; claiming restores slots freed during a keyed remount before audio props update.
  • Regression coverage: Core component tests cover repeated remounts, a single slot, Strict Mode, and overlapping owners; a Player integration test exercises the public component path.

Validation: 782 core tests and 98 Player tests passed, along with core typechecking and changed-file lint. Red/green verified by disconnecting claim wiring in memory; validation covered DOM source retention, not audible browser playback.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@JonnyBurger

Copy link
Copy Markdown
Member

I have my own PR open for this, thanks..

This branch was successfully deployed

2 active deployments
Preview – remotion — 82c266f7 Deployed Nov 19, 2026 by vercel[bot]
Preview – bugs — 82c266f7 Deployed Nov 19, 2026 by vercel[bot]
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.

@remotion/player: <Html5Audio> goes silent until reload after its parent component remounts

2 participants