Skip to content

AudioWorkletNodeOptions.processorOptions should not default to null. #2011

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

Closed
hoch opened this issue Jul 25, 2019 · 4 comments · Fixed by #2013
Closed

AudioWorkletNodeOptions.processorOptions should not default to null. #2011

hoch opened this issue Jul 25, 2019 · 4 comments · Fixed by #2013
Assignees

Comments

@hoch
Copy link
Member

hoch commented Jul 25, 2019

Describe the issue
Because it is defaulting to null, the processor always get null for the field even the main scope option object is undefined. We should make it a plain object.

object processorOptions;

Where Is It
https://webaudio.github.io/web-audio-api/#dictdef-audioworkletnodeoptions

@guest271314

This comment was marked as off-topic.

@hoch
Copy link
Member Author

hoch commented Jul 25, 2019

The setup code:

const node = new AudioWorkletNode(context, 'processor', nodeOptions);
class extends AudioWorkletProcessor {
  constructor(options){
    console.log(options);
  }
}

When nodeOptions = {}:

{numberOfInputs: 1, numberOfOutputs:1}

When nodeOptions = {foo: 'bar'}:

{numberOfInputs: 1, numberOfOutputs:1}

When nodeOptions = {foo:bar, processorOptions: {foo:'bar'}}:

{numberOfInputs: 1, numberOfOutputs:1, processorOptions: {foo:'bar'}}

@hoch
Copy link
Member Author

hoch commented Jul 25, 2019

From WG Telecon:
Remove the nullable type and the default value from processorOptions.

@karlt
Copy link
Contributor

karlt commented Jul 25, 2019

I'm not aware of any benefit in processorOptions being nullable.

If the value could default to the empty object, then that would permit clients to test for members without throwing a TypeError when processorOptions is not specified, but I don't think it is possible to specify an empty object default in WebIDL.

So, yes, the proposed change seems the best option available.

guest271314 added a commit to guest271314/wpt that referenced this issue Apr 15, 2020
Substitute checking `options.processorOptions.<property>` for `options.<property>` WebAudio/web-audio-api#2011; `this._recordChannelCount` for `input.length` to avoid `cannot read length of undefined` error when `input.length` is greater than `this._recordChannelCount`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants