Repository navigation
Conversation
disable() already stopped the decoder daemon, but the node kept the daemon and its frame channel (64 chunks of 64 KB, about 4 MB) until JS garbage-collected the node. The <Audio> tag replaces its file source after every end, so each play to the end left about 4 MB behind until a collection, which the node's small memory credit does not hurry. disable() now hands both to the context's disposer, as AudioBufferSourceNode does with its buffer, so ~SeekDecoderDaemon's join runs on the disposer thread, not the audio thread. readNextFrameChunk() returns false once the channel is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Member
|
valid improvement, will port it to the #1526 on Monday, because there is already an refactor in a review |
mdydek
added a commit
that referenced
this pull request
Dec 4, 2026
This branch has not been 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.
Closes #1551
Introduced changes
AudioFileSourceNode::disable()hands the decoder daemon and the frame channel (about 4 MB) to the context's disposer, asAudioBufferSourceNode::disable()does with its buffer. Before, both stayed until JS garbage-collected the node, and the<Audio>tag makes a new file source after every end, so each play to the end kept about 4 MB more.~SeekDecoderDaemonjoins the decoding thread, so it now runs on the disposer thread instead of the audio thread.disable()still requests the stop first, and since fix: a loaded or paused file source's decoder waits instead of polling every 10 ms #1521 the stop wakes a waiting daemon, so the join is short. For a remote source the join can still wait for a network read in progress; before this change that wait happened on the JS thread when the node was collected, now it holds up the disposer thread.readNextFrameChunk()returns false once the frame channel is gone. That covers astart()after the end, which renders silence as before.AudioFileSourceNodeTest:disable()releases both and the frame channel is actually freed, playing to the end releases both, andstart()after the end renders silence..claude/skills/audio-nodes: one paragraph on releasing what a finished source owns indisable().Measured with the reproduction from #1551 (Android release build, 30 plays to the end):
In our app (the same change on 1.0.2, a 47 s recording replayed to the end 13 times), native heap growth per replay went from about 4.1 MB to about 0.13 MB.
Not in this PR:
AudioFileSourceNodeHostObject::getMemoryPressure()credits about 6 KB, while a live file source holds about 4 MB (the frame channel and the pending chunk). A source dropped without reaching the end, for example when<Audio>gets a newsourcemid-playback, still keeps its 4 MB until a collection. I left the credit alone because of the over-reporting notes in the host-objects skill. I can add it here or in a separate PR if you want it. A source stopped before it started also keeps them, because that path callsAudioNode::disable()directly.Checked locally:
run-tests.sh smoke(619 passed), the file source, media element and decoder daemon suites with--ubasanand with--tsan(20 repeats), and clang-format 23 and cpplint 2.0.2 on the changed files. I did not run the native example-app builds; the same change builds for Android and iOS in our app on 1.0.2.Written with Claude Code.
Checklist
release/X.Yonly for fixes to the released version)🤖 Generated with Claude Code