Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Side by Side Diff: third_party/WebKit/ManualTests/webaudio/scriptprocessornode-premature-gc.html

Issue 1762103002: Keep ScriptProcessorNode from premature GC with ScriptWrappable::hasPendingActivity() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test premature GC on ScriptProcessorNode</title>
5 <style type="text/css">
6 body {
7 margin: 2em;
8 }
9 .manual-test-ui {
10 font-family: Arial;
11 padding: 1em;
12 border: 1px solid #999;
13 }
14 .manual-test-ui button {
15 padding: 1em;
16 font-size: 1em;
17 }
18 #eError {
19 font-family: Arial;
20 margin: 0.75em;
21 color: red;
22 }
23 </style>
24 </head>
25
26 <body>
27 <h1>Test Premature GC on ScriptProcessorNode</h1>
28
29 <p><strong>NOTE: This test requires HTTP server and getUserMedia (i.e. live
30 audio input).</strong></p>
31
32 <p>ScriptProcessorNode's the node reference should not get garbage collected
33 even when it is out of scope as long as <code>onaudioprocess</code>
34 handler is active.</p>
35
36 <p>This test must be performed manually, because 1) ScriptProcessorNode is
37 not compatible with OfflineAudioContext, thus 2)
38 <code>onaudioprocess</code> is being fired asynchronously.</p>
39
40 <p>As soon as this page loads, you should see the counter number increases
41 without stopping. Without the fix, the counter does not increase at all.
42 This test can be flaky, so it should be attempted repeatedly to see fail.
43 </p>
44
45 <p>CRBUG issue: <a href="https://bugs.chromium.org/p/chromium/issues/detail? id=360378" target="_blank">
46 360378</a></p>
47
48 <div class="manual-test-ui">
49 <p><code>onaudioprocess</code> called: <span id="eHandlerCounter">0</span> </p>
50 </div>
51
52 <script type="text/javascript">
53 var eHandlerCounter = document.querySelector('#eHandlerCounter');
54 var counter = 0;
55
56 function handleGUMStream (stream) {
57 var context = new AudioContext();
58 var streamSource = context.createMediaStreamSource(stream);
59 var scriptNode = context.createScriptProcessor(4096, 1, 1);
60
61 scriptNode.onaudioprocess = function (event) {
62 var input = event.inputBuffer.getChannelData(0);
63 var output = event.outputBuffer.getChannelData(0);
64 output.set(input);
65 eHandlerCounter.textContent = counter++;
66 };
67
68 streamSource.connect(scriptNode).connect(context.destination);
69 }
70
71 function streamFailed (error) {
72 eHandlerCounter.textContent = 'Input Stream Error. (' + error + ')';
73 }
74
75 navigator.webkitGetUserMedia({
76 audio: true
77 }, handleGUMStream, streamFailed);
78 </script>
79 </body>
80 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698