Repository navigation
fix(web): release retired pitch-correction sources - #1306
kimchouard wants to merge 1 commit into
Conversation
WPT non-regression comparisonPASS — no regressions · 0 improved section(s) · overall 2717 → 2717 (0) Unchanged sections (28)
Baseline: Workflow run · this comment is updated on every push. |
mdydek
left a comment
There was a problem hiding this comment.
I like the idea, but I would like to see also the immediate release of the native memory tbh. Many users asked for it and I think it is a reasonable change. You can reference to AudioBufferSourceNode::setBuffer implementation. We have separate thread for deconstructing and you can easily schedule something there: context->getDisposer()->dispose(std::move(audioBuffer_));
|
|
||
| Use `stop(when)` to schedule a stop, or `disconnect()` when you may reconnect later. | ||
| Those methods do not dispose the source. | ||
|
|
||
| This is a React Native Audio API extension, not part of the Web Audio API standard. | ||
| It returns `undefined` immediately. Cleanup runs on the audio thread when it can | ||
| process the request; disposal does not guarantee immediate memory reclamation. | ||
|
|
There was a problem hiding this comment.
| Use `stop(when)` to schedule a stop, or `disconnect()` when you may reconnect later. | |
| Those methods do not dispose the source. | |
| This is a React Native Audio API extension, not part of the Web Audio API standard. | |
| It returns `undefined` immediately. Cleanup runs on the audio thread when it can | |
| process the request; disposal does not guarantee immediate memory reclamation. |
| protected assertNotDisposed(): void {} | ||
|
|
There was a problem hiding this comment.
I think we do not need those assertions in the AudioNode and in the AudioScheduledSourceNode. The only node that benefit out of that is AudioBufferSourceNode and it cannot be started and has buffer set after disposal. I think that is enough, we don't need to introduce this noise.
Problem
On web, a pitch-corrected buffer source keeps its Signalsmith processor running after playback stops and the source is disconnected. Repeated playback and seeking accumulate idle processors in a shared audio context. We found this while investigating backing-track playback becoming choppy after repeated pauses.
Reproduced on current
main(a14f1a4b): after six playback cycles, all six processors still received audio callbacks during a 600 ms idle window.Change
Additive API; no breaking changes.
Add
AudioBufferSourceNode.dispose(): voidfor callers that are finished with a source:Disposal is terminal and idempotent. It disconnects the source, clears its buffer and callbacks, and cancels pending web initialization. The worklet drops its PCM/WASM references and returns
falsefromprocess(). Pending requests settle without waiting for an audio-thread acknowledgement.stop(when)keeps its scheduling behavior;disconnect()remains reversible. The shared context stays open. The method is a documented library extension with native and mock counterparts; it does not promise immediate garbage collection.Validation
yarn validate:fastpassed: formatting, lint, typecheck, enum sync, build, 439 C++ smoke tests, and 134 JavaScript tests. Native device playback was not re-evaluated; native changes use existing bindings.