Bug 176840 - Media elements do not continue playing when moved in the DOM.
Summary: Media elements do not continue playing when moved in the DOM.
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Macintosh macOS 10.12
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-13 08:20 PDT by Thomas Wisniewski
Modified: 2017-09-14 05:34 PDT (History)
3 users (show)

See Also:


Attachments
Testcase for <video> element (656 bytes, text/html)
2017-09-13 08:20 PDT, Thomas Wisniewski
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.