Changeset 146033 in webkit


Ignore:
Timestamp:
Mar 17, 2013 10:51:43 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

ScriptProcessorNode is garbage collected while still active if unreachable
https://bugs.webkit.org/show_bug.cgi?id=112521

Patch by Russell McClellan <russell.mcclellan@gmail.com> on 2013-03-17
Reviewed by Kentaro Hara.

Source/WebCore:

Fix for issue where ScriptProcessorNodes (and AudioNode js wrappers generally)
would be garbage collected before their time. Made AudioNode an ActiveDOMElement
marked pending if there are any open audio connections.

Test: webaudio/javascriptaudionode.html

  • Modules/webaudio/AudioNode.cpp:

(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::hasPendingActivity): it's pending (and thus not GCed)
if it has open audio connections.

  • Modules/webaudio/AudioNode.h: AudioNode is now an ActiveDOMElement
  • Modules/webaudio/AudioScheduledSourceNode.h: added a using declaration

to avoid function name hiding.

  • Modules/webaudio/ScriptProcessorNode.idl: AudioNode is an ActiveDOMElement

LayoutTests:

  • webaudio/javascriptaudionode-expected.txt:
  • webaudio/javascriptaudionode.html:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r146032 r146033  
     12013-03-17  Russell McClellan  <russell.mcclellan@gmail.com>
     2
     3        ScriptProcessorNode is garbage collected while still active if unreachable
     4        https://bugs.webkit.org/show_bug.cgi?id=112521
     5
     6        Reviewed by Kentaro Hara.
     7
     8        * webaudio/javascriptaudionode-expected.txt:
     9        * webaudio/javascriptaudionode.html:
     10
    1112013-03-17  Kunihiko Sakamoto  <ksakamoto@chromium.org>
    212
  • trunk/LayoutTests/webaudio/javascriptaudionode-expected.txt

    r132125 r146033  
    1717PASS Successfully created ScriptProcessorNode with bufferSize = 16384.
    1818PASS onaudioprocess was called with correct data.
     19PASS audioprocessWasCalled is true
    1920PASS successfullyParsed is true
    2021
  • trunk/LayoutTests/webaudio/javascriptaudionode.html

    r137516 r146033  
    7676}
    7777
     78function performGCTest() {
     79    // now test that ScriptProcessorNodes are not garbage collected
     80    // if they are unreachable but connected to a running audio context.
     81    var context = new webkitOfflineAudioContext(2, renderLengthInFrames, sampleRate);
     82
     83    window.audioprocessWasCalled = false;
     84
     85    context.oncomplete = function () {
     86        shouldBeTrue('audioprocessWasCalled');
     87        finishJSTest();
     88    };
     89
     90    // add the scriptprocessor and callback in a nested function to be sure they'll
     91    // be unreachable.
     92    (function() {
     93        var jsnode = context.createScriptProcessor(bufferSize, 0, 1);
     94        jsnode.onaudioprocess = function() {
     95            audioprocessWasCalled = true;
     96        };
     97        jsnode.connect(context.destination);
     98    })();
     99    gc();
     100    context.startRendering();
     101}
     102
    78103function runTest() {
    79104    if (window.testRunner) {
     
    149174
    150175    bufferSource.noteOn(0);
    151     context.oncomplete = finishJSTest;
     176    context.oncomplete = performGCTest;
    152177    context.startRendering();
     178
    153179}
    154180
  • trunk/Source/WebCore/ChangeLog

    r146032 r146033  
     12013-03-17  Russell McClellan  <russell.mcclellan@gmail.com>
     2
     3        ScriptProcessorNode is garbage collected while still active if unreachable
     4        https://bugs.webkit.org/show_bug.cgi?id=112521
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Fix for issue where ScriptProcessorNodes (and AudioNode js wrappers generally)
     9        would be garbage collected before their time.  Made AudioNode an ActiveDOMElement
     10        marked pending if there are any open audio connections.
     11
     12        Test: webaudio/javascriptaudionode.html
     13
     14        * Modules/webaudio/AudioNode.cpp:
     15        (WebCore::AudioNode::AudioNode):
     16        (WebCore::AudioNode::hasPendingActivity): it's pending (and thus not GCed)
     17        if it has open audio connections.
     18        * Modules/webaudio/AudioNode.h: AudioNode is now an ActiveDOMElement
     19        * Modules/webaudio/AudioScheduledSourceNode.h: added a using declaration
     20        to avoid function name hiding.
     21        * Modules/webaudio/ScriptProcessorNode.idl: AudioNode is an ActiveDOMElement
     22
    1232013-03-17  Kunihiko Sakamoto  <ksakamoto@chromium.org>
    224
  • trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp

    r144235 r146033  
    4646
    4747AudioNode::AudioNode(AudioContext* context, float sampleRate)
    48     : m_isInitialized(false)
     48    : ActiveDOMObject(context->scriptExecutionContext(), this)
     49    , m_isInitialized(false)
    4950    , m_nodeType(NodeTypeUnknown)
    5051    , m_context(context)
     
    7677}
    7778
     79bool AudioNode::hasPendingActivity() const
     80{
     81    return !m_isDisabled && (m_connectionRefCount > 0);
     82}
     83   
    7884void AudioNode::initialize()
    7985{
  • trunk/Source/WebCore/Modules/webaudio/AudioNode.h

    r144720 r146033  
    2626#define AudioNode_h
    2727
     28#include "ActiveDOMObject.h"
    2829#include "AudioBus.h"
    2930#include <wtf/Forward.h>
     
    5051// Most processing nodes such as filters will have one input and one output, although multiple inputs and outputs are possible.
    5152
    52 class AudioNode {
     53class AudioNode : public ActiveDOMObject {
    5354public:
    5455    enum { ProcessingSizeInFrames = 128 };
     
    111112    // Called from context's audio thread.
    112113    virtual void reset() = 0;
     114   
     115    // ActiveDOMObject interface
     116    virtual bool hasPendingActivity() const OVERRIDE;
    113117
    114118    // No significant resources should be allocated until initialize() is called.
  • trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h

    r129260 r146033  
    5757    AudioScheduledSourceNode(AudioContext*, float sampleRate);
    5858
     59    // unhide the ActiveDOMObject signature
     60    using AudioSourceNode::stop;
     61   
    5962    // Scheduling.
    6063    void start(double when);
  • trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.idl

    r145922 r146033  
    2828    JSGenerateToJSObject,
    2929    JSGenerateToNativeObject,
     30    ActiveDOMObject,
    3031    EventTarget
    3132] interface ScriptProcessorNode : AudioNode {
Note: See TracChangeset for help on using the changeset viewer.