WICG / video-rvfc

video.requestVideoFrameCallback() incubation
https://wicg.github.io/video-rvfc/
Other
54 stars 19 forks source link

Test the behavior of removing a video element from its parent #30

Closed foolip closed 4 years ago

foolip commented 4 years ago

The behavior per the spec is pretty clear (no more callbacks) but this is worth testing, as you might accidentally get some other behavior if you don't think of it.

tguilbert-google commented 4 years ago

When removing an element from its parents, the callbacks stop, as expected. However, they are stopping because we automatically pause the video, and not because we prevent callbacks from being fired if we aren't part of the DOM. Playing the video after removing it from the DOM causes callbacks to fire again.

Also, setting display:none (as opposed to calling video.parentNode.removeChild(video)) doesn't pause the video, and callbacks are still fired (but at the background render rate of 250ms).

Here's a quick test page

foolip commented 4 years ago

Sounds like the behavior is well-worth testing! Does the spec say enough about what should happen here such that tests in WPT could be added to cover this?

tguilbert-google commented 4 years ago

Since the comment I mentioned, there have been some relevant implementation updates: Chromium now fires callbacks for out-of-DOM elements at the same rate as elements on the page (as opposed to the 250ms background render rate). There was also for a while the question of having the callback and identifiers be tied to the DOM, but that issue brought up more technical difficulties than benefits (#25).

I think that now that there is no difference between in and out of DOM elements, and that the callbacks+ids are truly per-video, a simple test might be "removing the element from the DOM and making sure callbacks still fire". I don't know if there things worth calling out in the spec however. Maybe that "out-of-DOM elements should still fire their callbacks when played"?

foolip commented 4 years ago

A simple test like that sounds good if there's nothing in the spec or anything it depends on that treats detached elements any differently. The spec also need not say anything about it, unless there's some place in it where one would naturally ask the question.

tguilbert-google commented 4 years ago

The tests have been added. Thanks!