Re: Node lifetime question

I'm not trying to do anything new here, just address
https://github.com/WebAudio/web-audio-api/issues/944. We already have a
section on node lifetime, and the issue is to clarify some of it where it
talks about "connections" without explaining exactly what that means. While
it does not tell implementations what to do, this section still seems
important.

.            .       .    .  . ...Joe

Joe Berkovitz
President
Noteflight LLC

+1 978 314 6271

49R Day Street
Somerville MA 02144
USA

"Bring music to life"
www.noteflight.com

On Tue, Oct 4, 2016 at 12:43 PM, Paul Adenot <padenot@mozilla.com> wrote:

> What is you can observe is observable, what you can't observer is not
> observable.
>
> It's unclear to me what you're trying to do here? Come up with rules about
> garbage collection ?
>
> It's mostly an implementation concern.
>
> Paul.
>
> On Tue, Oct 4, 2016 at 6:25 PM, Joe Berkovitz <joe@noteflight.com> wrote:
>
>> Well, we are trying to establish rules for observability. Perhaps we're
>> saying, based on the previous example, that the rules are this: a
>> modulation signal alone, in the absence of an input, is not observable.
>> That seems fine to me. Would you agree?
>>
>> .            .       .    .  . ...Joe
>>
>> Joe Berkovitz
>> President
>> Noteflight LLC
>>
>> +1 978 314 6271
>>
>> 49R Day Street
>> Somerville MA 02144
>> USA
>>
>> "Bring music to life"
>> www.noteflight.com
>>
>> On Tue, Oct 4, 2016 at 11:57 AM, Paul Adenot <padenot@mozilla.com> wrote:
>>
>>> I suppose we could collect everything here. The key is observability.
>>> Implementors can do anything they feel like as long as the result is not
>>> observable.
>>>
>>> Paul.
>>>
>>> On Tue, Oct 4, 2016 at 5:36 PM, Joe Berkovitz <joe@noteflight.com>
>>> wrote:
>>>
>>>> Sorry, I meant to remove amp from reachability. Updated example:
>>>>
>>>>   var mod = new OscillatorNode(...); // modulation source
>>>>   var sig = new OscillatorNode(...);  // signal source
>>>>   sig.connect(amp);
>>>>   var amp = new GainNode();
>>>>   mod.connect(amp.gain);
>>>>   amp.connect(ctx.destination);
>>>>   mod.start();
>>>>   sig.start();
>>>>   sig.stop(ctx.currentTime + 1);
>>>>   sig = null;  // note: mod is still playing, and is also retained by a
>>>> JS reference
>>>>   amp = null;
>>>>
>>>>
>>>> .            .       .    .  . ...Joe
>>>>
>>>> Joe Berkovitz
>>>> President
>>>> Noteflight LLC
>>>>
>>>> +1 978 314 6271
>>>>
>>>> 49R Day Street
>>>> Somerville MA 02144
>>>> USA
>>>>
>>>> "Bring music to life"
>>>> www.noteflight.com
>>>>
>>>> On Tue, Oct 4, 2016 at 11:35 AM, Paul Adenot <padenot@mozilla.com>
>>>> wrote:
>>>>
>>>>> In your example, `amp` is till reachable, so it stays alive.
>>>>>
>>>>> Paul.
>>>>>
>>>>> On Tue, Oct 4, 2016 at 5:32 PM, Joe Berkovitz <joe@noteflight.com>
>>>>> wrote:
>>>>>
>>>>>> I agree with this outcome, but the reasoning still feels murky. It
>>>>>> seems that you are saying that an active connection from some source to
>>>>>> some node via an AudioParam doesn't count as an "input reference" to keep
>>>>>> it alive, but a connection via its input does. Perhaps that's true, but I
>>>>>> want to make sure.
>>>>>>
>>>>>> Let's try this example. In this one, there are three nodes: two
>>>>>> oscillators and a GainNode. One oscillator is being amplified, the other is
>>>>>> modulating the gain node. The source oscillator becomes stopped and has no
>>>>>> JS references, but the modulation oscillator sticks around. Does the
>>>>>> GainNode stick around too?
>>>>>>
>>>>>>   var mod = new OscillatorNode(...); // modulation source
>>>>>>   var sig = new OscillatorNode(...);  // signal source
>>>>>>   sig.connect(amp);
>>>>>>   var amp = new GainNode();
>>>>>>   mod.connect(amp.gain);
>>>>>>   amp.connect(ctx.destination);
>>>>>>   mod.start();
>>>>>>   sig.start();
>>>>>>   sig.stop(ctx.currentTime + 1);
>>>>>>   sig = null;  // note: mod is still playing, and is also retained by
>>>>>> a JS reference
>>>>>>
>>>>>> Question: does the gain node `amp` remain in the graph or can it be
>>>>>> GCed?
>>>>>>
>>>>>>
>>>>>> .            .       .    .  . ...Joe
>>>>>>
>>>>>> Joe Berkovitz
>>>>>> President
>>>>>> Noteflight LLC
>>>>>>
>>>>>> +1 978 314 6271
>>>>>>
>>>>>> 49R Day Street
>>>>>> Somerville MA 02144
>>>>>> USA
>>>>>>
>>>>>> "Bring music to life"
>>>>>> www.noteflight.com
>>>>>>
>>>>>> On Tue, Oct 4, 2016 at 4:21 AM, Paul Adenot <padenot@mozilla.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Agreed with Raymond here.
>>>>>>>
>>>>>>> Paul.
>>>>>>>
>>>>>>> On Tue, Oct 4, 2016 at 12:20 AM, Raymond Toy <rtoy@google.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Once oscB has stopped, and because you've dropped all references to
>>>>>>>> both A and B, does it matter anymore?  Nothing is observable anymore and
>>>>>>>> you can't make them observable, so it seems to me we don't have to say
>>>>>>>> anything.  The implementation can do whatever it wants now.
>>>>>>>>
>>>>>>>> On Mon, Oct 3, 2016 at 8:04 AM, Joe Berkovitz <joe@noteflight.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> But in that case, A and B both have "playing" references as per
>>>>>>>>> the Lifetime section of the spec, so JS references are irrelevant.
>>>>>>>>>
>>>>>>>>> So here is an improved and hopefully more troubling statement of
>>>>>>>>> the question:
>>>>>>>>>
>>>>>>>>> Let's say that osc A is modulating the frequency of osc B, but
>>>>>>>>> that B reached its stop time (and A has no stop time). Would we keep B
>>>>>>>>> alive anyway, because retained node A is modulating it, in spite of the
>>>>>>>>> fact that B can only produce silence?
>>>>>>>>>
>>>>>>>>> Example:
>>>>>>>>>   var oscA = new OscillatorNode(...);
>>>>>>>>>   var oscB = new OscillatorNode(...);
>>>>>>>>>   oscA.connect(oscB.frequency);
>>>>>>>>>   oscB.connect(ctx.destination);
>>>>>>>>>   oscA.start();
>>>>>>>>>   oscB.start();
>>>>>>>>>   oscB.stop(ctx.currentTime + 1);
>>>>>>>>>   oscA = oscB = null;
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> .            .       .    .  . ...Joe
>>>>>>>>>
>>>>>>>>> Joe Berkovitz
>>>>>>>>> President
>>>>>>>>> Noteflight LLC
>>>>>>>>>
>>>>>>>>> +1 978 314 6271
>>>>>>>>>
>>>>>>>>> 49R Day Street
>>>>>>>>> Somerville MA 02144
>>>>>>>>> USA
>>>>>>>>>
>>>>>>>>> "Bring music to life"
>>>>>>>>> www.noteflight.com
>>>>>>>>>
>>>>>>>>> On Fri, Sep 30, 2016 at 7:18 PM, Raymond Toy <rtoy@google.com>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> I think it should.  If A and B are both oscillators and A is
>>>>>>>>>> connected to, say, B.frequency, I expect to hear the modulated B even if A
>>>>>>>>>> and B have no Javascript references to them.
>>>>>>>>>>
>>>>>>>>>> On Fri, Sep 30, 2016 at 1:22 PM, Joe Berkovitz <
>>>>>>>>>> joe@noteflight.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> I sat down to work on https://github.com/WebAudio/we
>>>>>>>>>>> b-audio-api/issues/944 and discovered a question.
>>>>>>>>>>>
>>>>>>>>>>> So: we already know (I think) that when AudioNode A's output is
>>>>>>>>>>> connected to AudioNode B's input, then A has a "connection reference" to B.
>>>>>>>>>>> Thus, if A is retained, B is retained too.
>>>>>>>>>>>
>>>>>>>>>>> But what about the case where AudioNode A is connected to an
>>>>>>>>>>> AudioParam exposed by AudioNode B? Does A keep B alive in this case?
>>>>>>>>>>>
>>>>>>>>>>> .            .       .    .  . ...Joe
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Received on Tuesday, 4 October 2016 16:54:14 UTC