Commit da8bfdca authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

WebAudio: Fix testStoppedSourceGC for unified heap

GCs should be run async if they require that objects are guaranteed to
be collected.

Bug: 843903
Change-Id: I1e55646e3c2e9f9625c71b45d0c16d8477b4566d
Reviewed-on: https://chromium-review.googlesource.com/c/1488880Reviewed-by: default avatarRaymond Toy <rtoy@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635561}
parent 47ca9747
......@@ -2,6 +2,7 @@
<html>
<head>
<title>Test GC of Stopped AudioBufferSourceNode </title>
<script src="../../resources/gc.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../resources/audit-util.js"></script>
......
......@@ -2,6 +2,7 @@
<html>
<head>
<title>Test GC of Stopped ConstantSourceNode </title>
<script src="../../resources/gc.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../resources/audit-util.js"></script>
......
......@@ -2,6 +2,7 @@
<html>
<head>
<title>Test GC of Stopped OscillatorNode </title>
<script src="../../resources/gc.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../resources/audit-util.js"></script>
......
......@@ -15,10 +15,11 @@ function testStoppedSourceGC(task, should, options) {
lastSrc1.connect(gain);
lastSrc0.onended = () => {
// Have |lastSrc1| stop 10 render quanta from now (pretty arbitrary).
lastSrc1.stop(
asyncGC().then(function () {
// Have |lastSrc1| stop 10 render quanta from now (pretty arbitrary).
lastSrc1.stop(
context.currentTime + 10 * RENDER_QUANTUM_FRAMES / context.sampleRate);
should(() => gc(), 'GC').notThrow();
});
};
lastSrc1.onended = () => {
......@@ -28,35 +29,37 @@ function testStoppedSourceGC(task, should, options) {
task.done();
};
gc();
let initialCount = internals.audioHandlerCount();
let initialCount = 0;
asyncGC().then(function () {
initialCount = internals.audioHandlerCount();
// For information only. This should obviously always pass.
should(initialCount, 'Number of handlers before test')
.beEqualTo(initialCount);
// Create a bunch of sources for testing. Since we call stop(), these
// should all get collected, even though they're no longer connected to
// the destination.
for (let k = 0; k < numberOfNodes; ++k) {
let src = constructorMethod();
src.start();
src.connect(gain);
src.onended = () => {
++countEndedNodes;
if (countEndedNodes == numberOfNodes) {
// For information only
should(countEndedNodes, `Number of ${nodeName}s tested`)
.beEqualTo(numberOfNodes);
lastSrc0.stop();
}
};
// Stop it after about 2 renders
src.stop(
context.currentTime + 2 * RENDER_QUANTUM_FRAMES / context.sampleRate);
src.disconnect();
}
// For information only. This should obviously always pass.
should(initialCount, 'Number of handlers before test')
.beEqualTo(initialCount);
// Create a bunch of sources for testing. Since we call stop(), these
// should all get collected, even though they're no longer connected to
// the destination.
for (let k = 0; k < numberOfNodes; ++k) {
let src = constructorMethod();
src.start();
src.connect(gain);
src.onended = () => {
++countEndedNodes;
if (countEndedNodes == numberOfNodes) {
// For information only
should(countEndedNodes, `Number of ${nodeName}s tested`)
.beEqualTo(numberOfNodes);
lastSrc0.stop();
}
};
// Stop it after about 2 renders
src.stop(
context.currentTime + 2 * RENDER_QUANTUM_FRAMES / context.sampleRate);
src.disconnect();
}
// Start the sources
lastSrc0.start();
lastSrc1.start();
// Start the sources
lastSrc0.start();
lastSrc1.start();
});
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment