Skip to content

AudioScheduledSourceNode.start does weird checks that don't match browsers #2142

@bzbarsky

Description

@bzbarsky

https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-start step 1 says:

If stop() has been called on this node, or if an earlier call to start() has already occurred, an InvalidStateError exception MUST be thrown.

I don't think any browsers implement this as written. Consider this testcase:

var ctx = new AudioContext;
var node = new ConstantSourceNode(ctx);
try { node.stop(); } catch (e) {}
node.start();

Per spec as written, the start call should throw, since stop has been called. In practice, browsers do not seem to do it.

Similarly, consider this testcase:

var ctx = new AudioContext;
var node = new ConstantSourceNode(ctx);
try { node.start(-5); } catch (e) {}
node.start();

Again, per spec as written this should clearly throw. It does not throw in browsers.

I suspect that what the spec really aims to do here is to have some internal flag that is initially unset and gets set between the current step 2 and step 3 of the start steps. And then throw in step 1 if that flag is set.

Similarly, the steps for stop should probably check this flag. That's certainly how browsers seem to behave: if there was only a failed call to start, then stop is not allowed. But that's not what https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-stop step 1 says to do.

Metadata

Metadata

Assignees

Labels

Needs EditsDecision has been made, the issue can be fixed. https://speced.github.io/spec-maintenance/about/

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions