-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MSE] ManagedMediaSource isn't usable in a DedicatedWorker
https://bugs.webkit.org/show_bug.cgi?id=270891 rdar://124499286 Reviewed by Youenn Fablet. The HTMLMediaElement was never attached to the MediaSource (or ManagedMediaSource) running in the dedicated worker. While this didn't prevent MediaSource to work, it would have caused the ManagedMediaSource to never move to the `Open` readyState as the MMS need to check the HTMLMediaElement if an AirPlay alternative is present. The MediaSourceHandle uses the ensureOnDispatcher utility to dispatch to the MediaSource dispatcher, which will not run the function should MediaSource::isClosed() return true. We need to force the function to run when we attach the HTMLMediaElement which in turn will move the readyState to `open`. Added test. * LayoutTests/media/media-source/worker/media-managedmse-worker-expected.txt: Added. * LayoutTests/media/media-source/worker/media-managedmse-worker.html: Added. * LayoutTests/media/media-source/worker/worker.js: Added. (logToMain): (onmessage): * LayoutTests/platform/glib/TestExpectations: * Source/WebCore/Modules/mediasource/MediaSourceHandle.cpp: (WebCore::MediaSourceHandle::ensureOnDispatcher const): * Source/WebCore/Modules/mediasource/MediaSourceHandle.h: * Source/WebCore/Modules/mediasource/MediaSourceInterfaceWorker.cpp: (WebCore::MediaSourceInterfaceWorker::attachToElement): Canonical link: https://commits.webkit.org/276140@main
- Loading branch information
Showing
7 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
LayoutTests/media/media-source/worker/media-managedmse-worker-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
RUN(video.disableRemotePlayback = true) | ||
received handle message: [object MediaSourceHandle] OK | ||
info message from worker: sourceopen event received OK | ||
END OF TEST | ||
|
34 changes: 34 additions & 0 deletions
34
LayoutTests/media/media-source/worker/media-managedmse-worker.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> <!-- webkit-test-runner [ ManagedMediaSourceEnabled=true MediaSourceEnabled=true ] --> | ||
<html> | ||
<head> | ||
<title>managedmediasource in worker</title> | ||
<script src="../../../media/video-test.js"></script> | ||
<script> | ||
window.addEventListener('load', async event => { | ||
findMediaElement(); | ||
|
||
const worker = new Worker('worker.js'); | ||
worker.onmessage = msg => { | ||
switch (msg.data.topic) { | ||
case 'handle': | ||
logResult(true, 'received handle message: ' + msg.data.arg); | ||
video.srcObject = msg.data.arg; | ||
break; | ||
case 'info': | ||
logResult(true, 'info message from worker: ' + msg.data.arg); | ||
endTest(); | ||
break; | ||
default: | ||
logResult(false, 'error: Unrecognized topic in message from worker'); | ||
break; | ||
} | ||
}; | ||
run('video.disableRemotePlayback = true'); | ||
worker.postMessage({ }); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<video controls></video> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function logToMain(msg) { | ||
postMessage({topic: 'info', arg: msg}); | ||
} | ||
|
||
onmessage = (e) => { | ||
const ms = new ManagedMediaSource(); | ||
const handle = ms.handle; | ||
|
||
ms.onsourceopen = () => { | ||
logToMain("sourceopen event received"); | ||
}; | ||
// Transfer the MediaSourceHandle to the main thread for use in attaching to | ||
// the main thread media element that will play the content being buffered | ||
// here in the worker. | ||
postMessage({topic: 'handle', arg: handle}, [handle]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters