-
Notifications
You must be signed in to change notification settings - Fork 168
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
Revise sanity checks on AudioWorkletProcessor.process() method #1773
Conversation
index.bs
Outdated
<var>processor</var>. | ||
|
||
9. <a>Queue a task</a> the <a>control thread</a> to set the associated | ||
1. <a>Queue a task</a> the <a>control thread</a> to set the associated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're modifying this anyway: "Queue a task the" -> "Queue a task to the".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
index.bs
Outdated
to [=Computing a block of audio|compute a block of audio=] with | ||
the argument of [=input buffer=], output buffer and | ||
[=input AudioParam buffer=]. | ||
4. If this {{AudioNode}} is an {{AudioWorkletNode}}, execute these step: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"step:" -> "steps:"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
index.bs
Outdated
|
||
3. If <code><a href="http://www.ecma-international.org/ecma-262/6.0/#sec-iscallable"> | ||
IsCallable</a>(argument=<i><var>processFunction</var></i>)</code> is | ||
false, throw a {{TypeError}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not ReferenceError if the function doesn't exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am no expert on ES6 abstract operation, but technically IsCallable
checks if the target is function
type. So I think TypeError
is correct here.
Example: https://www.ecma-international.org/ecma-262/7.0/#sec-getmethod
index.bs
Outdated
@@ -9848,7 +9848,8 @@ custom audio node. {{AudioWorkletProcessor}} can | |||
only be instantiated by the construction of an | |||
{{AudioWorkletNode}} instance. Every | |||
{{AudioWorkletProcessor}} has an associated <dfn>node | |||
reference</dfn>, initially null. | |||
reference</dfn> and <dfn>callable process</dfn> that are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these internal slots (conceptually)? If so, we should probably use the [[foo]]
notation to indicate that. If not, then these dfn's define the terms without really defining the what the terms mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the [[foo]]
notation for the internal slot that are used by ECMAScript operation? We don't keep node reference in that way because it's not used by the operation itself. It is only used by the algorithm defined in the spec. I think callable process is same as well.
With that said, I am no expert on this issue and not sure what's the right way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. But we use it all over some for slots like [[buffer set]]
or [[internal reduction]]
and these aren't all ECMAScript operations.
Nevertheless, the dfn
don't define anything really, so a little bit of text about what it is would be useful. Or maybe you really just want them to be <var>
s for the algorithm. This probably requires a bit more work.
index.bs
Outdated
|
||
1. The associated {{AudioWorkletProcessor}}'s | ||
<a>active source</a> flag is equal to `true`. | ||
1. <a>callable process</a> is `true`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should not use numeric items since ordering is not needed?
index.bs
Outdated
[=input AudioParam buffer=]. | ||
4. If this {{AudioNode}} is an {{AudioWorkletNode}}, execute these steps: | ||
|
||
1. If <a>callable process</a> is `false`, abort the following sub steps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to indent this some more. I see that this step is labeled 5.
Also, when the following steps are aborted, where do we go from here? What's the next step in the algorithm?
index.bs
Outdated
IsCallable</a>(argument=<i><var>processFunction</var></i>)</code> is | ||
false, execute the following: | ||
|
||
1. Queue a control message to fire `onprocessorerror` event on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice (but not necessary) if onprocessorerror
were a link to the attribute.
index.bs
Outdated
1. Queue a control message to fire `onprocessorerror` event on the | ||
associated AudioWorkletNode. | ||
|
||
1. Set <a>callable process</a> to `false`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The algorithm flow is to continue after setting this to false. Is that what you want? I think not since IsCallable
returned false, you shouldn't call the process
method in the next step.
index.bs
Outdated
|
||
: <dfn>[[callable process]]</dfn> | ||
:: | ||
A boolean flag represents whether {{AudioWorkletProcessor/process()}} is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably s/represents/representing/
index.bs
Outdated
: <dfn>[[callable process]]</dfn> | ||
:: | ||
A boolean flag represents whether {{AudioWorkletProcessor/process()}} is | ||
a valid function that can ba invoked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/ba invoked/be invoked/
index.bs
Outdated
<dfn dfn>active processing conditions</dfn> are true: | ||
every <a>render quantum</a>, if both conditions are met: | ||
|
||
* {{{[[callable process]]}} is `true`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/{{{/{{/
|
||
9. <a>Queue a task</a> the <a>control thread</a> to set the associated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to queue anything anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. statechange
event for AudioWorkletNode is removed. So we don't have to do anything here. It was simply an oversight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine except for one nit.
[=input AudioParam buffer=]. | ||
|
||
1. Else if {{[[callable process]]}} is `false`, | ||
<a>Queue a control message</a> to fire `onprocessorerror` event on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we specify the type of error that occurred?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be an Event
on the main thread, so it is not an actual ErrorEvent
. You can't throw an error on the main thread, because technically it is an error from the other side.
What we can do instead is to throw a TypeError
in AWGS before queueing a message, but it will halt the entire AWGS and that's not what we want here.
I think we have now is sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was just basically wondering if we could provide some kind of info in the Event about what happened. This isn't required, but we know exactly why we're sending a message and it would be nice to let the user also know exactly why instead of just some random Event object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but the Event
object does not have a valid field to fill with the detailed error message. For the Event.type
, you'll get processorerror
.
Also defining a better error reporting for AWP should be a separate piece of work. I've been meaning to do that, but this becomes also useless when you have a proper error handling mechanism in WGS.
Fixes: #1767
process
function check in AudioWorkletProcessor instantiation.callable process
internal slot to AudioWorkletProcessor.process
function.Preview | Diff