w3c / webcodecs

WebCodecs is a flexible web API for encoding and decoding audio and video.
https://w3c.github.io/webcodecs/
Other
985 stars 136 forks source link

Clarify the `Clone configuration` algorithm #762

Closed padenot closed 8 months ago

padenot commented 8 months ago

When looking a Clone Configuration, and after having found a bug in Gecko, a DOM developer said:

This looks very underspecified in the spec. For one, I don't think any spec defines what assign a copy of config[m] to clone[m] means. And either that can throw exceptions, and it should be specified what needs to happen, or it doesn't and we need to figure out what to do in our implementation.

It can throw an exception, a minimal test case (adapted from our bug) would be:

var buf = new ArrayBuffer(4);
buf.transferToFixedLength()
VideoDecoder.isConfigSupported({"codec": "፝a", "description":buf})

Chromium says:

Uncaught (in promise) TypeError: Failed to execute 'isConfigSupported' on 'VideoDecoder': description is detached.

which makes sense to me, but we need to spec it.

padenot commented 8 months ago

Meaning checking if an exception has been thrown, and rejecting the promise.

padenot commented 8 months ago

Same deal with VideoDecoder.configure() with a detached array buffer. Curiously the configuration isn't cloned in this case, but the same behaviour in Chrome (which I also find sensible).

sandersdan commented 8 months ago

Conceptually this could also be part of the valid VideoDecoderConfig algorithm, which makes sense for something throwing a TypeError.

Djuffin commented 8 months ago

I agree that it does sound like a part of config validation