Closed Bug 1672028 Opened 4 years ago Closed 4 years ago

[wpt-sync] Sync PR 26109 - MSE-in-Workers: Cross-thread function and tests

Categories

(Core :: Audio/Video: Playback, task, P4)

task

Tracking

()

RESOLVED FIXED
84 Branch
Tracking Status
firefox84 --- fixed

People

(Reporter: mozilla.org, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 26109 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/26109
Details from upstream follow.

b'Matt Wolenetz <wolenetz@chromium.org>' wrote:

MSE-in-Workers: Cross-thread function and tests

Includes implementation of CrossThreadMediaSourceAttachment (CTMSA) and
updates to MediaSource and SourceBuffer to use it.

CTMSA owns a lock that it takes on most operations. It also provides a
utility method (RunExclusively()), which is used by the MSE API to take
that same lock during most operations on the API. The same thread
attachment provides a basic version of the same, though no lock is used.

CTMSA understands whether or not it is attached, has ever started
closing, and whether or not either of the attached contexts has ever
destructed. It conditions cross-thread operations to safely behave when
one or both contexts is being destructed.

MediaSource is given its own small lock that it uses to guard its
reference to the attachment instance, when attached. This is required
because attachment start is synchronous on the main thread, even if the
MediaSource is owned by worker context. CTMSA and MediaSource cooperate
to ensure mutex and safety of the two-stage attachment start. In
MediaSource::ContextDestroyed(), further care is taken to prevent
attachment start success when worker context destruction is possibly
racing the main thread's attempt to start attachment.
context_already_destroyed_, protected by MediaSource's lock, is used
to prevent that start from succeeding.

MediaSource's context destruction can no longer always assume that
accessing the demuxer via the WebMediaSource (and WebSourceBuffers) is
safe. The worker version of MediaSource context destruction uses the
attachment's RunExclusively() to safely know if it can cleanly Close the
underlying demuxer, or if instead it must do a simpler shutdown.

Future specification work will likely determine some signal to the media
element when the worker-owned MediaSource's context is shutdown, yet the
element itself is still alive. For now, sane results are returned by the
attachment (nothing buffered nor seekable), with no other error
provided. Possible app workarounds might include main and worker
watchdogs and being careful about when the main thread explicitly
terminates the worker.

This experimental implementation attempts to retain
BackgroundVideoOptimization, even for MSE-in-Workers, but does not
support AudioVideoTracks in the worker MediaSource or SourceBuffer.
Plumbing of appropriately-identified track metadata parsed from
initialization segment in the worker is used to populate (and remove)
media element AudioVideoTracks that should agree with the track id's
used internally in WebMediaPlayerImpl to accomplish
BackgroundVideoOptimization.

As a simplification, CTMSA assumes it can be used for at most one
attachment. Effectively, this assumes that the currently on-by-default
MediaSourceRevokeObjectURLOnAttach feature behavior will be always-on
soon. If CTMSA is not unregistered automatically after successful
attachment start (e.g., if that feature is disabled) and if the app
attempts to re-use the corresponding object URL for a later attachment,
that attachment will be rejected by CTMSA. Note that the same-thread
attachment would still allow such re-use when that feature is disabled.

Updated web-test:
mediasource-worker-attach.html changed to ...-play.html and fixed
New web-test:
mediasource-worker-play-terminate-worker.html
Manual test: page refreshing while running mediasource-worker-play*.html

BUG=878133

Change-Id: I21f6542b90d51bdc28096500fb1441d202ab4ee8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2459431
Commit-Queue: Matthew Wolenetz \<wolenetz@chromium.org>
Reviewed-by: Will Cassella \<cassew@google.com>
Cr-Commit-Position: refs/heads/master@{#818174}

Component: web-platform-tests → Audio/Video: Playback
Product: Testing → Core

CI Results

Ran 12 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 3 tests and 1 subtests

Status Summary

Firefox

OK : 1
PASS : 1[Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub] 3[Gecko-android-em-7.0-x86_64-opt-geckoview] 10[Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt]
FAIL : 25[Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt] 32[Gecko-android-em-7.0-x86_64-opt-geckoview] 34[Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub]
ERROR: 2

Chrome

OK : 1
PASS : 15
FAIL : 20
ERROR: 2

Safari

PASS : 5
FAIL : 30
ERROR: 3

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

Firefox-only Failures

/media-source/dedicated-worker/mediasource-worker-play-terminate-worker.html
Test worker MediaSource termination after at least 1 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt]
Test worker MediaSource termination after at least 2 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt]
Test worker MediaSource termination after at least 3 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt]
Test worker MediaSource termination after at least 4 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt]

New Tests That Don't Pass

/media-source/dedicated-worker/mediasource-worker-objecturl.html: ERROR (Chrome: OK, Safari: ERROR)
Test main context revocation of worker MediaSource object URL: FAIL (Chrome: PASS, Safari: FAIL)
MediaSource construction succeeds with initial closed readyState in dedicated worker: FAIL (Chrome: PASS, Safari: FAIL)
URL.createObjectURL(mediaSource) in dedicated worker returns a Blob URI: FAIL (Chrome: PASS, Safari: FAIL)
URL.revokeObjectURL(mediaSource) in dedicated worker with two url for same MediaSource: FAIL (Chrome: PASS, Safari: FAIL)
/media-source/dedicated-worker/mediasource-worker-play-terminate-worker.html: ERROR (Chrome: ERROR, Safari: ERROR)
Test worker MediaSource termination after at least 1 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt] (Chrome: PASS, Safari: PASS)
Test worker MediaSource termination after at least 2 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt] (Chrome: PASS, Safari: PASS)
Test worker MediaSource termination after at least 3 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt] (Chrome: PASS, Safari: PASS)
Test worker MediaSource termination after at least 4 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt] (Chrome: PASS, Safari: PASS)
Test worker MediaSource termination after at least 5 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt] (Chrome: PASS, Safari: FAIL)
Test worker MediaSource termination after at least 6 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt] (Chrome: PASS, Safari: FAIL)
Test worker MediaSource termination after at least 7 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt] (Chrome: PASS, Safari: FAIL)
Test worker MediaSource termination after at least 8 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt] (Chrome: PASS, Safari: FAIL)
Test worker MediaSource termination after at least 9 main thread setTimeouts, starting counting before setting src: FAIL [Gecko-android-em-7.0-x86_64-opt-geckoview, Gecko-linux1804-64-debug, Gecko-linux1804-64-opt, Gecko-linux1804-64-qr-debug, Gecko-linux1804-64-qr-opt, Gecko-windows7-32-debug, GitHub], PASS [Gecko-android-em-7.0-x86_64-debug-geckoview, Gecko-windows10-64-debug, Gecko-windows10-64-opt, Gecko-windows10-64-qr-debug, Gecko-windows10-64-qr-opt, Gecko-windows7-32-opt] (Chrome: PASS, Safari: FAIL)
Test worker MediaSource termination after at least 0 main thread setTimeouts, starting counting after setting src: FAIL (Chrome: PASS, Safari: FAIL)
Test worker MediaSource termination after at least 1 main thread setTimeouts, starting counting after setting src: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 2 main thread setTimeouts, starting counting after setting src: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 3 main thread setTimeouts, starting counting after setting src: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 4 main thread setTimeouts, starting counting after setting src: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 5 main thread setTimeouts, starting counting after setting src: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 6 main thread setTimeouts, starting counting after setting src: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 7 main thread setTimeouts, starting counting after setting src: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 8 main thread setTimeouts, starting counting after setting src: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 9 main thread setTimeouts, starting counting after setting src: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 0 main thread setTimeouts, starting counting after first ended event: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 1 main thread setTimeouts, starting counting after first ended event: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 2 main thread setTimeouts, starting counting after first ended event: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 3 main thread setTimeouts, starting counting after first ended event: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 4 main thread setTimeouts, starting counting after first ended event: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 5 main thread setTimeouts, starting counting after first ended event: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 6 main thread setTimeouts, starting counting after first ended event: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 7 main thread setTimeouts, starting counting after first ended event: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 8 main thread setTimeouts, starting counting after first ended event: FAIL (Chrome: FAIL, Safari: FAIL)
Test worker MediaSource termination after at least 9 main thread setTimeouts, starting counting after first ended event: FAIL (Chrome: FAIL, Safari: FAIL)
/media-source/dedicated-worker/mediasource-worker-play.html
Test worker MediaSource construction, attachment, buffering and basic playback: FAIL (Chrome: FAIL, Safari: FAIL)

Pushed by wptsync@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/fa103e2c9735
[wpt PR 26109] - MSE-in-Workers: Cross-thread function and tests, a=testonly
https://hg.mozilla.org/integration/autoland/rev/5ce326e76d6d
[wpt PR 26109] - Update wpt metadata, a=testonly
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch
You need to log in before you can comment on or make changes to this bug.