w3c / webcodecs

WebCodecs is a flexible web API for encoding and decoding audio and video.

Home Page:https://w3c.github.io/webcodecs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Task or microtask for invoking error callbacks?

dalecurtis opened this issue · comments

Spec language for invoking the error callback says to "queue a task":
https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task

Actually following this advice breaks some web platform tests. E.g.,
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/external/wpt/webcodecs/audio-encoder.https.any.js;l=196;drc=004515931845095d994006bca1401c3bf94ecb68

It seems reasonable to expect the error callback to have been delivered after awaiting flush; so I think we want to change the language around invoking the error callback to "queue a microtask":
https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-microtask

@padenot @youennf @Djuffin @aboba

Alternatively, we could invoke the error callback before rejecting pending flush promises.

Alternatively, we could invoke the error callback before rejecting pending flush promises.

I think that's what we should do

We generally tend to stay away from queuing micro tasks explicitly.

See discussion in web-platform-tests/interop#382 (comment) and web-platform-tests/interop#382 (comment), This would guarantee the flush promise to reject after the error callback is executed.

This turned out to be a bug in our implementation, so I don't think we need to change this after all.