Title: [253033] trunk
Revision
253033
Author
you...@apple.com
Date
2019-12-03 03:11:44 -0800 (Tue, 03 Dec 2019)

Log Message

[Cocoa] Run camera capture in UIProcess by default in layout tests
https://bugs.webkit.org/show_bug.cgi?id=204512

Reviewed by Eric Carlson.

Source/WebCore:

Remove no longer useful internals API once we are moving capture to UIProcess.

* platform/mediastream/RealtimeMediaSourceFactory.h:
* testing/Internals.cpp:
(WebCore::Internals::Internals):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

* UIProcess/UserMediaProcessManager.cpp:
(WebKit::UserMediaProcessManager::willCreateMediaStream):
Do not send sandbox extensions in case capture happens in UIProcess.
* WebProcess/cocoa/UserMediaCaptureManager.cpp:
(WebKit::UserMediaCaptureManager::Source::~Source):
(WebKit::UserMediaCaptureManager::createCaptureSource):
Register/unregister sources as active/unactive sources to the factory.

Tools:

By defaut, enable capture in UIProcess on Cocoa side.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):
(WTR::updateTestOptionsFromTestHeader):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):

LayoutTests:

Update tests to remove use of the removed internals API and disable
camera capture in UIProcess for two tests that exihibit shortcomings of our current UIProcess camera capture support.

* fast/mediastream/constraint-intrinsic-size.html:
* fast/mediastream/media-stream-page-muted.html:
* fast/mediastream/mediastreamtrack-video-clone.html:
* fast/mediastream/mock-media-source-expected.txt:
* fast/mediastream/mock-media-source.html:
* fast/mediastream/overconstrainederror-constraint.html:
* webrtc/video-rotation.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (253032 => 253033)


--- trunk/LayoutTests/ChangeLog	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/LayoutTests/ChangeLog	2019-12-03 11:11:44 UTC (rev 253033)
@@ -1,3 +1,21 @@
+2019-12-03  youenn fablet  <you...@apple.com>
+
+        [Cocoa] Run camera capture in UIProcess by default in layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=204512
+
+        Reviewed by Eric Carlson.
+
+        Update tests to remove use of the removed internals API and disable
+        camera capture in UIProcess for two tests that exihibit shortcomings of our current UIProcess camera capture support.
+
+        * fast/mediastream/constraint-intrinsic-size.html:
+        * fast/mediastream/media-stream-page-muted.html:
+        * fast/mediastream/mediastreamtrack-video-clone.html:
+        * fast/mediastream/mock-media-source-expected.txt:
+        * fast/mediastream/mock-media-source.html:
+        * fast/mediastream/overconstrainederror-constraint.html:
+        * webrtc/video-rotation.html:
+
 2019-12-03  Antti Koivisto  <an...@apple.com>
 
         [LFC][Integration] Setup root box properties

Modified: trunk/LayoutTests/fast/mediastream/constraint-intrinsic-size.html (253032 => 253033)


--- trunk/LayoutTests/fast/mediastream/constraint-intrinsic-size.html	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/LayoutTests/fast/mediastream/constraint-intrinsic-size.html	2019-12-03 11:11:44 UTC (rev 253033)
@@ -9,12 +9,8 @@
     <body>
 
         <script>
-            if (window.testRunner)
-                testRunner.setUserMediaPermission(true);
-            if (window.internals) {
-                window.internals.setMockMediaCaptureDevicesEnabled(true);
+            if (window.internals)
                 window.internals.settings.setScreenCaptureEnabled(true);
-            }
 
             function callGetDisplayMedia(options)
             {

Modified: trunk/LayoutTests/fast/mediastream/media-stream-page-muted.html (253032 => 253033)


--- trunk/LayoutTests/fast/mediastream/media-stream-page-muted.html	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/LayoutTests/fast/mediastream/media-stream-page-muted.html	2019-12-03 11:11:44 UTC (rev 253033)
@@ -176,14 +176,10 @@
         }
 
         jsTestIsAsync = true;
-        if (window.testRunner) {
-            testRunner.setUserMediaPermission(true);
+        if (window.testRunner)
             testRunner.waitUntilDone();
-        }
-        if (window.internals) {
-            window.internals.setMockMediaCaptureDevicesEnabled(true);
+        if (window.internals)
             window.internals.settings.setScreenCaptureEnabled(true);
-        }
 
         (async function() {
             try {

Modified: trunk/LayoutTests/fast/mediastream/mediastreamtrack-video-clone.html (253032 => 253033)


--- trunk/LayoutTests/fast/mediastream/mediastreamtrack-video-clone.html	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/LayoutTests/fast/mediastream/mediastreamtrack-video-clone.html	2019-12-03 11:11:44 UTC (rev 253033)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ enableCaptureVideoInUIProcess=false ] -->
 <!DOCTYPE html>
 <html>
 <head>

Modified: trunk/LayoutTests/fast/mediastream/mock-media-source-expected.txt (253032 => 253033)


--- trunk/LayoutTests/fast/mediastream/mock-media-source-expected.txt	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/LayoutTests/fast/mediastream/mock-media-source-expected.txt	2019-12-03 11:11:44 UTC (rev 253033)
@@ -1,4 +1,4 @@
-Test enabling/disabling mock media capture devices
+Test mock media capture devices
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
@@ -7,15 +7,6 @@
 *** Mock capture devices should be enabled by default
 PASS mediaStream is an instance of Object
 PASS mediaStream.getTracks().length is 2
-
-*** Disable mock capture devices
-internals.setMockMediaCaptureDevicesEnabled(false)
-PASS mediaDevices.getUserMedia() failed with NotReadableError
-
-*** Enable mock capture devices
-internals.setMockMediaCaptureDevicesEnabled(true)
-PASS mediaStream is an instance of Object
-PASS mediaStream.getTracks().length is 2
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/mediastream/mock-media-source.html (253032 => 253033)


--- trunk/LayoutTests/fast/mediastream/mock-media-source.html	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/LayoutTests/fast/mediastream/mock-media-source.html	2019-12-03 11:11:44 UTC (rev 253033)
@@ -5,27 +5,6 @@
         <script>
             var mediaStream;
 
-            function testWhenDisabled()
-            {
-                debug(`<br>*** Disable mock capture devices`);
-                if (window.internals)
-                    evalAndLog(`internals.setMockMediaCaptureDevicesEnabled(false)`);
-                navigator.mediaDevices
-                    .getUserMedia({audio:{}, video:{}})
-                    .then(function(stream) {
-                        mediaStream = stream;
-                        testFailed(`mediaDevices.getUserMedia() succeeded when no devices should be available`);
-                        finishJSTest();
-                    })
-                    .catch(function(err) {
-                        testPassed(`mediaDevices.getUserMedia() failed with ${err.name}`);
-                        debug(`<br>*** Enable mock capture devices`);
-                        if (window.internals)
-                            evalAndLog(`internals.setMockMediaCaptureDevicesEnabled(true)`);
-                        testWhenEnabled(null);
-                    });
-            }
-
             function testWhenEnabled(nextTest)
             {
                 navigator.mediaDevices
@@ -49,10 +28,7 @@
             function start()
             {
                 debug(`<br>*** Mock capture devices should be enabled by default`);
-                if (window.testRunner)
-                    testRunner.setUserMediaPermission(true);
-
-                testWhenEnabled(testWhenDisabled);
+                testWhenEnabled();
             }
 
         </script>
@@ -62,7 +38,7 @@
         <p id="description"></p>
         <div id="console"></div>
         <script>
-            description("Test enabling/disabling mock media capture devices");
+            description("Test mock media capture devices");
             window.jsTestIsAsync = true;
 
             window.successfullyParsed = true;

Modified: trunk/LayoutTests/fast/mediastream/overconstrainederror-constraint.html (253032 => 253033)


--- trunk/LayoutTests/fast/mediastream/overconstrainederror-constraint.html	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/LayoutTests/fast/mediastream/overconstrainederror-constraint.html	2019-12-03 11:11:44 UTC (rev 253033)
@@ -11,8 +11,6 @@
         <script>
 if (window.testRunner)
     testRunner.setUserMediaPermission(true);
-if (window.internals)
-    window.internals.setMockMediaCaptureDevicesEnabled(true);
 
 promise_test(async () => {
     return navigator.mediaDevices.getUserMedia({audio: {deviceId: {exact:"none"}}}).then(

Modified: trunk/LayoutTests/webrtc/video-rotation.html (253032 => 253033)


--- trunk/LayoutTests/webrtc/video-rotation.html	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/LayoutTests/webrtc/video-rotation.html	2019-12-03 11:11:44 UTC (rev 253033)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ enableCaptureVideoInUIProcess=false ] -->
 <!doctype html>
 <html>
     <head>

Modified: trunk/Source/WebCore/ChangeLog (253032 => 253033)


--- trunk/Source/WebCore/ChangeLog	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/Source/WebCore/ChangeLog	2019-12-03 11:11:44 UTC (rev 253033)
@@ -1,3 +1,18 @@
+2019-12-03  youenn fablet  <you...@apple.com>
+
+        [Cocoa] Run camera capture in UIProcess by default in layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=204512
+
+        Reviewed by Eric Carlson.
+
+        Remove no longer useful internals API once we are moving capture to UIProcess.
+
+        * platform/mediastream/RealtimeMediaSourceFactory.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::Internals):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2019-12-03  Antti Koivisto  <an...@apple.com>
 
         [LFC][Integration] Setup root box properties

Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h (253032 => 253033)


--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h	2019-12-03 11:11:44 UTC (rev 253033)
@@ -40,8 +40,8 @@
 
 class SingleSourceFactory {
 public:
-    void setActiveSource(RealtimeMediaSource&);
-    void unsetActiveSource(RealtimeMediaSource&);
+    WEBCORE_EXPORT void setActiveSource(RealtimeMediaSource&);
+    WEBCORE_EXPORT void unsetActiveSource(RealtimeMediaSource&);
     RealtimeMediaSource* activeSource() { return m_activeSource; }
 
 private:

Modified: trunk/Source/WebCore/testing/Internals.cpp (253032 => 253033)


--- trunk/Source/WebCore/testing/Internals.cpp	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/Source/WebCore/testing/Internals.cpp	2019-12-03 11:11:44 UTC (rev 253033)
@@ -553,7 +553,6 @@
 #endif
 
 #if ENABLE(MEDIA_STREAM)
-    setMockMediaCaptureDevicesEnabled(true);
     setMediaCaptureRequiresSecureConnection(false);
 #endif
 
@@ -1547,13 +1546,6 @@
     RuntimeEnabledFeatures::sharedFeatures().setInterruptAudioOnPageVisibilityChangeEnabled(shouldInterrupt);
 }
 
-void Internals::setMockMediaCaptureDevicesEnabled(bool enabled)
-{
-    Document* document = contextDocument();
-    if (auto* page = document->page())
-        page->settings().setMockCaptureDevicesEnabled(enabled);
-}
-
 void Internals::setMediaCaptureRequiresSecureConnection(bool enabled)
 {
     Document* document = contextDocument();

Modified: trunk/Source/WebCore/testing/Internals.h (253032 => 253033)


--- trunk/Source/WebCore/testing/Internals.h	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/Source/WebCore/testing/Internals.h	2019-12-03 11:11:44 UTC (rev 253033)
@@ -542,7 +542,6 @@
 
 #if ENABLE(MEDIA_STREAM)
     void setShouldInterruptAudioOnPageVisibilityChange(bool);
-    void setMockMediaCaptureDevicesEnabled(bool);
     void setMediaCaptureRequiresSecureConnection(bool);
     void setCustomPrivateRecorderCreator();
 #endif

Modified: trunk/Source/WebCore/testing/Internals.idl (253032 => 253033)


--- trunk/Source/WebCore/testing/Internals.idl	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/Source/WebCore/testing/Internals.idl	2019-12-03 11:11:44 UTC (rev 253033)
@@ -620,7 +620,6 @@
     [Conditional=WIRELESS_PLAYBACK_TARGET] void setMockMediaPlaybackTargetPickerEnabled(boolean enabled);
     [Conditional=WIRELESS_PLAYBACK_TARGET, MayThrowException] void setMockMediaPlaybackTargetPickerState(DOMString deviceName, DOMString deviceState);
     [Conditional=WIRELESS_PLAYBACK_TARGET] void mockMediaPlaybackTargetPickerDismissPopup();
-    [Conditional=MEDIA_STREAM] void setMockMediaCaptureDevicesEnabled(boolean enabled);
     [Conditional=MEDIA_STREAM] void setCustomPrivateRecorderCreator();
 
     [Conditional=WEB_AUDIO] void useMockAudioDestinationCocoa();

Modified: trunk/Source/WebKit/ChangeLog (253032 => 253033)


--- trunk/Source/WebKit/ChangeLog	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/Source/WebKit/ChangeLog	2019-12-03 11:11:44 UTC (rev 253033)
@@ -1,3 +1,18 @@
+2019-12-03  youenn fablet  <you...@apple.com>
+
+        [Cocoa] Run camera capture in UIProcess by default in layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=204512
+
+        Reviewed by Eric Carlson.
+
+        * UIProcess/UserMediaProcessManager.cpp:
+        (WebKit::UserMediaProcessManager::willCreateMediaStream):
+        Do not send sandbox extensions in case capture happens in UIProcess.
+        * WebProcess/cocoa/UserMediaCaptureManager.cpp:
+        (WebKit::UserMediaCaptureManager::Source::~Source):
+        (WebKit::UserMediaCaptureManager::createCaptureSource):
+        Register/unregister sources as active/unactive sources to the factory.
+
 2019-12-03  Carlos Garcia Campos  <cgar...@igalia.com>
 
         WebDriver: handle elements of type file in send keys command

Modified: trunk/Source/WebKit/UIProcess/UserMediaProcessManager.cpp (253032 => 253033)


--- trunk/Source/WebKit/UIProcess/UserMediaProcessManager.cpp	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/Source/WebKit/UIProcess/UserMediaProcessManager.cpp	2019-12-03 11:11:44 UTC (rev 253033)
@@ -75,15 +75,13 @@
     auto& process = proxy.page().process();
     size_t extensionCount = 0;
 
-    if (withAudio && !process.hasAudioCaptureExtension())
+    bool needsAudioSandboxExtension = withAudio && !process.hasAudioCaptureExtension() && !proxy.page().preferences().captureAudioInUIProcessEnabled();
+    if (needsAudioSandboxExtension)
         extensionCount++;
-    else
-        withAudio = false;
 
-    if (withVideo && !process.hasVideoCaptureExtension())
+    bool needsVideoSandboxExtension = withVideo && !process.hasVideoCaptureExtension() && !proxy.page().preferences().captureVideoInUIProcessEnabled();
+    if (needsVideoSandboxExtension)
         extensionCount++;
-    else
-        withVideo = false;
 
     if (extensionCount) {
         SandboxExtension::HandleArray handles;
@@ -93,11 +91,11 @@
             handles.allocate(extensionCount);
             ids.reserveInitialCapacity(extensionCount);
 
-            if (withAudio && SandboxExtension::createHandleForGenericExtension(audioExtensionPath, handles[--extensionCount]))
-                ids.append(audioExtensionPath);
+            if (needsAudioSandboxExtension && SandboxExtension::createHandleForGenericExtension(audioExtensionPath, handles[--extensionCount]))
+                ids.uncheckedAppend(audioExtensionPath);
 
-            if (withVideo && SandboxExtension::createHandleForGenericExtension(videoExtensionPath, handles[--extensionCount]))
-                ids.append(videoExtensionPath);
+            if (needsVideoSandboxExtension && SandboxExtension::createHandleForGenericExtension(videoExtensionPath, handles[--extensionCount]))
+                ids.uncheckedAppend(videoExtensionPath);
 
             if (ids.size() != handles.size()) {
                 WTFLogAlways("Could not create a required sandbox extension, capture will fail!");
@@ -108,9 +106,9 @@
         for (const auto& id : ids)
             RELEASE_LOG(WebRTC, "UserMediaProcessManager::willCreateMediaStream - granting extension %s", id.utf8().data());
 
-        if (withAudio)
+        if (needsAudioSandboxExtension)
             process.grantAudioCaptureExtension();
-        if (withVideo)
+        if (needsVideoSandboxExtension)
             process.grantVideoCaptureExtension();
         process.send(Messages::WebProcess::GrantUserMediaDeviceSandboxExtensions(MediaDeviceSandboxExtensions(ids, WTFMove(handles))), 0);
     }

Modified: trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp (253032 => 253033)


--- trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp	2019-12-03 11:11:44 UTC (rev 253033)
@@ -71,6 +71,11 @@
     {
         if (type() == Type::Audio)
             storage().invalidate();
+        else if (type() == Type::Video) {
+#if PLATFORM(IOS_FAMILY)
+            RealtimeMediaSourceCenter::singleton().videoCaptureFactory().unsetActiveSource(*this);
+#endif
+        }
     }
 
     SharedRingBufferStorage& storage()
@@ -257,6 +262,12 @@
     auto source = adoptRef(*new Source(String::number(id), type, device.type(), String { settings.label().string() }, WTFMove(hashSalt), id, *this));
     source->setSettings(WTFMove(settings));
     m_sources.add(id, source.copyRef());
+
+#if PLATFORM(IOS_FAMILY)
+    if (type == WebCore::RealtimeMediaSource::Type::Video)
+        RealtimeMediaSourceCenter::singleton().videoCaptureFactory().setActiveSource(source);
+#endif
+
     return WebCore::CaptureSourceOrError(WTFMove(source));
 }
 

Modified: trunk/Tools/ChangeLog (253032 => 253033)


--- trunk/Tools/ChangeLog	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/Tools/ChangeLog	2019-12-03 11:11:44 UTC (rev 253033)
@@ -1,3 +1,18 @@
+2019-12-03  youenn fablet  <you...@apple.com>
+
+        [Cocoa] Run camera capture in UIProcess by default in layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=204512
+
+        Reviewed by Eric Carlson.
+
+        By defaut, enable capture in UIProcess on Cocoa side.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+        (WTR::updateTestOptionsFromTestHeader):
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::hasSameInitializationOptions const):
+
 2019-12-03  Carlos Garcia Campos  <cgar...@igalia.com>
 
         Unreviewed. Focus the location bar on CTRL+l in GTK MiniBrowser

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (253032 => 253033)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2019-12-03 11:11:44 UTC (rev 253033)
@@ -815,6 +815,9 @@
     for (const auto& internalDebugFeature : options.internalDebugFeatures)
         WKPreferencesSetInternalDebugFeatureForKey(preferences, internalDebugFeature.value, toWK(internalDebugFeature.key).get());
 
+#if PLATFORM(COCOA)
+    WKPreferencesSetCaptureVideoInUIProcessEnabled(preferences, options.enableCaptureVideoInUIProcess);
+#endif
     WKPreferencesSetProcessSwapOnNavigationEnabled(preferences, options.contextOptions.shouldEnableProcessSwapOnNavigation());
     WKPreferencesSetPageVisibilityBasedProcessSuppressionEnabled(preferences, options.enableAppNap);
     WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true);
@@ -1446,6 +1449,8 @@
             testOptions.enableLazyImageLoading = parseBooleanTestHeaderValue(value);
         else if (key == "allowsLinkPreview")
             testOptions.allowsLinkPreview = parseBooleanTestHeaderValue(value);
+        else if (key == "enableCaptureVideoInUIProcess")
+            testOptions.enableCaptureVideoInUIProcess = parseBooleanTestHeaderValue(value);
         pairStart = pairEnd + 1;
     }
 }

Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (253032 => 253033)


--- trunk/Tools/WebKitTestRunner/TestOptions.h	2019-12-03 10:51:46 UTC (rev 253032)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h	2019-12-03 11:11:44 UTC (rev 253033)
@@ -97,6 +97,7 @@
     bool enableBackForwardCache { false };
     bool enableLazyImageLoading { false };
     bool allowsLinkPreview { true };
+    bool enableCaptureVideoInUIProcess { true };
 
     double contentInsetTop { 0 };
 
@@ -156,7 +157,8 @@
             || enableAppNap != options.enableAppNap
             || enableBackForwardCache != options.enableBackForwardCache
             || enableLazyImageLoading != options.enableLazyImageLoading
-            || allowsLinkPreview != options.allowsLinkPreview)
+            || allowsLinkPreview != options.allowsLinkPreview
+            || enableCaptureVideoInUIProcess != options.enableCaptureVideoInUIProcess)
             return false;
 
         if (!contextOptions.hasSameInitializationOptions(options.contextOptions))
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to