Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define when and how regular tasks are processed wrt the processing model #2301

Merged
merged 3 commits into from Feb 19, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 28 additions & 8 deletions index.bs
Expand Up @@ -10085,6 +10085,9 @@ Every {{AudioWorkletProcessor}} has an associated <dfn>active source</dfn> flag,
the node to be retained in memory and perform audio processing in
the absence of any connected inputs.

All tasks posted from an {{AudioWorkletNode}} are posted to the task queue of
padenot marked this conversation as resolved.
Show resolved Hide resolved
its associated {{BaseAudioContext}}.

<xmp class="idl">
[Exposed=Window]
interface AudioParamMap {
Expand Down Expand Up @@ -11115,12 +11118,20 @@ in the algorithm of <a href="#rendering-a-graph">rendering a graph</a>.
finished.
</div>

The audio callback is also queued as a task in the
<a href="#control-message-queue">control message queue</a>. The UA MUST perform
The audio callback is also queued as a task in the <a
href="#control-message-queue">control message queue</a>. The UA MUST perform
Copy link
Member

Choose a reason for hiding this comment

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

nit: do we need to indent here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No idea. I'll check locally by running bikeshed and merge as is if needed, or fixed if not. Thanks for the quick re-review!

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member Author

Choose a reason for hiding this comment

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

(bikeshed accepts it).

the following algorithms to process render quanta to fulfill such task by
filling up the requested buffer size. Along with the primary message queue, the
<a>rendering thread</a> has another task queue for microtasks for any microtask
operation such as resolution of {{Promise}}s in the {{AudioWorkletGlobalScope}}.
filling up the requested buffer size. Along with the <a>control message
queue</a>, each {{AudioContext}} has a regular <a
href="https://html.spec.whatwg.org/multipage/webappapis.html#task-queue">task
queue</a>, called its <dfn for="BaseAudioContext">associated task queue</dfn>
for tasks that are posted to the rendering thread from the control thread. An
additional microtask checkpoint is performed after processing a render quantum
to run any microtasks that might have been queued during the execution of the
`process` methods of {{AudioWorkletProcessor}}.

All tasks posted from an {{AudioWorkletNode}} are posted to the [=associated
task queue=] of its associated {{BaseAudioContext}}.

<div id="rendering-initialization" algorithm="initialize rendering loop">
The following step MUST be performed once before the rendering loop starts.
Expand All @@ -11131,6 +11142,8 @@ operation such as resolution of {{Promise}}s in the {{AudioWorkletGlobalScope}}.
</div>

<div id="rendering-a-graph" algorithm="rendering a graph">
The following steps MUST be performed when rendering a render quantum.

1. Let <var>render result</var> be <code>false</code>.

2. Process the [=control message queue=].
Expand All @@ -11147,7 +11160,14 @@ operation such as resolution of {{Promise}}s in the {{AudioWorkletGlobalScope}}.

2. Remove the [=oldest message=] of <var>Q<sub>rendering</sub></var>.

3. Process a render quantum.

3. Process the {{BaseAudioContext}}'s [=associated task queue=].

1. Let <var>task count</var> be the number of tasks in the task queue of the {{AudioContext}} being rendered.

2. Spin the event loop until <var>task count</var> tasks have been executed.
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need task count? Can we just say:

"Run the event loop until all queued tasks in Q are executed."

(Q can be defined somewhere)

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't found a way to define this more cleanly, this is unambiguous. In particular, I haven't found a way to define Q. I'm happy to hear any idea though.


4. Process a render quantum.

1. If the <a>rendering thread state</a> of the {{BaseAudioContext}} is not
<code>running</code>, return false.
Expand Down Expand Up @@ -11311,9 +11331,9 @@ operation such as resolution of {{Promise}}s in the {{AudioWorkletGlobalScope}}.

7. Set <var>render result</var> to <code>true</code>.

4. [=Perform a microtask checkpoint=].
5. [=Perform a microtask checkpoint=].

5. Return <var>render result</var>.
6. Return <var>render result</var>.
</div>

<dfn id="mute">Muting</dfn> an {{AudioNode}} means that its
Expand Down