-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework media element removal steps #7855
base: main
Are you sure you want to change the base?
Conversation
As per #2882 "await a stable state" is a problematic concept as it queues a microtask without encompassing task. This replaces its usage here by queuing a task as the media element paused member does not change upon element removal directly. (It's unclear if you can observe the paused member changing before the pause event. As written this seems possible if you are (un)lucky. Potentially this means that the internal pause steps are not correct for this caller. They are correct for at least one other caller: pause().)
(Preexisting issue: this algorithm is not shadow DOM aware.) So the intent of the current spec seems to be to queue a microtask from within the task that removes the element. I don't think it's possible to remove elements without being in a task, so the current spec doesn't seem problematic to me. So this is a normative change. A version of this patch that removes "await a stable state" but isn't a normative change would be something like:
Now, is this normative change closer to implementations? Your test case seems to be asking that question. I fleshed it out a bit and added a click gesture so you can call play() successfully: http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=10260 . The answer appears to be "yes", your change is closer to implementations; all three log "false" in the queued microtask and "true" after 1 second, so it seems like it's some sort of queued task, not a microtask. |
The current spec is problematic because of this:
It's UB when the algorithm is not running in parallel, as is the case here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that's easy to fix, by just allowing any algorithm to await a stable state.
Anyway, per the above, this is a good change either way. So we should write up some WPTs based on the above samples and then merge this.
⌛.)</p></li> | ||
|
||
<li><p>⌛ If the <span>media element</span> is <span>in a document</span>, return.</p></li> | ||
<li><p>If <var>media</var> is <span>in a document</span>, then return.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should "in a document" be used here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs to be "connected", but I'd consider that a separate change. I'd be willing to make it at the same time though if someone figures out the tests.
As per #2882 "await a stable state" is a problematic concept as it queues a microtask without encompassing task.
This replaces its usage here by queuing a task as the media element paused member does not change upon element removal directly.
(It's unclear if you can observe the paused member changing before the pause event. As written this seems possible if you are (un)lucky. Potentially this means that the internal pause steps are not correct for this caller. They are correct for at least one other caller: pause().)
Even the simplest case turned out to be not simple. Here's the test case I played with on Live DOM Viewer:
A follow-up issue for the internal pause steps seems reasonable as they were already broken before this change for this caller. Would love some independent analysis of these things.
(See WHATWG Working Mode: Changes for more details.)
/media.html ( diff )