w3c / picture-in-picture

Picture-in-Picture (PiP)
https://w3c.github.io/picture-in-picture
Other
309 stars 38 forks source link

Investigate if the algorithm and the implementations need to be updated #229

Open beaufortfrancois opened 3 months ago

beaufortfrancois commented 3 months ago

As originally posted by @marcoscaceres in https://github.com/w3c/picture-in-picture/pull/227#discussion_r1635906594:

this algorithm is wrong then. Above it says it runs “in parallel”, and you can see from both implementations that it’s running on the main thread. This needs be updated to return a promise rejected with X and the later run the steps in parallel.

We need to investigate if the algorithm and the implementations need to be updated.

tidoust commented 3 months ago

We need to investigate if the algorithm and the implementations need to be updated.

I note that the two algorithms that the spec currently says run "in parallel" must be updated, regardless of whether implementations need to be. As written, they are incorrect: a Promise cannot be resolved/rejected directly within steps that run in parallel. If the steps do run in parallel, then a task must be queued. See guidance in Dealing with the event loop in HTML and in particular "you must not directly access main-thread artifacts from a background thread [...] Doing so would create data races observable to JavaScript code"