Title: [287930] trunk/Source/WebKit
Revision
287930
Author
jer.no...@apple.com
Date
2022-01-12 10:17:13 -0800 (Wed, 12 Jan 2022)

Log Message

[iOS] Page loading hangs for ~10s on WebProcess launch
https://bugs.webkit.org/show_bug.cgi?id=235089

Reviewed by Eric Carlson.

WebPage::setMuted() will result in calling into the current audioCaptureFactory,
which will be by default CoreAudioAudioCaptureFactory unless replaced.
CoreAudioAudioCaptureFactory will in turn call into AVAudioSession, which will block
for multiple seconds due to the WebContent process sandbox.

Change the order in which these calls occur by configuring the audioCaptureFactory
in platformInitialize(), which occurs near the top of the constructor. This requires
access to the WebPageCreationParameters passed into the constructor, modify that method
to take a WebPageCreationParameters, and modify all the platform-specific definitions of
that method.

* WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::platformInitialize):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_appHighlightsVisible):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
(WebKit::WebPage::platformInitialize):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::platformInitialize): Deleted.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformInitializeAccessibility):
(WebKit::WebPage::platformInitialize): Deleted.
* WebProcess/WebPage/playstation/WebPagePlayStation.cpp:
(WebKit::WebPage::platformInitialize):
* WebProcess/WebPage/win/WebPageWin.cpp:
(WebKit::WebPage::platformInitialize):
* WebProcess/WebPage/wpe/WebPageWPE.cpp:
(WebKit::WebPage::platformInitialize):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (287929 => 287930)


--- trunk/Source/WebKit/ChangeLog	2022-01-12 18:15:32 UTC (rev 287929)
+++ trunk/Source/WebKit/ChangeLog	2022-01-12 18:17:13 UTC (rev 287930)
@@ -1,3 +1,40 @@
+2022-01-12  Jer Noble  <jer.no...@apple.com>
+
+        [iOS] Page loading hangs for ~10s on WebProcess launch
+        https://bugs.webkit.org/show_bug.cgi?id=235089
+
+        Reviewed by Eric Carlson.
+
+        WebPage::setMuted() will result in calling into the current audioCaptureFactory,
+        which will be by default CoreAudioAudioCaptureFactory unless replaced. 
+        CoreAudioAudioCaptureFactory will in turn call into AVAudioSession, which will block
+        for multiple seconds due to the WebContent process sandbox.
+
+        Change the order in which these calls occur by configuring the audioCaptureFactory
+        in platformInitialize(), which occurs near the top of the constructor. This requires
+        access to the WebPageCreationParameters passed into the constructor, modify that method
+        to take a WebPageCreationParameters, and modify all the platform-specific definitions of
+        that method.
+
+        * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+        (WebKit::WebPage::platformInitialize):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_appHighlightsVisible):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/gtk/WebPageGtk.cpp:
+        (WebKit::WebPage::platformInitialize):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::platformInitialize): Deleted.
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::platformInitializeAccessibility):
+        (WebKit::WebPage::platformInitialize): Deleted.
+        * WebProcess/WebPage/playstation/WebPagePlayStation.cpp:
+        (WebKit::WebPage::platformInitialize):
+        * WebProcess/WebPage/win/WebPageWin.cpp:
+        (WebKit::WebPage::platformInitialize):
+        * WebProcess/WebPage/wpe/WebPageWPE.cpp:
+        (WebKit::WebPage::platformInitialize):
+
 2022-01-12  Frédéric Wang  <fw...@igalia.com>
 
         Protect DocumentLoader when a reference to its members is used.

Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (287929 => 287930)


--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm	2022-01-12 18:15:32 UTC (rev 287929)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm	2022-01-12 18:17:13 UTC (rev 287930)
@@ -30,6 +30,7 @@
 #import "LaunchServicesDatabaseManager.h"
 #import "LoadParameters.h"
 #import "PluginView.h"
+#import "UserMediaCaptureManager.h"
 #import "WKAccessibilityWebPageObjectBase.h"
 #import "WebPageProxyMessages.h"
 #import "WebPaymentCoordinator.h"
@@ -64,6 +65,16 @@
 
 namespace WebKit {
 
+void WebPage::platformInitialize(const WebPageCreationParameters& parameters)
+{
+    platformInitializeAccessibility();
+
+#if ENABLE(MEDIA_STREAM)
+    if (auto* captureManager = WebProcess::singleton().supplement<UserMediaCaptureManager>())
+        captureManager->setupCaptureProcesses(parameters.shouldCaptureAudioInUIProcess, parameters.shouldCaptureAudioInGPUProcess, parameters.shouldCaptureVideoInUIProcess, parameters.shouldCaptureVideoInGPUProcess, parameters.shouldCaptureDisplayInUIProcess);
+#endif
+}
+
 void WebPage::platformDidReceiveLoadParameters(const LoadParameters& parameters)
 {
 #if HAVE(LSDATABASECONTEXT)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (287929 => 287930)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2022-01-12 18:15:32 UTC (rev 287929)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2022-01-12 18:17:13 UTC (rev 287930)
@@ -296,7 +296,6 @@
 #include "RemoteLayerTreeTransaction.h"
 #include "RemoteObjectRegistryMessages.h"
 #include "TextCheckingControllerProxy.h"
-#include "UserMediaCaptureManager.h"
 #include "VideoFullscreenManager.h"
 #include "WKStringCF.h"
 #include "WebRemoteObjectRegistry.h"
@@ -745,7 +744,7 @@
     setOverrideViewportArguments(parameters.overrideViewportArguments);
 #endif
 
-    platformInitialize();
+    platformInitialize(parameters);
 
     setUseFixedLayout(parameters.useFixedLayout);
 
@@ -858,11 +857,7 @@
     if (parameters.enumeratingAllNetworkInterfacesEnabled)
         m_page->libWebRTCProvider().enableEnumeratingAllNetworkInterfaces();
 #endif
-#if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
-    if (auto* captureManager = WebProcess::singleton().supplement<UserMediaCaptureManager>())
-        captureManager->setupCaptureProcesses(parameters.shouldCaptureAudioInUIProcess, parameters.shouldCaptureAudioInGPUProcess, parameters.shouldCaptureVideoInUIProcess, parameters.shouldCaptureVideoInGPUProcess, parameters.shouldCaptureDisplayInUIProcess);
 #endif
-#endif
 
     for (const auto& iterator : parameters.urlSchemeHandlers)
         registerURLSchemeHandler(iterator.value, iterator.key);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (287929 => 287930)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2022-01-12 18:15:32 UTC (rev 287929)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2022-01-12 18:17:13 UTC (rev 287930)
@@ -927,6 +927,7 @@
     void didEndUserTriggeredSelectionChanges();
 
 #if PLATFORM(COCOA)
+    void platformInitializeAccessibility();
     void registerUIProcessAccessibilityTokens(const IPC::DataReference& elemenToken, const IPC::DataReference& windowToken);
     WKAccessibilityWebPageObject* accessibilityRemoteObject();
     NSObject *accessibilityObjectForMainFramePlugin();
@@ -1507,7 +1508,7 @@
     IPC::Connection* messageSenderConnection() const override;
     uint64_t messageSenderDestinationID() const override;
 
-    void platformInitialize();
+    void platformInitialize(const WebPageCreationParameters&);
     void platformReinitialize();
     void platformDetach();
     void getPlatformEditorState(WebCore::Frame&, EditorState&) const;
@@ -1529,7 +1530,6 @@
     void updateViewportSizeForCSSViewportUnits();
 
     std::optional<FocusedElementInformation> focusedElementInformation();
-    void platformInitializeAccessibility();
     void generateSyntheticEditingCommand(SyntheticEditingCommandType);
     void handleSyntheticClick(WebCore::Node& nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebKit::WebEvent::Modifier>, WebCore::PointerID = WebCore::mousePointerID);
     void completeSyntheticClick(WebCore::Node& nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebKit::WebEvent::Modifier>, WebCore::SyntheticClickType, WebCore::PointerID = WebCore::mousePointerID);

Modified: trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp (287929 => 287930)


--- trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp	2022-01-12 18:15:32 UTC (rev 287929)
+++ trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp	2022-01-12 18:17:13 UTC (rev 287930)
@@ -54,7 +54,7 @@
 namespace WebKit {
 using namespace WebCore;
 
-void WebPage::platformInitialize()
+void WebPage::platformInitialize(const WebPageCreationParameters&)
 {
 #if ENABLE(ACCESSIBILITY)
     // Create the accessible object (the plug) that will serve as the

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (287929 => 287930)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2022-01-12 18:15:32 UTC (rev 287929)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2022-01-12 18:17:13 UTC (rev 287930)
@@ -189,11 +189,6 @@
     return range ? plainTextForDisplay(*range) : emptyString();
 }
 
-void WebPage::platformInitialize()
-{
-    platformInitializeAccessibility();
-}
-
 void WebPage::platformDetach()
 {
     [m_mockAccessibilityElement setWebPage:nullptr];

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (287929 => 287930)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2022-01-12 18:15:32 UTC (rev 287929)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2022-01-12 18:17:13 UTC (rev 287930)
@@ -109,7 +109,7 @@
 namespace WebKit {
 using namespace WebCore;
 
-void WebPage::platformInitialize()
+void WebPage::platformInitializeAccessibility()
 {
     auto mockAccessibilityElement = adoptNS([[WKAccessibilityWebPageObject alloc] init]);
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/playstation/WebPagePlayStation.cpp (287929 => 287930)


--- trunk/Source/WebKit/WebProcess/WebPage/playstation/WebPagePlayStation.cpp	2022-01-12 18:15:32 UTC (rev 287929)
+++ trunk/Source/WebKit/WebProcess/WebPage/playstation/WebPagePlayStation.cpp	2022-01-12 18:17:13 UTC (rev 287930)
@@ -34,7 +34,7 @@
 namespace WebKit {
 using namespace WebCore;
 
-void WebPage::platformInitialize()
+void WebPage::platformInitialize(const WebPageCreationParameters&)
 {
 }
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/win/WebPageWin.cpp (287929 => 287930)


--- trunk/Source/WebKit/WebProcess/WebPage/win/WebPageWin.cpp	2022-01-12 18:15:32 UTC (rev 287929)
+++ trunk/Source/WebKit/WebProcess/WebPage/win/WebPageWin.cpp	2022-01-12 18:17:13 UTC (rev 287930)
@@ -52,7 +52,7 @@
 namespace WebKit {
 using namespace WebCore;
 
-void WebPage::platformInitialize()
+void WebPage::platformInitialize(const WebPageCreationParameters&)
 {
 }
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp (287929 => 287930)


--- trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp	2022-01-12 18:15:32 UTC (rev 287929)
+++ trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp	2022-01-12 18:17:13 UTC (rev 287930)
@@ -36,7 +36,7 @@
 namespace WebKit {
 using namespace WebCore;
 
-void WebPage::platformInitialize()
+void WebPage::platformInitialize(const WebPageCreationParameters&)
 {
 #if ENABLE(ACCESSIBILITY)
     // Create the accessible object (the plug) that will serve as the
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to