Skip to content

Commit

Permalink
Fix 'offline renderer' thread cleanup
Browse files Browse the repository at this point in the history
Offline renderer thread in most of the cases doesn't clean up its resources.
Thread should be joined on every exit, not only when rendering process is in progress.
This problem was detected during webaudio testing which revealed memory leakage.
  • Loading branch information
marcin-mielczarczyk-red committed Jan 31, 2025
1 parent 5b8829b commit bc53de1
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ void OfflineAudioDestinationNode::uninitialize()
return;

if (m_startedRendering) {
if (m_renderThread) {
m_renderThread->waitForCompletion();
m_renderThread = nullptr;
}
if (auto* workletProxy = context().audioWorklet().proxy()) {
BinarySemaphore semaphore;
workletProxy->postTaskForModeToWorkletGlobalScope([&semaphore](ScriptExecutionContext&) mutable {
Expand All @@ -99,6 +95,11 @@ void OfflineAudioDestinationNode::uninitialize()
}
}

if (m_renderThread) {
m_renderThread->waitForCompletion();
m_renderThread = nullptr;
}

AudioNode::uninitialize();
}

Expand Down

0 comments on commit bc53de1

Please sign in to comment.