Repository navigation
Clarify relationships between AudioWorkletGlobalScope and AudioContext. - #1020
Conversation
hoch
left a comment
There was a problem hiding this comment.
I feel like more and more that we need to have a separate introduction doc for this type of information.
| subclass for instantiation.</li> | ||
| <li>An instance of the <a>AudioWorkletProcessor</a> subclass is instantiated with a structured clone of the same | ||
| <code>opts</code> dictionary.</li> | ||
| <li>In the main scope, <code>window.audioWorklet</code> is |
| <a>AudioWorkletProcessor</a>. | ||
| script code is evaluated in this scope to define one or more | ||
| <a>AudioWorkletProcessor</a> subclasses, which in turn are used to | ||
| instantiate <a>AudioWorkletProcessor</a>s, in 1:1 association with |
| impulse response. | ||
| </div> | ||
| <div class="note"> | ||
| Every <a>AudioWorkletGlobalScope</a> is associated with at most one |
There was a problem hiding this comment.
How is this enforced (association to at most one AudioContext)? Can't seem to find a link for that, so if it exists a link to that would be good.
There was a problem hiding this comment.
This actually is the statement of the principle to be enforced. It's what is required to satisfy some of the Worklet motivations described in https://drafts.css-houdini.org/worklets/#motivations, namely that global scopes may be spun up in a rendering environment as needed. Each scope must be able to run consistently, without races.
There was a problem hiding this comment.
I feel like the wording is slightly confusing. I believe we need to highlight that the one-to-one relationship between an BaseAudioContext and an AWGS. I think we have already decided that we do not support per-node global scope. No?
By the way, it's better to use BaseAudioContext everywhere instead of AudioContext.
| </p> | ||
| <figure> | ||
| <img alt="AudioWorklet sequence" src= | ||
| "images/audioProcessorInstantiation.png" width="917" height="546"> |
There was a problem hiding this comment.
Would this figure be better if it really were a sequence diagram?
There was a problem hiding this comment.
I considered that, but I think this is somewhat more effective in that it shows the relationship of the various pieces to each other.
Certainly open to changing it based on further review.
There was a problem hiding this comment.
@rtoy is there further need for changes or may I merge this?
There was a problem hiding this comment.
The picture is pretty complex, but I think a sequence diagram would also be complex.
I'm fine with this as it is. If it proves to confusing, someone will file and issue and we can fix it then.
There was a problem hiding this comment.
Agreed. We land the diagram as it is and can fix it later if necessary. When we freeze the spec for CR, I would like to rework on every diagram in the spec.
rtoy
left a comment
There was a problem hiding this comment.
lgtm, but I'd like hoch@ to take a look too.
hoch
left a comment
There was a problem hiding this comment.
@joeberkovitz Terribly sorry that I missed this PR.
- Is this an informative section or a normative one?
- For the relationship, using prose-like text makes sense. However, the depicted step in the section reads like an algorithm for instantiation.
| with <a>AudioWorkletNode</a>s in the main scope. | ||
| </p> | ||
| <p> | ||
| At least one <a>AudioWorkletGlobalScope</a> exists for each |
There was a problem hiding this comment.
At least
Are we allowing multiple AWGSs for an AudioContext?
There was a problem hiding this comment.
I don't think it makes any difference how many AWGSs are created, since if there is more than one, the effects of multiple AWGSs must not be observable. We are not mandating any sort of parallel processing here, but also not ruling it out provided that its effects are unobservable (which is important for the future).
However I believe this is in fact normative language because of the requirement of "At least one". What is observable is that at least one AWGS exists, allowing processing to take place at all.
There was a problem hiding this comment.
I guess the non-observability of multiple AWGS is also normative: we are formally stating that they are not allowed to have observable effects.
| <p> | ||
| At least one <a>AudioWorkletGlobalScope</a> exists for each | ||
| <a>AudioContext</a> that contains one or more | ||
| <a>AudioWorkletNode</a>s. The running of imported module scripts is |
There was a problem hiding this comment.
Can we leave 'module' out? Or do you have a reference this is actually the 'module' pattern?
There was a problem hiding this comment.
Agreed, I'm removing module.
| impulse response. | ||
| </div> | ||
| <div class="note"> | ||
| Every <a>AudioWorkletGlobalScope</a> is associated with at most one |
There was a problem hiding this comment.
I feel like the wording is slightly confusing. I believe we need to highlight that the one-to-one relationship between an BaseAudioContext and an AWGS. I think we have already decided that we do not support per-node global scope. No?
By the way, it's better to use BaseAudioContext everywhere instead of AudioContext.
| </p> | ||
| <figure> | ||
| <img alt="AudioWorklet sequence" src= | ||
| "images/audioProcessorInstantiation.png" width="917" height="546"> |
There was a problem hiding this comment.
Agreed. We land the diagram as it is and can fix it later if necessary. When we freeze the spec for CR, I would like to rework on every diagram in the spec.
| <img alt="AudioWorklet sequence" src= | ||
| "images/audioProcessorInstantiation.png" width="917" height="546"> | ||
| <figcaption> | ||
| <a><code>AudioWorklet</code></a> sequence |
There was a problem hiding this comment.
<code> tags are redundant. Or it doesn't work in the <figcaption>?
| imported module scripts is run, including the one that was | ||
| previously imported. | ||
| </li> | ||
| <li>As part of running the imported script, an |
There was a problem hiding this comment.
Consider this scenario:
- worklet.import('moduleA');
- Context A created. (with AWGS A)
- worklet.import('moduleB');
- Context B created. (with AWGS B)
What is the status of definition map in AWGS A and AWGS B? Are they supposed to be same or different?
There was a problem hiding this comment.
They would be the same. moduleB gets added to AWGS A, and moduleA is placed into AWGS B prior to moduleB. This is just regular Worklet behavior.
| </li> | ||
| <li>As part of running the imported script, an | ||
| <a>AudioWorkletProcessor</a> is registered under the key | ||
| <code>"Custom1"</code> within the <a>AudioWorkletGlobalScope</a>. |
There was a problem hiding this comment.
Not sure about using an arbitrary keyword Custom1 in the spec. We might have to consult the spec specialist here. (I have a strong feeling that she/he will encourage us to use the ECMA style algorithm for this.)
There was a problem hiding this comment.
Let's mark that up when it happens.
| </li> | ||
| <li>An instance of the <a>AudioWorkletProcessor</a> subclass is | ||
| instantiated with a structured clone of the same <code>opts</code> | ||
| dictionary. |
There was a problem hiding this comment.
When I reached here, this section reads like a rough description of 'instantiation process'. Perhaps we should focus on explaining relationship between classes.
There was a problem hiding this comment.
I don't understand what relationship you want to explain - can you elaborate?
|
@hoch I've responded to your comments and my hope is that this is ready to merge - PTAL. Thanks! |
This is a fix for #966.