Fix tasks for enterPictureInPicture and exitPictureInPicture.#233
Fix tasks for enterPictureInPicture and exitPictureInPicture.#233markafoltz wants to merge 1 commit into
Conversation
|
Should also close #225 |
|
@markafoltz From what I can see in https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/document_picture_in_picture/picture_in_picture_controller_impl.cc;l=158?q=kMediaElementEvent%20f:picture&ss=chromium%2Fchromium%2Fsrc, Chromium's implementation will no longer comply with the spec. I may be wrong about this but is this what we want ? Note that this PR is related to #229 |
|
It should be impossible to fire events or resolve promises off of the main thread in Blink, so where do you see Chrome not complying? (Sorry I don't know the PiP code.) |
|
Thanks for the pointer as well, this should also close #229 |
Like I said, I may be wrong, but https://source.chromium.org/search?q=kMediaElementEvent%20f:picture&sq=&ss=chromium%2Fchromium%2Fsrc returns results where we specifically use the media element task source in Picture-in-Picture, and I'm not sure it covers all the cases you've updated in this PR. An example would be |
| The <a>task source</a> for all the tasks queued in this specification is the | ||
| <a>media element event task source</a> of the video element in question. | ||
|
|
||
| When an algorithm <dfn lt="queue a picture-in-picture task">queues a |
There was a problem hiding this comment.
I wonder if we should just reuse [[queue a media element task]] instead:
https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task
That takes a media element instead it seems... that might make more sense?
| 4. [=Queue a picture-in-picture task=] to [=/resolve=] |promise| with the | ||
| <a>Picture-in-Picture window</a> associated with {{pictureInPictureElement}}. |
There was a problem hiding this comment.
| 4. [=Queue a picture-in-picture task=] to [=/resolve=] |promise| with the | |
| <a>Picture-in-Picture window</a> associated with {{pictureInPictureElement}}. | |
| 4. [=Queue a picture-in-picture task=] to [=/resolve=] |promise| with the | |
| {{pictureInPictureElement}}'s [=picture-in-Picture window=]. |
| 2. If the previous step threw an exception, reject |promise| with that | ||
| 2. If the previous step threw an exception, | ||
| [=queue a picture-in-picture task=] to reject |promise| with that | ||
| exception and abort these steps. |
There was a problem hiding this comment.
| exception and abort these steps. | |
| [=exception=] and abort these steps. |
|
|
||
| 1. Run the <a>exit Picture-in-Picture algorithm</a>. | ||
| 2. If the previous step threw an exception, reject |promise| with that | ||
| 2. If the previous step threw an exception, |
There was a problem hiding this comment.
| 2. If the previous step threw an exception, | |
| 2. If the previous step threw an [=exception=], |
| {{pictureInPictureElement}} changes, the user agent MUST | ||
| <a>queue a picture-in-picture task</a> to <a>fire an event</a> named | ||
| {{resize}} at {{pictureInPictureElement}}. |
There was a problem hiding this comment.
| {{pictureInPictureElement}} changes, the user agent MUST | |
| <a>queue a picture-in-picture task</a> to <a>fire an event</a> named | |
| {{resize}} at {{pictureInPictureElement}}. | |
| {{pictureInPictureElement}} changes, the user agent MUST | |
| <a>queue a picture-in-picture task</a> to [=/fire an event=] named | |
| "{{resize}}" at {{pictureInPictureElement}}. |
|
I want to suggest the PR I've written which covers this, for requestPictureInPicture, but also makes sure to address more issues than just firing events and resolving. There are other problems. It's re-written the |
…not possible Restructures the requestPictureInPicture() algorithm to handle parallel window creation more robustly. The algorithm now creates the Picture-in-Picture window in parallel, then queues subsequent DOM mutations and promise resolutions as a separate task. Key changes: - Steps 1-9 run synchronously with validation checks - Step 10 returns the promise and runs remaining steps in parallel - Within the parallel section, a global task is queued to handle DOM mutations, fire events, and resolve/reject the promise - Enforces one Picture-in-Picture element per top-level browsing context - Mandatorily exits fullscreen when entering PiP - Exits previous PiP session when a new one is requested Addresses #244, #233, and #229. Co-authored-by: Marcos Cáceres <marcos@marcosc.com>
Closes #230: ensures that Promises returned by these methods use the media element task source.
Also fixes several ambiguous cross references.
Preview | Diff