Skip to content

Clarify relationships between AudioWorkletGlobalScope and AudioContext. - #1020

Merged
joeberkovitz merged 8 commits into
gh-pagesfrom
966-clarify-awgs-relationships
Jan 4, 2017
Merged

joeberkovitz merged 8 commits into
gh-pagesfrom
966-clarify-awgs-relationships

Conversation

@joeberkovitz

Copy link
Copy Markdown

This is a fix for #966.

@hoch hoch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like more and more that we need to have a separate introduction doc for this type of information.

Comment thread index.html
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not entirely sure why this non-normative section is necessary. Being user-friendly is certainly nice, but this information is too non-normative and the algorithm above is good enough to explain what's happening technically. @rtoy @padenot WDYT?

@joeberkovitz

Copy link
Copy Markdown
Author

@rtoy @padenot I would like to get this PR merged and I've only heard from @hoch so far. Although a separate intro doc would be nice, I think that can be deferred.

@rtoy rtoy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay!

Comment thread index.html Outdated
<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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"in 1:1" -> "in a 1:1"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread index.html Outdated
impulse response.
</div>
<div class="note">
Every <a>AudioWorkletGlobalScope</a> is associated with at most one

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread index.html
</p>
<figure>
<img alt="AudioWorklet sequence" src=
"images/audioProcessorInstantiation.png" width="917" height="546">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this figure be better if it really were a sequence diagram?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rtoy is there further need for changes or may I merge this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 rtoy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but I'd like hoch@ to take a look too.

@joeberkovitz

Copy link
Copy Markdown
Author

@hoch, @rtoy asked me to ask you to take a look at this :) Want to merge it if possible...

@hoch hoch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment thread index.html
with <a>AudioWorkletNode</a>s in the main scope.
</p>
<p>
At least one <a>AudioWorkletGlobalScope</a> exists for each

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least

Are we allowing multiple AWGSs for an AudioContext?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the non-observability of multiple AWGS is also normative: we are formally stating that they are not allowed to have observable effects.

Comment thread index.html Outdated
<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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leave 'module' out? Or do you have a reference this is actually the 'module' pattern?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I'm removing module.

Comment thread index.html Outdated
impulse response.
</div>
<div class="note">
Every <a>AudioWorkletGlobalScope</a> is associated with at most one

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread index.html
</p>
<figure>
<img alt="AudioWorklet sequence" src=
"images/audioProcessorInstantiation.png" width="917" height="546">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread index.html Outdated
<img alt="AudioWorklet sequence" src=
"images/audioProcessorInstantiation.png" width="917" height="546">
<figcaption>
<a><code>AudioWorklet</code></a> sequence

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<code> tags are redundant. Or it doesn't work in the <figcaption>?

Comment thread index.html
imported module scripts is run, including the one that was
previously imported.
</li>
<li>As part of running the imported script, an

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider this scenario:

  1. worklet.import('moduleA');
  2. Context A created. (with AWGS A)
  3. worklet.import('moduleB');
  4. 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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread index.html
</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>.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's mark that up when it happens.

Comment thread index.html Outdated
</li>
<li>An instance of the <a>AudioWorkletProcessor</a> subclass is
instantiated with a structured clone of the same <code>opts</code>
dictionary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I reached here, this section reads like a rough description of 'instantiation process'. Perhaps we should focus on explaining relationship between classes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what relationship you want to explain - can you elaborate?

@joeberkovitz

Copy link
Copy Markdown
Author

@hoch I've responded to your comments and my hope is that this is ready to merge - PTAL. Thanks!

@hoch hoch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@joeberkovitz
joeberkovitz merged commit d21f20e into gh-pages Jan 4, 2017
@mjwilson-google
mjwilson-google deleted the 966-clarify-awgs-relationships branch October 29, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants