Skip to content

Commit ba95648

Browse files
committed
ASSERTION FAILED: context().isInitialized() ./Modules/webaudio/OfflineAudioDestinationNode.cpp(142)
https://bugs.webkit.org/show_bug.cgi?id=224876 <rdar://76896256> Reviewed by Eric Carlson. Source/WebCore: In OfflineAudioDestinationNode::uninitialize(), we were synchronizing with the render thread to make sure that OfflineAudioDestinationNode::offlineRender() was done running before proceeding with uninitialization. However, when an audio worklet is used, m_renderThread is null and no synchronization with the AudioWorklet thread would happen. This patch adds the missing synchronization with the AudioWorklet thread when present. Test: webaudio/OfflineAudioContext/offlineaudiocontext-uninitialized-crash.html * Modules/webaudio/OfflineAudioDestinationNode.cpp: (WebCore::OfflineAudioDestinationNode::uninitialize): LayoutTests: Add layout test coverage. * webaudio/OfflineAudioContext/offlineaudiocontext-uninitialized-crash-expected.txt: Added. * webaudio/OfflineAudioContext/offlineaudiocontext-uninitialized-crash.html: Added. Canonical link: https://commits.webkit.org/236854@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276379 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent cada8c7 commit ba95648

5 files changed

Lines changed: 74 additions & 3 deletions

File tree

LayoutTests/ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2021-04-21 Chris Dumez <cdumez@apple.com>
2+
3+
ASSERTION FAILED: context().isInitialized() ./Modules/webaudio/OfflineAudioDestinationNode.cpp(142)
4+
https://bugs.webkit.org/show_bug.cgi?id=224876
5+
<rdar://76896256>
6+
7+
Reviewed by Eric Carlson.
8+
9+
Add layout test coverage.
10+
11+
* webaudio/OfflineAudioContext/offlineaudiocontext-uninitialized-crash-expected.txt: Added.
12+
* webaudio/OfflineAudioContext/offlineaudiocontext-uninitialized-crash.html: Added.
13+
114
2021-04-21 Simon Fraser <simon.fraser@apple.com>
215

316
will-change: transform should affect nested position:fixed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This test passes if it does not crash.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<p>This test passes if it does not crash.</p>
2+
<script>
3+
if (window.testRunner)
4+
testRunner.dumpAsText();
5+
6+
onload = async () => {
7+
let contexts = [];
8+
onunload = () => {
9+
while (contexts.length) {
10+
let ctx = contexts.pop();
11+
ctx.startRendering();
12+
}
13+
};
14+
15+
for (let i = 0; i < 15; i++) {
16+
let offlineAudioContext = new OfflineAudioContext({
17+
length: 1,
18+
sampleRate: 3000
19+
});
20+
contexts.push(offlineAudioContext);
21+
try {
22+
await offlineAudioContext.audioWorklet.addModule('');
23+
} catch {
24+
}
25+
}
26+
};
27+
</script>

Source/WebCore/ChangeLog

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
2021-04-21 Chris Dumez <cdumez@apple.com>
2+
3+
ASSERTION FAILED: context().isInitialized() ./Modules/webaudio/OfflineAudioDestinationNode.cpp(142)
4+
https://bugs.webkit.org/show_bug.cgi?id=224876
5+
<rdar://76896256>
6+
7+
Reviewed by Eric Carlson.
8+
9+
In OfflineAudioDestinationNode::uninitialize(), we were synchronizing with the
10+
render thread to make sure that OfflineAudioDestinationNode::offlineRender() was
11+
done running before proceeding with uninitialization. However, when an audio
12+
worklet is used, m_renderThread is null and no synchronization with the AudioWorklet
13+
thread would happen. This patch adds the missing synchronization with the AudioWorklet
14+
thread when present.
15+
16+
Test: webaudio/OfflineAudioContext/offlineaudiocontext-uninitialized-crash.html
17+
18+
* Modules/webaudio/OfflineAudioDestinationNode.cpp:
19+
(WebCore::OfflineAudioDestinationNode::uninitialize):
20+
121
2021-04-21 Simon Fraser <simon.fraser@apple.com>
222

323
will-change: transform should affect nested position:fixed

Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <algorithm>
3939
#include <wtf/IsoMallocInlines.h>
4040
#include <wtf/MainThread.h>
41+
#include <wtf/threads/BinarySemaphore.h>
4142

4243
namespace WebCore {
4344

@@ -76,9 +77,18 @@ void OfflineAudioDestinationNode::uninitialize()
7677
if (!isInitialized())
7778
return;
7879

79-
if (m_renderThread) {
80-
m_renderThread->waitForCompletion();
81-
m_renderThread = nullptr;
80+
if (m_startedRendering) {
81+
if (m_renderThread) {
82+
m_renderThread->waitForCompletion();
83+
m_renderThread = nullptr;
84+
}
85+
if (auto* workletProxy = context().audioWorklet().proxy()) {
86+
BinarySemaphore semaphore;
87+
workletProxy->postTaskForModeToWorkletGlobalScope([&semaphore](ScriptExecutionContext&) mutable {
88+
semaphore.signal();
89+
}, WorkerRunLoop::defaultMode());
90+
semaphore.wait();
91+
}
8292
}
8393

8494
AudioNode::uninitialize();

0 commit comments

Comments
 (0)