Skip to content

Commit 34eb17a

Browse files
committed
Suspended OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224333 Reviewed by Darin Adler. Source/WebCore: When offline rendering is suspended, we now release the ActiveDOMObject::PendingActivity we hold to keep the OfflineAudioContext and its wrapper alive during rendering. The JS has to keep a reference to the context's wrapper anyway if they ever want to resume rendering. Test: webaudio/OfflineAudioContext/offlineaudiocontext-leak-while-suspended.html * Modules/webaudio/OfflineAudioContext.cpp: (WebCore::OfflineAudioContext::didSuspendRendering): LayoutTests: Add layout test coverage. * webaudio/OfflineAudioContext/offlineaudiocontext-leak-while-suspended-expected.txt: Added. * webaudio/OfflineAudioContext/offlineaudiocontext-leak-while-suspended.html: Added. Canonical link: https://commits.webkit.org/236315@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275679 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 0ebbd8f commit 34eb17a

5 files changed

Lines changed: 73 additions & 0 deletions

File tree

LayoutTests/ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2021-04-08 Chris Dumez <cdumez@apple.com>
2+
3+
Suspended OfflineAudioContext objects are leaking
4+
https://bugs.webkit.org/show_bug.cgi?id=224333
5+
6+
Reviewed by Darin Adler.
7+
8+
Add layout test coverage.
9+
10+
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-while-suspended-expected.txt: Added.
11+
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-while-suspended.html: Added.
12+
113
2021-04-08 Chris Gambrell <cgambrell@apple.com>
214

315
[LayoutTests] Convert http/tests/navigation convert PHP to Python
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Makes sure that the OfflineAudioContext objects are not leaking when suspended.
2+
3+
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4+
5+
6+
PASS internals.numberOfBaseAudioContexts() >= instancesToCreate is true
7+
PASS internals.numberOfBaseAudioContexts() < instancesToCreate is true
8+
PASS successfullyParsed is true
9+
10+
TEST COMPLETE
11+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<script src="../../resources/js-test.js"></script>
5+
<script>
6+
description("Makes sure that the OfflineAudioContext objects are not leaking when suspended.");
7+
jsTestIsAsync = true;
8+
9+
const instancesToCreate = 100;
10+
11+
function test() {
12+
let promises = [];
13+
for (let i = 0; i < instancesToCreate; i++) {
14+
let context = new OfflineAudioContext(2, 44100, 44100);
15+
promises.push(context.suspend(0.5));
16+
context.startRendering();
17+
}
18+
shouldBeTrue("internals.numberOfBaseAudioContexts() >= instancesToCreate");
19+
Promise.all(promises).then((values) => {
20+
gc();
21+
setTimeout(() => {
22+
gc();
23+
shouldBeTrue("internals.numberOfBaseAudioContexts() < instancesToCreate");
24+
finishJSTest();
25+
}, 0);
26+
});
27+
}
28+
29+
test();
30+
</script>
31+
</body>
32+
</html>

Source/WebCore/ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2021-04-08 Chris Dumez <cdumez@apple.com>
2+
3+
Suspended OfflineAudioContext objects are leaking
4+
https://bugs.webkit.org/show_bug.cgi?id=224333
5+
6+
Reviewed by Darin Adler.
7+
8+
When offline rendering is suspended, we now release the ActiveDOMObject::PendingActivity we hold
9+
to keep the OfflineAudioContext and its wrapper alive during rendering. The JS has to keep a
10+
reference to the context's wrapper anyway if they ever want to resume rendering.
11+
12+
Test: webaudio/OfflineAudioContext/offlineaudiocontext-leak-while-suspended.html
13+
14+
* Modules/webaudio/OfflineAudioContext.cpp:
15+
(WebCore::OfflineAudioContext::didSuspendRendering):
16+
117
2021-04-08 Jiewen Tan <jiewen_tan@apple.com>
218

319
Unreviewed, a comment fix

Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ void OfflineAudioContext::didSuspendRendering(size_t frame)
196196
{
197197
BaseAudioContext::didSuspendRendering(frame);
198198

199+
clearPendingActivity();
200+
199201
RefPtr<DeferredPromise> promise;
200202
{
201203
AutoLocker locker(*this);

0 commit comments

Comments
 (0)