Bug 85681 - Simplify AudioNode ref-counting by removing RefTypeDisabled
Summary: Simplify AudioNode ref-counting by removing RefTypeDisabled
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Raymond Toy
URL:
Keywords:
Depends on:
Blocks: 77224
  Show dependency treegraph
 
Reported: 2012-05-04 16:05 PDT by Raymond Toy
Modified: 2012-05-21 15:22 PDT (History)
4 users (show)

See Also:


Attachments
WIP (11.62 KB, patch)
2012-05-14 15:24 PDT, Raymond Toy
no flags Details | Formatted Diff | Diff
Patch (11.80 KB, patch)
2012-05-15 16:05 PDT, Raymond Toy
no flags Details | Formatted Diff | Diff
Patch (11.40 KB, patch)
2012-05-15 20:16 PDT, Raymond Toy
no flags Details | Formatted Diff | Diff
Patch (11.38 KB, patch)
2012-05-16 13:38 PDT, Raymond Toy
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Raymond Toy 2012-05-04 16:05:09 PDT
It should be possible to remove the RefTypeDisabled ref type and also the corresponding enable() and disable() methods that set the ref type to RefTypeDisabled.
Comment 1 Raymond Toy 2012-05-04 16:05:59 PDT
Implement this before fixing 77224.  This change will simplify 77224.
Comment 2 Raymond Toy 2012-05-14 15:24:05 PDT
Created attachment 141797 [details]
WIP
Comment 3 Raymond Toy 2012-05-14 15:32:45 PDT
Cannot remove the enable() and disable() methods.  They're still needed to do the correct things.
Comment 4 Chris Rogers 2012-05-14 15:33:21 PDT
Comment on attachment 141797 [details]
WIP

View in context: https://bugs.webkit.org/attachment.cgi?id=141797&action=review

> Source/WebCore/Modules/webaudio/AudioNode.cpp:270
> +    fprintf(stderr, "%p: %d: AudioNode::enableOutputs %d %d\n", this, nodeType(), m_normalRefCount, m_connectionRefCount);

we're using print (instead of fprintf) let's stay consistent -- in another patch you can change everything over to fprintf, but let's not mix that up in this one

> Source/WebCore/Modules/webaudio/AudioNode.cpp:302
> +    if (m_isDisabled && m_connectionRefCount > 0 && refType == RefTypeConnection)

Can we just move the if() logic from line 302 into line 272 and call enable... directly?

> Source/WebCore/Modules/webaudio/AudioNode.cpp:340
> +void AudioNode::disableOutputsIfNotDisabled()

I'd move the code for this method up to just after the "enable" version of this method

> Source/WebCore/Modules/webaudio/AudioNode.h:158
> +    void disableOutputsIfNotDisabled();

nit: I'm too crazy about these names - how about:
enableOutputsIfNecessary
disableOutputsIfNecessary
Comment 5 Raymond Toy 2012-05-15 16:05:38 PDT
Created attachment 142090 [details]
Patch
Comment 6 Raymond Toy 2012-05-15 16:09:48 PDT
Comment on attachment 141797 [details]
WIP

View in context: https://bugs.webkit.org/attachment.cgi?id=141797&action=review

Updated according to review.  Chris, please review the changes in AudioNodeInput::disable() and AudioNode::disableOutputsIfNecessary().  AudioNodeInput::disable() is better, but AudioNode::disableOutputsIfNecessary() is not as nice as I would want, but I'm not sure how else to do it.

>> Source/WebCore/Modules/webaudio/AudioNode.cpp:270
>> +    fprintf(stderr, "%p: %d: AudioNode::enableOutputs %d %d\n", this, nodeType(), m_normalRefCount, m_connectionRefCount);
> 
> we're using print (instead of fprintf) let's stay consistent -- in another patch you can change everything over to fprintf, but let's not mix that up in this one

Removed.  I forgot to delete this debugging print.

>> Source/WebCore/Modules/webaudio/AudioNode.cpp:302
>> +    if (m_isDisabled && m_connectionRefCount > 0 && refType == RefTypeConnection)
> 
> Can we just move the if() logic from line 302 into line 272 and call enable... directly?

Done.  But need to add refType as a parameter to work with finishDeref.

>> Source/WebCore/Modules/webaudio/AudioNode.cpp:340
>> +void AudioNode::disableOutputsIfNotDisabled()
> 
> I'd move the code for this method up to just after the "enable" version of this method

Done.

>> Source/WebCore/Modules/webaudio/AudioNode.h:158
>> +    void disableOutputsIfNotDisabled();
> 
> nit: I'm too crazy about these names - how about:
> enableOutputsIfNecessary
> disableOutputsIfNecessary

New names applied.
Comment 7 Chris Rogers 2012-05-15 19:00:21 PDT
Comment on attachment 142090 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=142090&action=review

> Source/WebCore/Modules/webaudio/AudioNode.cpp:267
> +void AudioNode::enableOutputsIfNecessary(RefType refType)

Please remove refType argument -- see comment below in ref() method.

> Source/WebCore/Modules/webaudio/AudioNode.cpp:286
> +        if (!m_isDisabled) {

It's odd to have a nested if () here.  Please roll this test into the first if ()

> Source/WebCore/Modules/webaudio/AudioNode.cpp:327
> +    enableOutputsIfNecessary(refType);

You can remove refType argument and simply wrap the enableOutputsIfNecessary() call in:
 if (refType == RefTypeConnection)

> Source/WebCore/Modules/webaudio/AudioNodeInput.cpp:110
> +    // Disable outputs, but only if there is one connection left (checked in

Please remove all of these comment about "one connection left", etc.
All of this is logic internal (implementation detail) to disableOutputsIfNecessary()

On the other hand, the difficult part of understanding this code is that we're inside of the disable() method right here, and yet we're 
calling something called disableOutputsIfNecessary().
The essential point to be made in the comment is that we "propagate" the disabling from this input to any outputs of this AudioNode
Comment 8 Raymond Toy 2012-05-15 20:16:36 PDT
Created attachment 142135 [details]
Patch
Comment 9 Raymond Toy 2012-05-15 20:19:18 PDT
Comment on attachment 142090 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=142090&action=review

>> Source/WebCore/Modules/webaudio/AudioNode.cpp:267
>> +void AudioNode::enableOutputsIfNecessary(RefType refType)
> 
> Please remove refType argument -- see comment below in ref() method.

Done.

>> Source/WebCore/Modules/webaudio/AudioNode.cpp:286
>> +        if (!m_isDisabled) {
> 
> It's odd to have a nested if () here.  Please roll this test into the first if ()

Combined into one.

>> Source/WebCore/Modules/webaudio/AudioNode.cpp:327
>> +    enableOutputsIfNecessary(refType);
> 
> You can remove refType argument and simply wrap the enableOutputsIfNecessary() call in:
>  if (refType == RefTypeConnection)

Done.

>> Source/WebCore/Modules/webaudio/AudioNodeInput.cpp:110
>> +    // Disable outputs, but only if there is one connection left (checked in
> 
> Please remove all of these comment about "one connection left", etc.
> All of this is logic internal (implementation detail) to disableOutputsIfNecessary()
> 
> On the other hand, the difficult part of understanding this code is that we're inside of the disable() method right here, and yet we're 
> calling something called disableOutputsIfNecessary().
> The essential point to be made in the comment is that we "propagate" the disabling from this input to any outputs of this AudioNode

Comment removed.
Comment 10 Raymond Toy 2012-05-16 09:19:08 PDT
Comment on attachment 142090 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=142090&action=review

>>> Source/WebCore/Modules/webaudio/AudioNodeInput.cpp:110
>>> +    // Disable outputs, but only if there is one connection left (checked in
>> 
>> Please remove all of these comment about "one connection left", etc.
>> All of this is logic internal (implementation detail) to disableOutputsIfNecessary()
>> 
>> On the other hand, the difficult part of understanding this code is that we're inside of the disable() method right here, and yet we're 
>> calling something called disableOutputsIfNecessary().
>> The essential point to be made in the comment is that we "propagate" the disabling from this input to any outputs of this AudioNode
> 
> Comment removed.

Maybe the functions should be renamed propagateOutputEnables and propagateOutputDisables?
Comment 11 Chris Rogers 2012-05-16 13:28:35 PDT
Comment on attachment 142135 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=142135&action=review

Looks good with a couple of comment nits.

> Source/WebCore/ChangeLog:3
> +        Remove RefTypDisabled and disable() and enable() methods

Please update comment since disable and enable are not removed in this patch, and RefTypDisabled is a typo.  I'd recommend changing the title of the WebKit bug itself to something like:

"Simplify AudioNode ref-counting by removing RefTypeDisabled"

> Source/WebCore/Modules/webaudio/AudioNode.cpp:281
> +    // Disable outputs if they have not been disabled yet. We do this if the number of connections

"if they have not been disabled yet" -> "if appropriate"

> Source/WebCore/Modules/webaudio/AudioNodeInput.cpp:110
> +    node()->disableOutputsIfNecessary();

Please add comment:
// Propagate disabled state to outputs.

> Source/WebCore/Modules/webaudio/AudioNodeInput.cpp:128
> +    node()->enableOutputsIfNecessary();

Please add comment:
// Propagate enabled state to outputs.
Comment 12 Raymond Toy 2012-05-16 13:38:24 PDT
Created attachment 142336 [details]
Patch
Comment 13 Chris Rogers 2012-05-16 13:54:08 PDT
Comment on attachment 142336 [details]
Patch

Thanks Ray
Comment 14 WebKit Review Bot 2012-05-16 15:26:24 PDT
Comment on attachment 142336 [details]
Patch

Clearing flags on attachment: 142336

Committed r117354: <http://trac.webkit.org/changeset/117354>
Comment 15 WebKit Review Bot 2012-05-16 15:26:29 PDT
All reviewed patches have been landed.  Closing bug.
Comment 16 Eric Seidel (no email) 2012-05-21 15:22:37 PDT
Comment on attachment 141797 [details]
WIP

Cleared review? from obsolete attachment 141797 [details] so that this bug does not appear in http://webkit.org/pending-review.  If you would like this patch reviewed, please attach it to a new bug (or re-open this bug before marking it for review again).