- Revision
- 223827
- Author
- wenson_hs...@apple.com
- Date
- 2017-10-22 19:20:19 -0700 (Sun, 22 Oct 2017)
Log Message
[iOS] WebProcess::initializeWebProcess spends ~150ms spinning up AVSystemController on some devices
https://bugs.webkit.org/show_bug.cgi?id=178640
<rdar://problem/35113105>
Reviewed by Youenn Fablet.
In r213933, we added a mechanism to allow the web process to drive media capture, by setting an attribute on the
shared AVSystemController. This requires us to fault in the Celestial framework, which is a slight performance
hit on some hardware. Instead of doing this at the start of every web process launch, we can just do this work
lazily, the first time the web process requests permissions for user media access.
* WebProcess/WebCoreSupport/WebUserMediaClient.cpp:
(WebKit::WebUserMediaClient::requestUserMediaAccess):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::prepareToSendUserMediaPermissionRequest):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::prepareToSendUserMediaPermissionRequest):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (223826 => 223827)
--- trunk/Source/WebKit/ChangeLog 2017-10-23 00:43:38 UTC (rev 223826)
+++ trunk/Source/WebKit/ChangeLog 2017-10-23 02:20:19 UTC (rev 223827)
@@ -1,3 +1,26 @@
+2017-10-22 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [iOS] WebProcess::initializeWebProcess spends ~150ms spinning up AVSystemController on some devices
+ https://bugs.webkit.org/show_bug.cgi?id=178640
+ <rdar://problem/35113105>
+
+ Reviewed by Youenn Fablet.
+
+ In r213933, we added a mechanism to allow the web process to drive media capture, by setting an attribute on the
+ shared AVSystemController. This requires us to fault in the Celestial framework, which is a slight performance
+ hit on some hardware. Instead of doing this at the start of every web process launch, we can just do this work
+ lazily, the first time the web process requests permissions for user media access.
+
+ * WebProcess/WebCoreSupport/WebUserMediaClient.cpp:
+ (WebKit::WebUserMediaClient::requestUserMediaAccess):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::prepareToSendUserMediaPermissionRequest):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::prepareToSendUserMediaPermissionRequest):
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::WebProcess::platformInitializeWebProcess):
+
2017-10-21 Michael Catanzaro <mcatanz...@igalia.com>
Unreviewed, silence a -Wunused-but-set-variable warning
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebUserMediaClient.cpp (223826 => 223827)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebUserMediaClient.cpp 2017-10-23 00:43:38 UTC (rev 223826)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebUserMediaClient.cpp 2017-10-23 02:20:19 UTC (rev 223827)
@@ -43,6 +43,7 @@
void WebUserMediaClient::requestUserMediaAccess(UserMediaRequest& request)
{
+ m_page.prepareToSendUserMediaPermissionRequest();
m_page.userMediaPermissionRequestManager().startUserMediaRequest(request);
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (223826 => 223827)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2017-10-23 00:43:38 UTC (rev 223826)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2017-10-23 02:20:19 UTC (rev 223827)
@@ -3898,6 +3898,13 @@
}
#if ENABLE(MEDIA_STREAM)
+
+#if !PLATFORM(IOS)
+void WebPage::prepareToSendUserMediaPermissionRequest()
+{
+}
+#endif
+
void WebPage::userMediaAccessWasGranted(uint64_t userMediaID, String&& audioDeviceUID, String&& videoDeviceUID, String&& mediaDeviceIdentifierHashSalt)
{
m_userMediaPermissionRequestManager->userMediaAccessWasGranted(userMediaID, WTFMove(audioDeviceUID), WTFMove(videoDeviceUID), WTFMove(mediaDeviceIdentifierHashSalt));
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (223826 => 223827)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2017-10-23 00:43:38 UTC (rev 223826)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2017-10-23 02:20:19 UTC (rev 223827)
@@ -511,6 +511,7 @@
#if ENABLE(MEDIA_STREAM)
UserMediaPermissionRequestManager& userMediaPermissionRequestManager() { return *m_userMediaPermissionRequestManager; }
+ void prepareToSendUserMediaPermissionRequest();
#endif
void elementDidFocus(WebCore::Node*);
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (223826 => 223827)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2017-10-23 00:43:38 UTC (rev 223826)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2017-10-23 02:20:19 UTC (rev 223827)
@@ -99,6 +99,7 @@
#import <WebCore/RenderImage.h>
#import <WebCore/RenderThemeIOS.h>
#import <WebCore/RenderView.h>
+#import <WebCore/RuntimeApplicationChecks.h>
#import <WebCore/Settings.h>
#import <WebCore/SharedBuffer.h>
#import <WebCore/StyleProperties.h>
@@ -110,8 +111,16 @@
#import <wtf/MathExtras.h>
#import <wtf/MemoryPressureHandler.h>
#import <wtf/SetForScope.h>
+#import <wtf/SoftLinking.h>
#import <wtf/text/TextStream.h>
+#if ENABLE(MEDIA_STREAM)
+#import "CelestialSPI.h"
+SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(Celestial)
+SOFT_LINK_CLASS_OPTIONAL(Celestial, AVSystemController)
+SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_PIDToInheritApplicationStateFrom, NSString *)
+#endif
+
using namespace WebCore;
namespace WebKit {
@@ -3411,6 +3420,22 @@
}
#endif
+#if ENABLE(MEDIA_STREAM)
+void WebPage::prepareToSendUserMediaPermissionRequest()
+{
+ static std::once_flag once;
+ std::call_once(once, [] {
+ if (!canLoadAVSystemController_PIDToInheritApplicationStateFrom())
+ return;
+
+ NSError *error = nil;
+ [[getAVSystemControllerClass() sharedAVSystemController] setAttribute:@(WebCore::presentingApplicationPID()) forKey:getAVSystemController_PIDToInheritApplicationStateFrom() error:&error];
+ if (error)
+ WTFLogAlways("Failed to set up PID proxying: %s", error.localizedDescription.UTF8String);
+ });
+}
+#endif
+
} // namespace WebKit
#endif // PLATFORM(IOS)
Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (223826 => 223827)
--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2017-10-23 00:43:38 UTC (rev 223826)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2017-10-23 02:20:19 UTC (rev 223827)
@@ -70,9 +70,7 @@
#import <stdio.h>
#if PLATFORM(IOS)
-#import "CelestialSPI.h"
#import <pal/spi/ios/GraphicsServicesSPI.h>
-#import <wtf/SoftLinking.h>
#endif
#if USE(OS_STATE)
@@ -79,16 +77,6 @@
#import <os/state_private.h>
#endif
-#if PLATFORM(IOS)
-SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(Celestial)
-
-SOFT_LINK_CLASS_OPTIONAL(Celestial, AVSystemController)
-
-SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_PIDToInheritApplicationStateFrom, NSString *)
-
-#define AVSystemController_PIDToInheritApplicationStateFrom getAVSystemController_PIDToInheritApplicationStateFrom()
-#endif
-
using namespace WebCore;
namespace WebKit {
@@ -175,16 +163,6 @@
// Priority decay on iOS 9 is impacting page load time so we fix the priority of the WebProcess' main thread (rdar://problem/22003112).
pthread_set_fixedpriority_self();
#endif
-
-#if PLATFORM(IOS)
- if (canLoadAVSystemController_PIDToInheritApplicationStateFrom()) {
- pid_t pid = WebCore::presentingApplicationPID();
- NSError *error = nil;
- [[getAVSystemControllerClass() sharedAVSystemController] setAttribute:@(pid) forKey:AVSystemController_PIDToInheritApplicationStateFrom error:&error];
- if (error)
- WTFLogAlways("Failed to set up PID proxying: %s", [[error localizedDescription] UTF8String]);
- }
-#endif
}
void WebProcess::initializeProcessName(const ChildProcessInitializationParameters& parameters)