Title: [293892] trunk/Source/WebKit
Revision
293892
Author
pvol...@apple.com
Date
2022-05-06 08:23:27 -0700 (Fri, 06 May 2022)

Log Message

[WP] Wait for Launch Services database after Network process connection has been established
https://bugs.webkit.org/show_bug.cgi?id=240125
<rdar://92107043>

Reviewed by Geoffrey Garen.

Since the Launch Services database is provided to the WebContent process by the Network process, it makes sense
to wait for the database when we're certain that the Network process is running. This should fix main thread hangs
in the cases where we before started waiting for the database before the Network process had launched. To support
this move, we also need to delay the initialization of accessibility in NSApplication, since that depends on having
the database available. This is now being done in WebPage::platformInitializeAccessibility, which is a natural
place for this initialization to take place.

* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformInitializeAccessibility):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::ensureNetworkProcessConnection):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (293891 => 293892)


--- trunk/Source/WebKit/ChangeLog	2022-05-06 15:21:16 UTC (rev 293891)
+++ trunk/Source/WebKit/ChangeLog	2022-05-06 15:23:27 UTC (rev 293892)
@@ -1,3 +1,25 @@
+2022-05-06  Per Arne Vollan  <pvol...@apple.com>
+
+        [WP] Wait for Launch Services database after Network process connection has been established
+        https://bugs.webkit.org/show_bug.cgi?id=240125
+        <rdar://92107043>
+
+        Reviewed by Geoffrey Garen.
+
+        Since the Launch Services database is provided to the WebContent process by the Network process, it makes sense
+        to wait for the database when we're certain that the Network process is running. This should fix main thread hangs
+        in the cases where we before started waiting for the database before the Network process had launched. To support
+        this move, we also need to delay the initialization of accessibility in NSApplication, since that depends on having
+        the database available. This is now being done in WebPage::platformInitializeAccessibility, which is a natural
+        place for this initialization to take place.
+
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::platformInitializeAccessibility):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::ensureNetworkProcessConnection):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
 2022-05-06  Kimmo Kinnunen  <kkinnu...@apple.com>
 
         GPU Process crash under IPC::Connection::open() ASSERTION FAILED: m_sendPort

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


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2022-05-06 15:21:16 UTC (rev 293891)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2022-05-06 15:23:27 UTC (rev 293892)
@@ -113,6 +113,10 @@
 
 void WebPage::platformInitializeAccessibility()
 {
+    // Need to initialize accessibility for VoiceOver to work when the WebContent process is using NSRunLoop.
+    // Currently, it is also needed to allocate and initialize an NSApplication object.
+    [NSApplication _accessibilityInitialize];
+
     auto mockAccessibilityElement = adoptNS([[WKAccessibilityWebPageObject alloc] init]);
 
     // Get the pid for the starting process.

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (293891 => 293892)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2022-05-06 15:21:16 UTC (rev 293891)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2022-05-06 15:23:27 UTC (rev 293892)
@@ -241,6 +241,10 @@
 #include "WebMockContentFilterManager.h"
 #endif
 
+#if HAVE(LSDATABASECONTEXT)
+#include "LaunchServicesDatabaseManager.h"
+#endif
+
 #undef WEBPROCESS_RELEASE_LOG
 #define RELEASE_LOG_SESSION_ID (m_sessionID ? m_sessionID->toUInt64() : 0)
 #if RELEASE_LOG_DISABLED
@@ -1192,6 +1196,12 @@
             m_networkProcessConnection->serviceWorkerConnection().registerServiceWorkerClients();
 #endif
 
+#if HAVE(LSDATABASECONTEXT)
+        // On Mac, this needs to be called before NSApplication is being initialized.
+        // The NSApplication initialization is being done in [NSApplication _accessibilityInitialize]
+        LaunchServicesDatabaseManager::singleton().waitForDatabaseUpdate();
+#endif
+
         // This can be called during a WebPage's constructor, so wait until after the constructor returns to touch the WebPage.
         RunLoop::main().dispatch([this] {
             for (auto& webPage : m_pageMap.values())

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (293891 => 293892)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2022-05-06 15:21:16 UTC (rev 293891)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2022-05-06 15:23:27 UTC (rev 293892)
@@ -27,7 +27,6 @@
 #import "WebProcess.h"
 
 #import "AccessibilitySupportSPI.h"
-#import "LaunchServicesDatabaseManager.h"
 #import "LegacyCustomProtocolManager.h"
 #import "LogInitialization.h"
 #import "Logging.h"
@@ -330,12 +329,6 @@
     method_setImplementation(methodToPatch, (IMP)NSApplicationAccessibilityFocusedUIElement);
 #endif
 
-#if HAVE(LSDATABASECONTEXT)
-    // On Mac, this needs to be called before NSApplication is being initialized.
-    // The NSApplication initialization is being done in [NSApplication _accessibilityInitialize]
-    LaunchServicesDatabaseManager::singleton().waitForDatabaseUpdate();
-#endif
-
 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_NSRUNLOOP)
     RefPtr<SandboxExtension> launchServicesExtension;
     if (parameters.launchServicesExtensionHandle) {
@@ -345,12 +338,9 @@
         }
     }
 
-    // Need to initialize accessibility for VoiceOver to work when the WebContent process is using NSRunLoop.
-    // Currently, it is also needed to allocate and initialize an NSApplication object.
-    // This method call will also call RegisterApplication, so there is no need for us to call this or
-    // check in with Launch Services
-    [NSApplication _accessibilityInitialize];
-
+    // Register the application. This will also check in with Launch Services.
+    _RegisterApplication(nullptr, nullptr);
+    
     // Update process name while holding the Launch Services sandbox extension
     updateProcessName(IsInProcessInitialization::Yes);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to