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

Inconsistencies in constructor descriptions and factory method initialization #2073

Closed
karlt opened this issue Oct 4, 2019 · 2 comments · Fixed by #2092
Closed

Inconsistencies in constructor descriptions and factory method initialization #2073

karlt opened this issue Oct 4, 2019 · 2 comments · Fixed by #2092
Assignees
Projects
Milestone

Comments

@karlt
Copy link
Contributor

karlt commented Oct 4, 2019

The Web Audio API specifies an algorithm to create an AudioNode of a particular type using its constructor.

Many descriptions of constructors more or less repeat that algorithm, but without explicitly passing arguments to the algorithm for Initializing an object that inherits from AudioNode.
e.g. the AudioBufferSourceNode constructor.

Some descriptions of constructors use a similar algorithm, but extended to perform additional initialization (e.g. the MediaStreamAudioSourceNode ).

The AudioWorkletNode constructor description is a little different in that the algorithm initializes this instead of creating and returning a new object.

The approach for AudioWorkletNode seems more consistent with the WebIDL spec which says that
The prose definition of a constructor operation must either initialize the value passed as this, or throw an exception.
The WebIDL algorithm for creation of an interface object with the ECMAScript binding will "Perform the actions listed in the description of constructor with values as the argument values and object as this" and so it would not seem appropriate for the description of the constructor to return a new object.

Given that each particular type describes the steps for the constructor and WebIDL describes the steps for creation from ECMAScript and that the generic algorithm is not complete for all "particular type"s, I guess it would be best to remove the generic algorithm "to create an AudioNode of a particular type n using its constructor".

Also, the algorithm "to create a new AudioNode of a particular type n using its factory method" does not invoke the constructor, and so does not contain any type-specific additional initialization steps, such as those in the MediaStreamAudioSourceNode constructor. Perhaps this should invoke the constructor instead of the "Intialize" algorithm.

@rtoy
Copy link
Member

rtoy commented Oct 9, 2019

I believe this is an artifact of when we added the node constructors in addition to the factory methods, and we wanted to use a generic algorithm to describe the construction since they are all very similar. And because we didn't want to duplicate much of the algorithm across every single node.

@padenot padenot self-assigned this Oct 10, 2019
@mdjp mdjp added this to the Web Audio V1 milestone Oct 10, 2019
@rtoy rtoy added this to Untriaged in V1 via automation Oct 10, 2019
@padenot
Copy link
Member

padenot commented Oct 10, 2019

Taking this:

  1. Remove the generic ctor algorithm in favour of one for each type that calls the "initialize" algorithm, and pass the arguments appropriately.
  2. Change the generic factory method algorithm to call the ctor underneath, so that the "initialize" algorithm is called and the specific initialization is performed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
V1
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants