Bug 176840

Summary: Media elements do not continue playing when moved in the DOM.
Product: WebKit Reporter: Thomas Wisniewski <wisniewskit>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: eric.carlson, jeremyj-wk, jer.noble, thisiskatewinslet
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Mac   
OS: macOS 10.12   
Attachments:
Description Flags
Testcase for <video> element none

Description Thomas Wisniewski 2017-09-13 08:20:12 PDT
Created attachment 320641 [details]
Testcase for  <video> element

Based on the attached test-case (and the resolution of https://bugzilla.mozilla.org/show_bug.cgi?id=1398341), it seems that WebKit will restart playback of a media element when it is moved in the DOM.

Firefox and Edge continue playback smoothly as per spec (see https://bugzilla.mozilla.org/show_bug.cgi?id=1398341 for context), while Chrome currently erroneously pauses the element (bug: https://bugs.chromium.org/p/chromium/issues/detail?id=737744)

(This behavior was uncovered while investigating an interop/webcompat issue: https://webcompat.com/issues/8777)
Comment 1 Eric Carlson 2017-09-14 05:34:30 PDT
It looks like we are pausing the element to early:

https://dev.w3.org/html5/spec-preview/media-elements.html#playing-the-media-resource

When a media element is removed from a Document, the user agent must run the following steps:

  1. Asynchronously await a stable state, allowing the task that removed the media element from the Document to continue. The synchronous section consists of all the remaining steps of this algorithm. (Steps in the synchronous section are marked with ⌛.)

  2. ⌛ If the media element is in a Document, abort these steps.

  3. ⌛ If the media element's networkState attribute has the value NETWORK_EMPTY, abort these steps.

  4. ⌛ Pause the media element.