Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW TEST(276140@main): [ MacOS WK1 Debug ] media/media-source/worker/media-managedmse-worker.html is a constant crash #26236

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

EXPECTED (ManagedMediaSource.canConstructInDedicatedWorker == 'true') OK
RUN(video.disableRemotePlayback = true)
received handle message: [object MediaSourceHandle] OK
info message from worker: sourceopen event received OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@
window.addEventListener('load', async event => {
findMediaElement();

testExpected('ManagedMediaSource.canConstructInDedicatedWorker', true);
const worker = new Worker('worker.js');
worker.onmessage = msg => {
switch (msg.data.topic) {
case 'handle':
case 'handle':
logResult(true, 'received handle message: ' + msg.data.arg);
video.srcObject = msg.data.arg;
break;
case 'info':
case 'info':
logResult(true, 'info message from worker: ' + msg.data.arg);
endTest();
break;
default:
case 'error':
logResult(false, 'error message from worker: ' + msg.data.arg);
endTest();
break;
default:
logResult(false, 'error: Unrecognized topic in message from worker');
break;
}
Expand Down
27 changes: 17 additions & 10 deletions LayoutTests/media/media-source/worker/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@ function logToMain(msg) {
postMessage({topic: 'info', arg: msg});
}

onmessage = (e) => {
const ms = new ManagedMediaSource();
const handle = ms.handle;
function logErrorToMain(msg) {
postMessage({topic: 'error', arg: msg});
}

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]);
onmessage = (e) => {
try {
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]);
} catch (e) {
logErrorToMain('MSE not supported');
}
};
2 changes: 0 additions & 2 deletions LayoutTests/platform/mac-wk1/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -2823,8 +2823,6 @@ webkit.org/b/270385 [ Sonoma+ ] fast/images/jpegxl-with-color-profile.html [ Ima

webkit.org/b/259485 [ Ventura ] http/tests/media/hls/track-in-band-multiple-cues.html [ Skip ]

webkit.org/b/271323 [ Debug ] media/media-source/worker/media-managedmse-worker.html [ Skip ]

# webkit.org/b/270199 [ MacOS WK1 Debug ] fast/frames/lots-of-iframes.html and fast/frames/lots-of-objects.html are consistent/flaky timeouts
[ Debug ] fast/frames/lots-of-iframes.html [ Pass Timeout ]
[ Debug ] fast/frames/lots-of-objects.html [ Pass Timeout ]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

EXPECTED (ManagedMediaSource.canConstructInDedicatedWorker == 'true'), OBSERVED 'false' FAIL
RUN(video.disableRemotePlayback = true)
error message from worker: MSE not supported FAIL
END OF TEST

1 change: 1 addition & 0 deletions Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4300,6 +4300,7 @@ MediaSourceInWorkerEnabled:
humanReadableName: "MediaSource in a Worker"
humanReadableDescription: "MediaSource in a Worker"
condition: ENABLE(MEDIA_SOURCE_IN_WORKERS)
exposed: [ WebCore, WebKit ]
defaultValue:
WebKitLegacy:
default: false
Expand Down
6 changes: 4 additions & 2 deletions Source/WebCore/Modules/mediasource/MediaSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
#endif
#include "MediaSourcePrivate.h"
#include "MediaSourceRegistry.h"
#include "MediaStrategy.h"
#include "PlatformStrategies.h"
#include "Quirks.h"
#include "ScriptExecutionContext.h"
#include "Settings.h"
Expand Down Expand Up @@ -1579,7 +1581,7 @@ bool MediaSource::enabledForContext(ScriptExecutionContext& context)
UNUSED_PARAM(context);
#if ENABLE(MEDIA_SOURCE_IN_WORKERS)
if (context.isWorkerGlobalScope())
return context.settingsValues().mediaSourceInWorkerEnabled;
return context.settingsValues().mediaSourceInWorkerEnabled && platformStrategies()->mediaStrategy().hasThreadSafeMediaSourceSupport();
#endif

ASSERT(context.isDocument());
Expand All @@ -1601,7 +1603,7 @@ Ref<MediaSourceHandle> MediaSource::handle()

bool MediaSource::canConstructInDedicatedWorker(ScriptExecutionContext& context)
{
return context.settingsValues().mediaSourceInWorkerEnabled;
return context.settingsValues().mediaSourceInWorkerEnabled && platformStrategies()->mediaStrategy().hasThreadSafeMediaSourceSupport();
}

#endif
Expand Down
5 changes: 5 additions & 0 deletions Source/WebCore/platform/MediaStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ void MediaStrategy::resetMediaEngines()
m_mockMediaSourceEnabled = false;
}

bool MediaStrategy::hasThreadSafeMediaSourceSupport() const
{
return false;
}

#if ENABLE(MEDIA_SOURCE)
void MediaStrategy::enableMockMediaSource()
{
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/platform/MediaStrategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class WEBCORE_EXPORT MediaStrategy {
#endif
virtual std::unique_ptr<NowPlayingManager> createNowPlayingManager() const;
void resetMediaEngines();
virtual bool hasThreadSafeMediaSourceSupport() const;
#if ENABLE(MEDIA_SOURCE)
virtual void enableMockMediaSource();
bool mockMediaSourceEnabled() const;
Expand Down
6 changes: 5 additions & 1 deletion Source/WebCore/platform/PlatformStrategies.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#pragma once

#include <mutex>

namespace WebCore {

class BlobRegistry;
Expand Down Expand Up @@ -53,8 +55,9 @@ class PlatformStrategies {

MediaStrategy& mediaStrategy()
{
if (!m_mediaStrategy)
std::call_once(m_onceKeyForMediaStrategies, [&] {
m_mediaStrategy = createMediaStrategy();
});
return *m_mediaStrategy;
}

Expand Down Expand Up @@ -89,6 +92,7 @@ class PlatformStrategies {

LoaderStrategy* m_loaderStrategy { };
PasteboardStrategy* m_pasteboardStrategy { };
std::once_flag m_onceKeyForMediaStrategies;
MediaStrategy* m_mediaStrategy { };
BlobRegistry* m_blobRegistry { };

Expand Down
12 changes: 12 additions & 0 deletions Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ WebMediaStrategy::~WebMediaStrategy() = default;
Ref<WebCore::AudioDestination> WebMediaStrategy::createAudioDestination(WebCore::AudioIOCallback& callback, const String& inputDeviceId,
unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate)
{
ASSERT(isMainRunLoop());
#if ENABLE(GPU_PROCESS)
if (m_useGPUProcess)
return WebCore::SharedAudioDestination::create(callback, numberOfOutputChannels, sampleRate, [inputDeviceId, numberOfInputChannels, numberOfOutputChannels, sampleRate] (WebCore::AudioIOCallback& callback) {
Expand All @@ -67,6 +68,7 @@ Ref<WebCore::AudioDestination> WebMediaStrategy::createAudioDestination(WebCore:

std::unique_ptr<WebCore::NowPlayingManager> WebMediaStrategy::createNowPlayingManager() const
{
ASSERT(isMainRunLoop());
#if ENABLE(GPU_PROCESS)
if (m_useGPUProcess) {
class NowPlayingInfoForGPUManager : public WebCore::NowPlayingManager {
Expand All @@ -88,9 +90,19 @@ std::unique_ptr<WebCore::NowPlayingManager> WebMediaStrategy::createNowPlayingMa
return WebCore::MediaStrategy::createNowPlayingManager();
}

bool WebMediaStrategy::hasThreadSafeMediaSourceSupport() const
{
#if ENABLE(GPU_PROCESS)
return m_useGPUProcess;
#else
return false;
#endif
}

#if ENABLE(MEDIA_SOURCE)
void WebMediaStrategy::enableMockMediaSource()
{
ASSERT(isMainRunLoop());
#if USE(AVFOUNDATION)
WebCore::DeprecatedGlobalSettings::setAVFoundationEnabled(false);
#endif
Expand Down
4 changes: 3 additions & 1 deletion Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#pragma once

#include <WebCore/MediaStrategy.h>
#include <atomic>

namespace WebKit {

Expand All @@ -43,12 +44,13 @@ class WebMediaStrategy final : public WebCore::MediaStrategy {
const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate) override;
#endif
std::unique_ptr<WebCore::NowPlayingManager> createNowPlayingManager() const final;
bool hasThreadSafeMediaSourceSupport() const final;
#if ENABLE(MEDIA_SOURCE)
void enableMockMediaSource() final;
#endif

#if ENABLE(GPU_PROCESS)
bool m_useGPUProcess { false };
std::atomic<bool> m_useGPUProcess { false };
#endif
};

Expand Down