Diff
Modified: trunk/Source/WTF/ChangeLog (290173 => 290174)
--- trunk/Source/WTF/ChangeLog 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WTF/ChangeLog 2022-02-18 22:43:33 UTC (rev 290174)
@@ -1,3 +1,13 @@
+2022-02-18 Eric Carlson <eric.carl...@apple.com>
+
+ [macOS] Allow screen and window capture to be done in the GPU Process
+ https://bugs.webkit.org/show_bug.cgi?id=236815
+ <rdar://problem/89117278>
+
+ Reviewed by Jer Noble.
+
+ * Scripts/Preferences/WebPreferencesExperimental.yaml: Add UseGPUProcessForDisplayCapture.
+
2022-02-18 Brandon Stewart <brandonstew...@apple.com>
Generate compile_commands.json on macOS Builds
Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (290173 => 290174)
--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml 2022-02-18 22:43:33 UTC (rev 290174)
@@ -1420,6 +1420,17 @@
WebKit:
default: defaultUseGPUProcessForDOMRenderingEnabled()
+UseGPUProcessForDisplayCapture:
+ type: bool
+ humanReadableName: "GPU Process: Screen and Window capture"
+ humanReadableDescription: "Display capture in GPU Process"
+ webcoreBinding: none
+ condition: HAVE(SC_CONTENT_SHARING_SESSION)
+ exposed: [ WebKit ]
+ defaultValue:
+ WebKit:
+ default: false
+
UseGPUProcessForWebGLEnabled:
type: bool
humanReadableName: "GPU Process: WebGL"
Modified: trunk/Source/WebCore/ChangeLog (290173 => 290174)
--- trunk/Source/WebCore/ChangeLog 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebCore/ChangeLog 2022-02-18 22:43:33 UTC (rev 290174)
@@ -1,3 +1,34 @@
+2022-02-18 Eric Carlson <eric.carl...@apple.com>
+
+ [macOS] Allow screen and window capture to be done in the GPU Process
+ https://bugs.webkit.org/show_bug.cgi?id=236815
+ <rdar://problem/89117278>
+
+ Reviewed by Jer Noble.
+
+ Tested manually.
+
+ * platform/mediastream/mac/ScreenCaptureKitCaptureSource.h:
+ * platform/mediastream/mac/ScreenCaptureKitCaptureSource.mm:
+ (WebCore::ScreenCaptureKitCaptureSource::sessionDidChangeContent): Call CaptureDevice
+ constructor directly since we have everything it needs.
+ (WebCore::findSharableDevice): Extract logic from processSharableContent into a
+ static function so it can be reused.
+ (WebCore::ScreenCaptureKitCaptureSource::findShareableContent): Use findSharableDevice.
+ (WebCore::ScreenCaptureKitCaptureSource::streamConfiguration): Add logging.
+ (WebCore::ScreenCaptureKitCaptureSource::startContentStream): Ditto.
+ (WebCore::ScreenCaptureKitCaptureSource::captureDeviceWithPersistentID):
+ (WebCore::ScreenCaptureKitCaptureSource::processSharableContent): Deleted.
+ * platform/mediastream/mac/ScreenCaptureKitSharingSessionManager.h:
+ (WebCore::ScreenCaptureKitSharingSessionManager::SharingSessionObserver::operator== const): Deleted.
+
+ * platform/mediastream/mac/ScreenCaptureKitSharingSessionManager.mm:
+ (WebCore::ScreenCaptureKitSharingSessionManager::isAvailable):
+ (WebCore::ScreenCaptureKitSharingSessionManager::sessionDidChangeContent): Call
+ CaptureDevice constructor directly since we have everything it needs.
+ (WebCore::ScreenCaptureKitSharingSessionManager::promptForGetDisplayMedia): Call
+ completion handler if the class is not available.
+
2022-02-18 Alan Bujtas <za...@apple.com>
[LFC][IFC] Fix ideographic baseline for atomic inline level boxes with non-zero descent
Modified: trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.h (290173 => 290174)
--- trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.h 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.h 2022-02-18 22:43:33 UTC (rev 290174)
@@ -66,6 +66,9 @@
static std::optional<CaptureDevice> windowCaptureDeviceWithPersistentID(const String&);
WEBCORE_EXPORT static void windowDevices(Vector<DisplayCaptureManager::WindowCaptureDevice>&);
+ static void captureDeviceWithPersistentID(CaptureDevice::DeviceType, uint32_t, CompletionHandler<void(std::optional<CaptureDevice>)>&&);
+
+ using Content = std::variant<RetainPtr<SCWindow>, RetainPtr<SCDisplay>>;
void streamFailedWithError(RetainPtr<NSError>&&, const String&);
enum class SampleType { Video };
void streamDidOutputSampleBuffer(RetainPtr<CMSampleBufferRef>, SampleType);
@@ -87,7 +90,6 @@
const char* logClassName() const final { return "ScreenCaptureKitCaptureSource"; }
void startContentStream();
- void processSharableContent(RetainPtr<SCShareableContent>&&, RetainPtr<NSError>&&);
void findShareableContent();
RetainPtr<SCStreamConfiguration> streamConfiguration();
void updateStreamConfiguration();
@@ -97,9 +99,7 @@
dispatch_queue_t captureQueue();
- using Content = std::variant<RetainPtr<SCWindow>, RetainPtr<SCDisplay>>;
std::optional<Content> m_content;
-
RetainPtr<WebCoreScreenCaptureKitHelper> m_captureHelper;
RetainPtr<CMSampleBufferRef> m_currentFrame;
RetainPtr<SCContentFilter> m_contentFilter;
Modified: trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.mm (290173 => 290174)
--- trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.mm 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.mm 2022-02-18 22:43:33 UTC (rev 290174)
@@ -216,7 +216,7 @@
{
ASSERT(isAvailable());
- ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
+ ALWAYS_LOG_IF_POSSIBLE(LOGIDENTIFIER);
if (m_isRunning)
return true;
@@ -232,7 +232,7 @@
if (!m_isRunning)
return;
- ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
+ ALWAYS_LOG_IF_POSSIBLE(LOGIDENTIFIER);
m_isRunning = false;
@@ -274,12 +274,14 @@
std::optional<CaptureDevice> device;
SCContentFilter* content = [session content];
switch (content.type) {
- case SCContentFilterTypeDesktopIndependentWindow:
- device = windowCaptureDeviceWithPersistentID(String::number(content.desktopIndependentWindowInfo.window.windowID));
+ case SCContentFilterTypeDesktopIndependentWindow: {
+ auto *window = content.desktopIndependentWindowInfo.window;
+ device = CaptureDevice(String::number(window.windowID), CaptureDevice::DeviceType::Window, window.title, emptyString(), true);
m_content = content.desktopIndependentWindowInfo.window;
break;
+ }
case SCContentFilterTypeDisplay:
- device = screenCaptureDeviceWithPersistentID(String::number(content.displayInfo.display.displayID));
+ device = CaptureDevice(String::number(content.displayInfo.display.displayID), CaptureDevice::DeviceType::Screen, makeString("Screen"), emptyString(), true);
m_content = content.displayInfo.display;
break;
case SCContentFilterTypeNothing:
@@ -289,7 +291,7 @@
return;
}
if (!device) {
- streamFailedWithError(nil, "Failed find CaptureDevice after content change"_s);
+ streamFailedWithError(nil, "Failed to find CaptureDevice after content changed"_s);
return;
}
@@ -308,40 +310,33 @@
return m_currentFrame;
}
-void ScreenCaptureKitCaptureSource::processSharableContent(RetainPtr<SCShareableContent>&& shareableContent, RetainPtr<NSError>&& error)
+static void findSharableDevice(RetainPtr<SCShareableContent>&& shareableContent, CaptureDevice::DeviceType deviceType, uint32_t deviceID, CompletionHandler<void(std::optional<ScreenCaptureKitCaptureSource::Content>, uint32_t)>&& completionHandler)
{
ASSERT(isMainRunLoop());
- if (error) {
- streamFailedWithError(WTFMove(error), "-[SCStream getShareableContentWithCompletionHandler:] failed"_s);
- return;
- }
-
- if (m_captureDevice.type() == CaptureDevice::DeviceType::Screen) {
+ uint32_t index = 0;
+ std::optional<ScreenCaptureKitCaptureSource::Content> content;
+ if (deviceType == CaptureDevice::DeviceType::Screen) {
[[shareableContent displays] enumerateObjectsUsingBlock:makeBlockPtr([&] (SCDisplay *display, NSUInteger, BOOL *stop) {
- if (display.displayID == m_deviceID) {
- m_content = display;
+ if (display.displayID == deviceID) {
+ content = display;
*stop = YES;
}
+ ++index;
}).get()];
- } else if (m_captureDevice.type() == CaptureDevice::DeviceType::Window) {
+ } else if (deviceType == CaptureDevice::DeviceType::Window) {
[[shareableContent windows] enumerateObjectsUsingBlock:makeBlockPtr([&] (SCWindow *window, NSUInteger, BOOL *stop) {
- if (window.windowID == m_deviceID) {
- m_content = window;
+ if (window.windowID == deviceID) {
+ content = window;
*stop = YES;
}
+ ++index;
}).get()];
} else {
ASSERT_NOT_REACHED();
- return;
}
- if (!m_content) {
- streamFailedWithError(nil, "capture device not found"_s);
- return;
- }
-
- startContentStream();
+ completionHandler(WTFMove(content), index);
}
void ScreenCaptureKitCaptureSource::findShareableContent()
@@ -348,10 +343,28 @@
{
ASSERT(!m_content);
- [PAL::getSCShareableContentClass() getShareableContentWithCompletionHandler:makeBlockPtr([weakThis = WeakPtr { *this }] (SCShareableContent *shareableContent, NSError *error) mutable {
- callOnMainRunLoop([weakThis = WTFMove(weakThis), shareableContent = RetainPtr { shareableContent }, error = RetainPtr { error }]() mutable {
- if (weakThis)
- weakThis->processSharableContent(WTFMove(shareableContent), WTFMove(error));
+ ALWAYS_LOG_IF_POSSIBLE(LOGIDENTIFIER);
+
+ [PAL::getSCShareableContentClass() getShareableContentWithCompletionHandler:makeBlockPtr([this, weakThis = WeakPtr { *this }, identifier = LOGIDENTIFIER] (SCShareableContent *shareableContent, NSError *error) mutable {
+ callOnMainRunLoop([this, weakThis = WTFMove(weakThis), shareableContent = RetainPtr { shareableContent }, error = RetainPtr { error }, identifier]() mutable {
+ if (!weakThis)
+ return;
+
+ if (error) {
+ streamFailedWithError(WTFMove(error), "-[SCStream getShareableContentWithCompletionHandler:] failed"_s);
+ return;
+ }
+
+ ALWAYS_LOG_IF_POSSIBLE(identifier, "have content list");
+
+ findSharableDevice(WTFMove(shareableContent), m_captureDevice.type(), m_deviceID, [this, weakThis = WTFMove(weakThis)] (std::optional<Content> content, uint32_t) mutable {
+ if (!content) {
+ streamFailedWithError(nil, "capture device not found"_s);
+ return;
+ }
+ m_content = WTFMove(content);
+ startContentStream();
+ });
});
}).get()];
}
@@ -361,6 +374,8 @@
if (m_streamConfiguration)
return m_streamConfiguration;
+ ALWAYS_LOG_IF_POSSIBLE(LOGIDENTIFIER);
+
m_streamConfiguration = adoptNS([PAL::allocSCStreamConfigurationInstance() init]);
[m_streamConfiguration setPixelFormat:preferedPixelBufferFormat()];
[m_streamConfiguration setShowsCursor:YES];
@@ -385,6 +400,8 @@
void ScreenCaptureKitCaptureSource::startContentStream()
{
+ ALWAYS_LOG_IF_POSSIBLE(LOGIDENTIFIER);
+
if (m_contentStream)
return;
@@ -430,7 +447,7 @@
if (!m_contentStream) {
- streamFailedWithError(nil, "Failed to allocate ContentStream"_s);
+ streamFailedWithError(nil, "Failed to allocate SCStream"_s);
return;
}
@@ -443,13 +460,15 @@
}
}
- auto completionHandler = makeBlockPtr([weakThis = WeakPtr { *this }] (NSError *error) mutable {
- if (!error)
- return;
+ auto completionHandler = makeBlockPtr([this, weakThis = WeakPtr { *this }, identifier = LOGIDENTIFIER] (NSError *error) mutable {
+ callOnMainRunLoop([this, weakThis = WTFMove(weakThis), error = RetainPtr { error }, identifier]() mutable {
+ if (!weakThis)
+ return;
- callOnMainRunLoop([weakThis = WTFMove(weakThis), error = RetainPtr { error }]() mutable {
- if (weakThis)
- weakThis->streamFailedWithError(WTFMove(error), "-[SCStream startCaptureWithFrameHandler:completionHandler:] failed"_s);
+ if (error)
+ streamFailedWithError(WTFMove(error), "-[SCStream startCaptureWithFrameHandler:completionHandler:] failed"_s);
+ else
+ ALWAYS_LOG_IF_POSSIBLE(identifier, "stream started");
});
});
@@ -623,6 +642,38 @@
return m_captureDevice.type() == CaptureDevice::DeviceType::Screen ? RealtimeMediaSourceSettings::DisplaySurfaceType::Monitor : RealtimeMediaSourceSettings::DisplaySurfaceType::Window;
}
+void ScreenCaptureKitCaptureSource::captureDeviceWithPersistentID(CaptureDevice::DeviceType deviceType, uint32_t deviceID, CompletionHandler<void(std::optional<CaptureDevice>)>&& completionHandler)
+{
+ [PAL::getSCShareableContentClass() getShareableContentWithCompletionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), deviceID, deviceType] (SCShareableContent *shareableContent, NSError *error) mutable {
+ callOnMainRunLoop([shareableContent = RetainPtr { shareableContent }, error = RetainPtr { error }, completionHandler = WTFMove(completionHandler), deviceID, deviceType]() mutable {
+
+ if (error) {
+ RELEASE_LOG_ERROR(WebRTC, "getShareableContentWithCompletionHandler failed with error %s", [[error localizedDescription] UTF8String]);
+ completionHandler(std::nullopt);
+ return;
+ }
+
+ findSharableDevice(WTFMove(shareableContent), deviceType, deviceID, [completionHandler = WTFMove(completionHandler)] (std::optional<Content> content, uint32_t index) mutable {
+ if (!content) {
+ RELEASE_LOG_ERROR(WebRTC, "capture device not found");
+ return;
+ }
+
+ auto device = switchOn(content.value(),
+ [index] (const RetainPtr<SCDisplay> display) -> std::optional<CaptureDevice> {
+ return CaptureDevice(String::number([display displayID]), CaptureDevice::DeviceType::Screen, makeString("Screen ", index), emptyString(), true);
+ },
+ [] (const RetainPtr<SCWindow> window) -> std::optional<CaptureDevice> {
+ return CaptureDevice(String::number([window windowID]), CaptureDevice::DeviceType::Window, [window title], emptyString(), true);
+ }
+ );
+
+ completionHandler(WTFMove(device));
+ });
+ });
+ }).get()];
+}
+
std::optional<CaptureDevice> ScreenCaptureKitCaptureSource::screenCaptureDeviceWithPersistentID(const String& displayIDString)
{
if (!isAvailable()) {
Modified: trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitSharingSessionManager.h (290173 => 290174)
--- trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitSharingSessionManager.h 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitSharingSessionManager.h 2022-02-18 22:43:33 UTC (rev 290174)
@@ -30,6 +30,7 @@
#include <wtf/Vector.h>
#include <wtf/WeakPtr.h>
+OBJC_CLASS SCContentFilter;
OBJC_CLASS SCContentSharingSession;
OBJC_CLASS WebDisplayMediaPromptHelper;
@@ -39,25 +40,9 @@
class ScreenCaptureKitSharingSessionManager : public CanMakeWeakPtr<ScreenCaptureKitSharingSessionManager> {
public:
- class SharingSessionObserver : public CanMakeWeakPtr<SharingSessionObserver> {
- public:
- virtual ~SharingSessionObserver() = default;
-
- enum class Type { Screen, Window };
- virtual Type sessionType() const = 0;
- virtual uint32_t sessionID() const = 0;
-
- virtual void sessionChanged() = 0;
- virtual void sessionEnded() = 0;
-
- bool operator==(const SharingSessionObserver& other) const
- {
- return sessionType() == other.sessionType() && sessionID() == other.sessionID();
- }
- };
-
WEBCORE_EXPORT static ScreenCaptureKitSharingSessionManager& singleton();
WEBCORE_EXPORT static bool isAvailable();
+ WEBCORE_EXPORT static bool shouldUseSystemPicker();
ScreenCaptureKitSharingSessionManager();
~ScreenCaptureKitSharingSessionManager();
@@ -64,9 +49,6 @@
RetainPtr<SCContentSharingSession> takeSharingSessionForFilter(SCContentFilter*);
- RetainPtr<SCContentSharingSession> addSharingSessionObserver(SharingSessionObserver&);
- void removeSharingSessionObserver(SharingSessionObserver&);
-
void sessionDidChangeContent(RetainPtr<SCContentSharingSession>);
void pickerCanceledForSession(RetainPtr<SCContentSharingSession>);
void sessionDidEnd(RetainPtr<SCContentSharingSession>);
Modified: trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitSharingSessionManager.mm (290173 => 290174)
--- trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitSharingSessionManager.mm 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitSharingSessionManager.mm 2022-02-18 22:43:33 UTC (rev 290174)
@@ -127,9 +127,7 @@
bool ScreenCaptureKitSharingSessionManager::isAvailable()
{
return screenCaptureKitPickerFeatureEnabled()
- && WTF::processHasEntitlement("com.apple.private.screencapturekit.sharingsession")
- && PAL::getSCContentSharingSessionClass()
- && ScreenCaptureKitCaptureSource::isAvailable();
+ && PAL::getSCContentSharingSessionClass();
}
ScreenCaptureKitSharingSessionManager& ScreenCaptureKitSharingSessionManager::singleton()
@@ -208,11 +206,13 @@
std::optional<CaptureDevice> device;
SCContentFilter* content = [session content];
switch (content.type) {
- case SCContentFilterTypeDesktopIndependentWindow:
- device = ScreenCaptureKitCaptureSource::windowCaptureDeviceWithPersistentID(String::number(content.desktopIndependentWindowInfo.window.windowID));
+ case SCContentFilterTypeDesktopIndependentWindow: {
+ auto *window = content.desktopIndependentWindowInfo.window;
+ device = CaptureDevice(String::number(window.windowID), CaptureDevice::DeviceType::Window, window.title, emptyString(), true);
break;
+ }
case SCContentFilterTypeDisplay:
- device = ScreenCaptureKitCaptureSource::screenCaptureDeviceWithPersistentID(String::number(content.displayInfo.display.displayID));
+ device = CaptureDevice(String::number(content.displayInfo.display.displayID), CaptureDevice::DeviceType::Screen, makeString("Screen "), emptyString(), true);
break;
case SCContentFilterTypeNothing:
case SCContentFilterTypeAppsAndWindowsPinnedToDisplay:
@@ -240,8 +240,10 @@
ASSERT(isAvailable());
ASSERT(!m_completionHandler);
- if (!isAvailable() || m_completionHandler)
+ if (!isAvailable()) {
+ completionHandler(std::nullopt);
return;
+ }
SCContentSharingSession* session = [[PAL::getSCContentSharingSessionClass() alloc] initWithTitle:@"WebKit getDisplayMedia Prompt"];
if (!session) {
Modified: trunk/Source/WebKit/ChangeLog (290173 => 290174)
--- trunk/Source/WebKit/ChangeLog 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/ChangeLog 2022-02-18 22:43:33 UTC (rev 290174)
@@ -1,3 +1,57 @@
+2022-02-18 Eric Carlson <eric.carl...@apple.com>
+
+ [macOS] Allow screen and window capture to be done in the GPU Process
+ https://bugs.webkit.org/show_bug.cgi?id=236815
+ <rdar://problem/89117278>
+
+ Reviewed by Jer Noble.
+
+ * GPUProcess/GPUProcess.cpp:
+ (WebKit::GPUProcess::showWindowPicker): Call the picker.
+ (WebKit::GPUProcess::showScreenPicker): Ditto.
+ (WebKit::GPUProcess::setUseScreenCaptureKit):
+ * GPUProcess/GPUProcess.h:
+ * GPUProcess/GPUProcess.messages.in:
+
+ * GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in: Add rule to allow sandbox
+ to be extended dynamically with the mach-lookups required for the picker.
+ * Scripts/process-entitlements.sh: Add entitlements required for picker.
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const): Encode shouldCaptureDisplayInGPUProcess.
+ (WebKit::WebPageCreationParameters::decode): Decode shouldCaptureDisplayInGPUProcess.
+ * Shared/WebPageCreationParameters.h:
+
+ * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+ * UIProcess/GPU/GPUProcessProxy.cpp:
+ (WebKit::addDisplayCaptureSandboxExtension): Create extensions required to use the
+ system picker.
+ (WebKit::GPUProcessProxy::updateSandboxAccess): Add display capture.
+ (WebKit::GPUProcessProxy::updateCaptureAccess): Pass "allowDisplayCapture" to updateSandboxAccess.
+ (WebKit::GPUProcessProxy::showWindowPicker):
+ (WebKit::GPUProcessProxy::showScreenPicker):
+ (WebKit::GPUProcessProxy::updatePreferences):
+ * UIProcess/GPU/GPUProcessProxy.h:
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::creationParameters): Set shouldCaptureDisplayInGPUProcess.
+
+ * UIProcess/mac/DisplayCaptureSessionManager.mm:
+ (WebKit::DisplayCaptureSessionManager::showWindowPicker): Send message to GPU
+ process when necessary.
+ (WebKit::DisplayCaptureSessionManager::showScreenPicker): Ditto.
+
+ * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+ (WebKit::WebPage::platformInitialize): Pass shouldCaptureDisplayInGPUProcess to setupCaptureProcesses.
+
+ * WebProcess/cocoa/UserMediaCaptureManager.cpp:
+ (WebKit::UserMediaCaptureManager::setupCaptureProcesses): Add shouldCaptureDisplayInGPUProcess
+ parameter.
+ (WebKit::UserMediaCaptureManager::DisplayFactory::createDisplayCaptureSource): Deal
+ with GPU process capture.
+ (WebKit::UserMediaCaptureManager::DisplayFactory::setShouldCaptureInGPUProcess):
+ * WebProcess/cocoa/UserMediaCaptureManager.h:
+
2022-02-18 Kate Cheney <katherine_che...@apple.com>
Use async NSSharingServicePicker menu if available
Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.cpp (290173 => 290174)
--- trunk/Source/WebKit/GPUProcess/GPUProcess.cpp 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.cpp 2022-02-18 22:43:33 UTC (rev 290174)
@@ -74,6 +74,14 @@
#include <pal/spi/cg/ImageIOSPI.h>
#endif
+#if HAVE(SCREEN_CAPTURE_KIT)
+#include <WebCore/ScreenCaptureKitCaptureSource.h>
+#endif
+
+#if HAVE(SC_CONTENT_SHARING_SESSION)
+#include <WebCore/ScreenCaptureKitSharingSessionManager.h>
+#endif
+
namespace WebKit {
// We wouldn't want the GPUProcess to repeatedly exit then relaunch when under memory pressure. In particular, we need to make sure the
@@ -347,9 +355,20 @@
{
MockRealtimeMediaSourceCenter::setMockCameraIsInterrupted(isInterrupted);
}
+#endif // ENABLE(MEDIA_STREAM)
-#endif
+#if HAVE(SC_CONTENT_SHARING_SESSION)
+void GPUProcess::showWindowPicker(CompletionHandler<void(std::optional<WebCore::CaptureDevice>)>&& completionHandler)
+{
+ WebCore::ScreenCaptureKitSharingSessionManager::singleton().showWindowPicker(WTFMove(completionHandler));
+}
+void GPUProcess::showScreenPicker(CompletionHandler<void(std::optional<WebCore::CaptureDevice>)>&& completionHandler)
+{
+ WebCore::ScreenCaptureKitSharingSessionManager::singleton().showScreenPicker(WTFMove(completionHandler));
+}
+#endif // HAVE(SC_CONTENT_SHARING_SESSION)
+
#if PLATFORM(MAC)
void GPUProcess::displayConfigurationChanged(CGDirectDisplayID displayID, CGDisplayChangeSummaryFlags flags)
{
@@ -502,6 +521,16 @@
}
#endif
+#if HAVE(SCREEN_CAPTURE_KIT)
+void GPUProcess::setUseScreenCaptureKit(bool use)
+{
+ if (m_useScreenCaptureKit == use)
+ return;
+ m_useScreenCaptureKit = use;
+ WebCore::ScreenCaptureKitCaptureSource::setEnabled(m_useScreenCaptureKit);
+}
+#endif
+
void GPUProcess::webProcessConnectionCountForTesting(CompletionHandler<void(uint64_t)>&& completionHandler)
{
completionHandler(GPUConnectionToWebProcess::objectCountForTesting());
Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.h (290173 => 290174)
--- trunk/Source/WebKit/GPUProcess/GPUProcess.h 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.h 2022-02-18 22:43:33 UTC (rev 290174)
@@ -49,6 +49,7 @@
#endif
namespace WebCore {
+class CaptureDevice;
class NowPlayingManager;
struct MockMediaDevice;
struct ScreenProperties;
@@ -154,6 +155,10 @@
void setMockCameraIsInterrupted(bool);
bool setCaptureAttributionString(const String&);
#endif
+#if HAVE(SC_CONTENT_SHARING_SESSION)
+ void showWindowPicker(CompletionHandler<void(std::optional<WebCore::CaptureDevice>)>&&);
+ void showScreenPicker(CompletionHandler<void(std::optional<WebCore::CaptureDevice>)>&&);
+#endif
#if PLATFORM(MAC)
void displayConfigurationChanged(CGDirectDisplayID, CGDisplayChangeSummaryFlags);
void setScreenProperties(const WebCore::ScreenProperties&);
@@ -183,6 +188,10 @@
void setMediaSourceInlinePaintingEnabled(bool);
#endif
+#if HAVE(SCREEN_CAPTURE_KIT)
+ void setUseScreenCaptureKit(bool);
+#endif
+
#if ENABLE(CFPREFS_DIRECT_MODE)
void notifyPreferencesChanged(const String& domain, const String& key, const std::optional<String>& encodedValue);
void dispatchSimulatedNotificationsForPreferenceChange(const String& key) final;
@@ -221,6 +230,7 @@
HashMap<PAL::SessionID, GPUSession> m_sessions;
WebCore::Timer m_idleExitTimer;
std::unique_ptr<WebCore::NowPlayingManager> m_nowPlayingManager;
+ String m_applicationVisibleName;
#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
mutable std::unique_ptr<RemoteAudioSessionProxyManager> m_audioSessionManager;
#endif
@@ -244,7 +254,9 @@
#if ENABLE(MEDIA_SOURCE) && HAVE(AVSAMPLEBUFFERVIDEOOUTPUT)
bool m_mediaSourceInlinePaintingEnabled { false };
#endif
- String m_applicationVisibleName;
+#if HAVE(SCREEN_CAPTURE_KIT)
+ bool m_useScreenCaptureKit { false };
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.messages.in (290173 => 290174)
--- trunk/Source/WebKit/GPUProcess/GPUProcess.messages.in 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.messages.in 2022-02-18 22:43:33 UTC (rev 290174)
@@ -52,6 +52,11 @@
#endif
+#if HAVE(SC_CONTENT_SHARING_SESSION)
+ ShowWindowPicker() -> (std::optional<WebCore::CaptureDevice> device) Async
+ ShowScreenPicker() -> (std::optional<WebCore::CaptureDevice> device) Async
+#endif
+
#if ENABLE(MEDIA_SOURCE)
SetWebMParserEnabled(bool enabled);
#endif
@@ -72,6 +77,10 @@
SetMediaSourceInlinePaintingEnabled(bool enabled);
#endif
+#if HAVE(SCREEN_CAPTURE_KIT)
+ SetUseScreenCaptureKit(bool use);
+#endif
+
RequestBitmapImageForCurrentTime(WebCore::ProcessIdentifier processIdentifier, WebCore::MediaPlayerIdentifier playerIdentifier) -> (WebKit::ShareableBitmap::Handle handle) Async
#if ENABLE(CFPREFS_DIRECT_MODE)
Modified: trunk/Source/WebKit/GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in (290173 => 290174)
--- trunk/Source/WebKit/GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in 2022-02-18 22:43:33 UTC (rev 290174)
@@ -851,8 +851,23 @@
(iokit-user-client-class "IOUSBDeviceUserClientV2")
(iokit-user-client-class "IOUSBInterfaceUserClientV2"))
(allow device-camera))
+
#endif // PLATFORM(MAC)
+#if HAVE(SC_CONTENT_SHARING_SESSION)
+(allow mach-lookup
+ (require-all
+ (extension "com.apple.webkit.extension.mach")
+ (global-name
+ "com.apple.replaykit.sharingsession.notification"
+ "com.apple.replaykit.sharingsession"
+ "com.apple.tccd.system"
+ "com.apple.replayd"
+ )
+ )
+)
+#endif
+
(allow mach-lookup (with telemetry)
(global-name "com.apple.relatived.tempest")
)
Modified: trunk/Source/WebKit/Scripts/process-entitlements.sh (290173 => 290174)
--- trunk/Source/WebKit/Scripts/process-entitlements.sh 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/Scripts/process-entitlements.sh 2022-02-18 22:43:33 UTC (rev 290174)
@@ -105,6 +105,9 @@
if (( "${TARGET_MAC_OS_X_VERSION_MAJOR}" >= 130000 ))
then
plistbuddy Add :com.apple.private.gpu-restricted bool YES
+ plistbuddy Add :com.apple.private.screencapturekit.sharingsession bool YES
+ plistbuddy Add :com.apple.private.tcc.allow array
+ plistbuddy Add :com.apple.private.tcc.allow:0 string kTCCServiceScreenCapture
fi
plistbuddy Add :com.apple.private.memory.ownership_transfer bool YES
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (290173 => 290174)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2022-02-18 22:43:33 UTC (rev 290174)
@@ -162,6 +162,7 @@
encoder << shouldCaptureVideoInUIProcess;
encoder << shouldCaptureVideoInGPUProcess;
encoder << shouldCaptureDisplayInUIProcess;
+ encoder << shouldCaptureDisplayInGPUProcess;
encoder << shouldRenderCanvasInGPUProcess;
encoder << shouldRenderDOMInGPUProcess;
encoder << shouldPlayMediaInGPUProcess;
@@ -556,6 +557,9 @@
if (!decoder.decode(parameters.shouldCaptureDisplayInUIProcess))
return std::nullopt;
+ if (!decoder.decode(parameters.shouldCaptureDisplayInGPUProcess))
+ return std::nullopt;
+
if (!decoder.decode(parameters.shouldRenderCanvasInGPUProcess))
return std::nullopt;
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (290173 => 290174)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2022-02-18 22:43:33 UTC (rev 290174)
@@ -233,6 +233,7 @@
bool shouldCaptureVideoInUIProcess { false };
bool shouldCaptureVideoInGPUProcess { false };
bool shouldCaptureDisplayInUIProcess { false };
+ bool shouldCaptureDisplayInGPUProcess { false };
bool shouldRenderCanvasInGPUProcess { false };
bool shouldRenderDOMInGPUProcess { false };
bool shouldPlayMediaInGPUProcess { false };
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (290173 => 290174)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2022-02-18 22:43:33 UTC (rev 290174)
@@ -98,6 +98,10 @@
SOFT_LINK_CLASS(WebContentAnalysis, WebFilterEvaluator);
#endif
+#if HAVE(SC_CONTENT_SHARING_SESSION)
+#import <WebCore/ScreenCaptureKitSharingSessionManager.h>
+#endif
+
#if ENABLE(APPLE_PAY_AMS_UI)
SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(AppleMediaServices)
SOFT_LINK_CLASS_OPTIONAL(AppleMediaServices, AMSEngagementRequest)
Modified: trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp (290173 => 290174)
--- trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp 2022-02-18 22:43:33 UTC (rev 290174)
@@ -245,6 +245,38 @@
return true;
}
+#if HAVE(SC_CONTENT_SHARING_SESSION)
+static inline bool addDisplayCaptureSandboxExtension(std::optional<audit_token_t> auditToken, Vector<SandboxExtension::Handle>& extensions)
+{
+ if (!auditToken) {
+ RELEASE_LOG_ERROR(WebRTC, "NULL audit token");
+ return false;
+ }
+
+ auto handle = SandboxExtension::createHandleForMachLookup("com.apple.replaykit.sharingsession.notification"_s, *auditToken);
+ if (!handle)
+ return false;
+ extensions.append(WTFMove(*handle));
+
+ handle = SandboxExtension::createHandleForMachLookup("com.apple.replaykit.sharingsession"_s, *auditToken);
+ if (!handle)
+ return false;
+ extensions.append(WTFMove(*handle));
+
+ handle = SandboxExtension::createHandleForMachLookup("com.apple.tccd.system"_s, *auditToken);
+ if (!handle)
+ return false;
+ extensions.append(WTFMove(*handle));
+
+ handle = SandboxExtension::createHandleForMachLookup("com.apple.replayd"_s, *auditToken);
+ if (!handle)
+ return false;
+ extensions.append(WTFMove(*handle));
+
+ return true;
+}
+#endif
+
#if PLATFORM(IOS)
static inline bool addTCCDSandboxExtension(Vector<SandboxExtension::Handle>& extensions)
{
@@ -258,7 +290,7 @@
}
#endif
-void GPUProcessProxy::updateSandboxAccess(bool allowAudioCapture, bool allowVideoCapture)
+void GPUProcessProxy::updateSandboxAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture)
{
if (m_useMockCaptureDevices)
return;
@@ -272,6 +304,11 @@
if (allowAudioCapture && !m_hasSentMicrophoneSandboxExtension && addMicrophoneSandboxExtension(extensions))
m_hasSentMicrophoneSandboxExtension = true;
+#if HAVE(SC_CONTENT_SHARING_SESSION)
+ if (allowDisplayCapture && !m_hasSentDisplayCaptureSandboxExtension && addDisplayCaptureSandboxExtension(connection()->getAuditToken(), extensions))
+ m_hasSentDisplayCaptureSandboxExtension = true;
+#endif
+
#if PLATFORM(IOS)
if ((allowAudioCapture || allowVideoCapture) && !m_hasSentTCCDSandboxExtension && addTCCDSandboxExtension(extensions))
m_hasSentTCCDSandboxExtension = true;
@@ -284,7 +321,7 @@
void GPUProcessProxy::updateCaptureAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture, WebCore::ProcessIdentifier processID, CompletionHandler<void()>&& completionHandler)
{
- updateSandboxAccess(allowAudioCapture, allowVideoCapture);
+ updateSandboxAccess(allowAudioCapture, allowVideoCapture, allowDisplayCapture);
sendWithAsyncReply(Messages::GPUProcess::UpdateCaptureAccess { allowAudioCapture, allowVideoCapture, allowDisplayCapture, processID }, WTFMove(completionHandler));
}
@@ -317,6 +354,18 @@
{
send(Messages::GPUProcess::SetMockCameraIsInterrupted { isInterrupted }, 0);
}
+#endif // ENABLE(MEDIA_STREAM)
+
+#if HAVE(SC_CONTENT_SHARING_SESSION)
+void GPUProcessProxy::showWindowPicker(CompletionHandler<void(std::optional<WebCore::CaptureDevice>)>&& completionHandler)
+{
+ sendWithAsyncReply(Messages::GPUProcess::ShowWindowPicker { }, WTFMove(completionHandler));
+}
+
+void GPUProcessProxy::showScreenPicker(CompletionHandler<void(std::optional<WebCore::CaptureDevice>)>&& completionHandler)
+{
+ sendWithAsyncReply(Messages::GPUProcess::ShowScreenPicker { }, WTFMove(completionHandler));
+}
#endif
void GPUProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions)
@@ -622,6 +671,14 @@
send(Messages::GPUProcess::SetMediaSourceInlinePaintingEnabled(m_hasEnabledMediaSourceInlinePainting), 0);
}
#endif
+
+#if HAVE(SCREEN_CAPTURE_KIT)
+ if (!m_hasEnabledScreenCaptureKit && preferences.useScreenCaptureKit()) {
+ m_hasEnabledScreenCaptureKit = true;
+ send(Messages::GPUProcess::SetUseScreenCaptureKit(m_hasEnabledScreenCaptureKit), 0);
+ }
+#endif
+
}
}
Modified: trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.h (290173 => 290174)
--- trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.h 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.h 2022-02-18 22:43:33 UTC (rev 290174)
@@ -50,6 +50,7 @@
#endif
namespace WebCore {
+class CaptureDevice;
struct MockMediaDevice;
struct ScreenProperties;
struct SecurityOriginData;
@@ -86,8 +87,14 @@
void removeMockMediaDevice(const String&);
void resetMockMediaDevices();
void setMockCameraIsInterrupted(bool);
+ void updateSandboxAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture);
#endif
+#if HAVE(SC_CONTENT_SHARING_SESSION)
+ void showWindowPicker(CompletionHandler<void(std::optional<WebCore::CaptureDevice>)>&&);
+ void showScreenPicker(CompletionHandler<void(std::optional<WebCore::CaptureDevice>)>&&);
+#endif
+
void removeSession(PAL::SessionID);
#if PLATFORM(MAC)
@@ -136,8 +143,6 @@
void terminateWebProcess(WebCore::ProcessIdentifier);
void processIsReadyToExit();
- void updateSandboxAccess(bool allowAudioCapture, bool allowVideoCapture);
-
#if HAVE(VISIBILITY_PROPAGATION_VIEW)
void didCreateContextForVisibilityPropagation(WebPageProxyIdentifier, WebCore::PageIdentifier, LayerHostingContextID);
#endif
@@ -155,6 +160,7 @@
bool m_hasSentTCCDSandboxExtension { false };
bool m_hasSentCameraSandboxExtension { false };
bool m_hasSentMicrophoneSandboxExtension { false };
+ bool m_hasSentDisplayCaptureSandboxExtension { false };
#endif
#if ENABLE(MEDIA_SOURCE) && ENABLE(VP9)
@@ -177,6 +183,10 @@
bool m_hasEnabledMediaSourceInlinePainting { false };
#endif
+#if HAVE(SCREEN_CAPTURE_KIT)
+ bool m_hasEnabledScreenCaptureKit { false };
+#endif
+
HashSet<PAL::SessionID> m_sessionIDs;
};
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (290173 => 290174)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2022-02-18 22:43:33 UTC (rev 290174)
@@ -317,6 +317,10 @@
#import "DisplayCaptureSessionManager.h"
#endif
+#if HAVE(SC_CONTENT_SHARING_SESSION)
+#import <WebCore/ScreenCaptureKitSharingSessionManager.h>
+#endif
+
#define MESSAGE_CHECK(process, assertion) MESSAGE_CHECK_BASE(assertion, process->connection())
#define MESSAGE_CHECK_URL(process, url) MESSAGE_CHECK_BASE(checkURLReceivedFromCurrentOrPreviousWebProcess(process, url), process->connection())
#define MESSAGE_CHECK_COMPLETION(process, assertion, completion) MESSAGE_CHECK_COMPLETION_BASE(assertion, process->connection(), completion)
@@ -8437,6 +8441,7 @@
parameters.shouldEnableVP9SWDecoder = preferences().vp9DecoderEnabled() && (!WebCore::systemHasBattery() || preferences().vp9SWDecoderEnabledOnBattery());
#endif
parameters.shouldCaptureDisplayInUIProcess = m_process->processPool().configuration().shouldCaptureDisplayInUIProcess();
+ parameters.shouldCaptureDisplayInGPUProcess = preferences().useGPUProcessForDisplayCapture();
#if ENABLE(APP_BOUND_DOMAINS)
parameters.limitsNavigationsToAppBoundDomains = m_limitsNavigationsToAppBoundDomains;
#endif
Modified: trunk/Source/WebKit/UIProcess/mac/DisplayCaptureSessionManager.mm (290173 => 290174)
--- trunk/Source/WebKit/UIProcess/mac/DisplayCaptureSessionManager.mm 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/UIProcess/mac/DisplayCaptureSessionManager.mm 2022-02-18 22:43:33 UTC (rev 290174)
@@ -32,6 +32,8 @@
#import "MediaPermissionUtilities.h"
#import "WKWebViewInternal.h"
#import "WebPageProxy.h"
+#import "WebProcess.h"
+#import "WebProcessPool.h"
#import <WebCore/CaptureDeviceManager.h>
#import <WebCore/LocalizedStrings.h>
#import <WebCore/MockRealtimeMediaSourceCenter.h>
@@ -201,7 +203,14 @@
#if HAVE(SC_CONTENT_SHARING_SESSION)
if (WebCore::ScreenCaptureKitSharingSessionManager::isAvailable()) {
- WebCore::ScreenCaptureKitSharingSessionManager::singleton().showWindowPicker(WTFMove(completionHandler));
+ if (!page.preferences().useGPUProcessForDisplayCapture()) {
+ WebCore::ScreenCaptureKitSharingSessionManager::singleton().showWindowPicker(WTFMove(completionHandler));
+ return;
+ }
+
+ auto& gpuProcess = page.process().processPool().ensureGPUProcess();
+ gpuProcess.updateSandboxAccess(false, false, true);
+ gpuProcess.showWindowPicker(WTFMove(completionHandler));
return;
}
#endif
@@ -218,7 +227,7 @@
});
}
-void DisplayCaptureSessionManager::showScreenPicker(WebPageProxy&, const WebCore::SecurityOriginData&, CompletionHandler<void(std::optional<WebCore::CaptureDevice>)>&& completionHandler)
+void DisplayCaptureSessionManager::showScreenPicker(WebPageProxy& page, const WebCore::SecurityOriginData&, CompletionHandler<void(std::optional<WebCore::CaptureDevice>)>&& completionHandler)
{
if (m_indexOfDeviceSelectedForTesting) {
completionHandler(deviceSelectedForTesting(WebCore::CaptureDevice::DeviceType::Screen));
@@ -227,7 +236,14 @@
#if HAVE(SC_CONTENT_SHARING_SESSION)
if (WebCore::ScreenCaptureKitSharingSessionManager::isAvailable()) {
- WebCore::ScreenCaptureKitSharingSessionManager::singleton().showScreenPicker(WTFMove(completionHandler));
+ if (!page.preferences().useGPUProcessForDisplayCapture()) {
+ WebCore::ScreenCaptureKitSharingSessionManager::singleton().showScreenPicker(WTFMove(completionHandler));
+ return;
+ }
+
+ auto& gpuProcess = page.process().processPool().ensureGPUProcess();
+ gpuProcess.updateSandboxAccess(false, false, true);
+ gpuProcess.showScreenPicker(WTFMove(completionHandler));
return;
}
#endif
Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (290173 => 290174)
--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2022-02-18 22:43:33 UTC (rev 290174)
@@ -71,7 +71,7 @@
#if ENABLE(MEDIA_STREAM)
if (auto* captureManager = WebProcess::singleton().supplement<UserMediaCaptureManager>())
- captureManager->setupCaptureProcesses(parameters.shouldCaptureAudioInUIProcess, parameters.shouldCaptureAudioInGPUProcess, parameters.shouldCaptureVideoInUIProcess, parameters.shouldCaptureVideoInGPUProcess, parameters.shouldCaptureDisplayInUIProcess, m_page->settings().webRTCRemoteVideoFrameEnabled());
+ captureManager->setupCaptureProcesses(parameters.shouldCaptureAudioInUIProcess, parameters.shouldCaptureAudioInGPUProcess, parameters.shouldCaptureVideoInUIProcess, parameters.shouldCaptureVideoInGPUProcess, parameters.shouldCaptureDisplayInUIProcess, parameters.shouldCaptureDisplayInGPUProcess, m_page->settings().webRTCRemoteVideoFrameEnabled());
#endif
}
Modified: trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp (290173 => 290174)
--- trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp 2022-02-18 22:43:33 UTC (rev 290174)
@@ -71,16 +71,17 @@
return "UserMediaCaptureManager";
}
-void UserMediaCaptureManager::setupCaptureProcesses(bool shouldCaptureAudioInUIProcess, bool shouldCaptureAudioInGPUProcess, bool shouldCaptureVideoInUIProcess, bool shouldCaptureVideoInGPUProcess, bool shouldCaptureDisplayInUIProcess, bool shouldUseGPUProcessRemoteFrames)
+void UserMediaCaptureManager::setupCaptureProcesses(bool shouldCaptureAudioInUIProcess, bool shouldCaptureAudioInGPUProcess, bool shouldCaptureVideoInUIProcess, bool shouldCaptureVideoInGPUProcess, bool shouldCaptureDisplayInUIProcess, bool shouldCaptureDisplayInGPUProcess, bool shouldUseGPUProcessRemoteFrames)
{
m_shouldUseGPUProcessRemoteFrames = shouldUseGPUProcessRemoteFrames;
// FIXME(rdar://84278146): Adopt AVCaptureSession attribution API for camera access in the web process if shouldCaptureVideoInGPUProcess is false.
MockRealtimeMediaSourceCenter::singleton().setMockAudioCaptureEnabled(!shouldCaptureAudioInUIProcess && !shouldCaptureAudioInGPUProcess);
MockRealtimeMediaSourceCenter::singleton().setMockVideoCaptureEnabled(!shouldCaptureVideoInUIProcess && !shouldCaptureVideoInGPUProcess);
- MockRealtimeMediaSourceCenter::singleton().setMockDisplayCaptureEnabled(!shouldCaptureDisplayInUIProcess);
+ MockRealtimeMediaSourceCenter::singleton().setMockDisplayCaptureEnabled(!shouldCaptureDisplayInUIProcess && !shouldCaptureDisplayInGPUProcess);
m_audioFactory.setShouldCaptureInGPUProcess(shouldCaptureAudioInGPUProcess);
m_videoFactory.setShouldCaptureInGPUProcess(shouldCaptureVideoInGPUProcess);
+ m_displayFactory.setShouldCaptureInGPUProcess(shouldCaptureDisplayInGPUProcess);
if (shouldCaptureAudioInGPUProcess) {
WebCore::AudioMediaStreamTrackRendererUnit::setCreateInternalUnitFunction([](auto&& renderCallback, auto&& resetCallback) {
@@ -92,7 +93,7 @@
RealtimeMediaSourceCenter::singleton().setAudioCaptureFactory(m_audioFactory);
if (shouldCaptureVideoInUIProcess || shouldCaptureVideoInGPUProcess)
RealtimeMediaSourceCenter::singleton().setVideoCaptureFactory(m_videoFactory);
- if (shouldCaptureDisplayInUIProcess)
+ if (shouldCaptureDisplayInUIProcess || shouldCaptureDisplayInGPUProcess)
RealtimeMediaSourceCenter::singleton().setDisplayCaptureFactory(m_displayFactory);
}
@@ -252,9 +253,22 @@
CaptureSourceOrError UserMediaCaptureManager::DisplayFactory::createDisplayCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints)
{
- return RemoteRealtimeDisplaySource::create(device, constraints, WTFMove(hashSalt), m_manager, false);
+#if !ENABLE(GPU_PROCESS)
+ if (m_shouldCaptureInGPUProcess)
+ return CaptureSourceOrError { "Display capture in GPUProcess is not implemented"_s };
+#endif
+ if (m_shouldCaptureInGPUProcess)
+ m_manager.m_remoteCaptureSampleManager.setVideoFrameObjectHeapProxy(&WebProcess::singleton().ensureGPUProcessConnection().videoFrameObjectHeapProxy());
+
+ return RemoteRealtimeDisplaySource::create(device, constraints, WTFMove(hashSalt), m_manager, m_shouldCaptureInGPUProcess);
}
+void UserMediaCaptureManager::DisplayFactory::setShouldCaptureInGPUProcess(bool value)
+{
+ m_shouldCaptureInGPUProcess = value;
}
-#endif
+
+}
+
+#endif // PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
Modified: trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h (290173 => 290174)
--- trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h 2022-02-18 22:40:32 UTC (rev 290173)
+++ trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h 2022-02-18 22:43:33 UTC (rev 290174)
@@ -57,7 +57,7 @@
static const char* supplementName();
void didReceiveMessageFromGPUProcess(IPC::Connection& connection, IPC::Decoder& decoder) { didReceiveMessage(connection, decoder); }
- void setupCaptureProcesses(bool shouldCaptureAudioInUIProcess, bool shouldCaptureAudioInGPUProcess, bool shouldCaptureVideoInUIProcess, bool shouldCaptureVideoInGPUProcess, bool shouldCaptureDisplayInUIProcess, bool shouldUseGPUProcessRemoteFrames);
+ void setupCaptureProcesses(bool shouldCaptureAudioInUIProcess, bool shouldCaptureAudioInGPUProcess, bool shouldCaptureVideoInUIProcess, bool shouldCaptureVideoInGPUProcess, bool shouldCaptureDisplayInUIProcess, bool shouldCaptureDisplayInGPUProcess, bool shouldUseGPUProcessRemoteFrames);
void addSource(Ref<RemoteRealtimeAudioSource>&&);
void addSource(Ref<RemoteRealtimeVideoSource>&&);
@@ -98,6 +98,7 @@
class DisplayFactory : public WebCore::DisplayCaptureFactory {
public:
explicit DisplayFactory(UserMediaCaptureManager& manager) : m_manager(manager) { }
+ void setShouldCaptureInGPUProcess(bool);
private:
WebCore::CaptureSourceOrError createDisplayCaptureSource(const WebCore::CaptureDevice&, String&&, const WebCore::MediaConstraints*) final;
@@ -104,6 +105,7 @@
WebCore::DisplayCaptureManager& displayCaptureDeviceManager() final { return m_manager.m_noOpCaptureDeviceManager; }
UserMediaCaptureManager& m_manager;
+ bool m_shouldCaptureInGPUProcess { false };
};
class NoOpCaptureDeviceManager : public WebCore::DisplayCaptureManager {