Title: [293758] trunk/Source/WebKit
Revision
293758
Author
pvol...@apple.com
Date
2022-05-03 20:17:09 -0700 (Tue, 03 May 2022)

Log Message

Add logging related to Launch Services database
https://bugs.webkit.org/show_bug.cgi?id=240032

Reviewed by Geoffrey Garen.

We have reports indicating that it can sometime take unexpectedly long time for the Network process to provide
the Launch Services database to the WebContent and GPU process. Add some logging to help diagnose the issue.
There are also some related selector response checks that can be removed now.

* NetworkProcess/cocoa/LaunchServicesDatabaseObserver.mm:
(WebKit::LaunchServicesDatabaseObserver::LaunchServicesDatabaseObserver):
(WebKit::LaunchServicesDatabaseObserver::startObserving):
(WebKit::LaunchServicesDatabaseObserver::~LaunchServicesDatabaseObserver):
(WebKit::databaseContext): Deleted.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::NetworkProcessProxy):
(WebKit::NetworkProcessProxy::didFinishLaunching):
* UIProcess/Network/NetworkProcessProxyCocoa.mm:
(WebKit::NetworkProcessProxy::sendXPCEndpointToProcess):
* WebProcess/cocoa/LaunchServicesDatabaseManager.mm:
(WebKit::LaunchServicesDatabaseManager::handleEvent):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (293757 => 293758)


--- trunk/Source/WebKit/ChangeLog	2022-05-04 02:27:25 UTC (rev 293757)
+++ trunk/Source/WebKit/ChangeLog	2022-05-04 03:17:09 UTC (rev 293758)
@@ -1,3 +1,27 @@
+2022-05-03  Per Arne Vollan  <pvol...@apple.com>
+
+        Add logging related to Launch Services database
+        https://bugs.webkit.org/show_bug.cgi?id=240032
+
+        Reviewed by Geoffrey Garen.
+
+        We have reports indicating that it can sometime take unexpectedly long time for the Network process to provide
+        the Launch Services database to the WebContent and GPU process. Add some logging to help diagnose the issue.
+        There are also some related selector response checks that can be removed now.
+
+        * NetworkProcess/cocoa/LaunchServicesDatabaseObserver.mm:
+        (WebKit::LaunchServicesDatabaseObserver::LaunchServicesDatabaseObserver):
+        (WebKit::LaunchServicesDatabaseObserver::startObserving):
+        (WebKit::LaunchServicesDatabaseObserver::~LaunchServicesDatabaseObserver):
+        (WebKit::databaseContext): Deleted.
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::NetworkProcessProxy):
+        (WebKit::NetworkProcessProxy::didFinishLaunching):
+        * UIProcess/Network/NetworkProcessProxyCocoa.mm:
+        (WebKit::NetworkProcessProxy::sendXPCEndpointToProcess):
+        * WebProcess/cocoa/LaunchServicesDatabaseManager.mm:
+        (WebKit::LaunchServicesDatabaseManager::handleEvent):
+
 2022-05-03  Yusuke Suzuki  <ysuz...@apple.com>
 
         [JSC] Initialize empty and null AtomString at compile time

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/LaunchServicesDatabaseObserver.mm (293757 => 293758)


--- trunk/Source/WebKit/NetworkProcess/cocoa/LaunchServicesDatabaseObserver.mm	2022-05-04 02:27:25 UTC (rev 293757)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/LaunchServicesDatabaseObserver.mm	2022-05-04 03:17:09 UTC (rev 293758)
@@ -33,25 +33,10 @@
 
 namespace WebKit {
 
-#if HAVE(LSDATABASECONTEXT)
-static LSDatabaseContext *databaseContext()
-{
-    static dispatch_once_t once;
-    static LSDatabaseContext *context = nullptr;
-    dispatch_once(&once, ^{
-        context = [NSClassFromString(@"LSDatabaseContext") sharedDatabaseContext];
-    });
-    return context;
-}
-#endif
-
 LaunchServicesDatabaseObserver::LaunchServicesDatabaseObserver(NetworkProcess&)
 {
 #if HAVE(LSDATABASECONTEXT)
-    if (![databaseContext() respondsToSelector:@selector(addDatabaseChangeObserver4WebKit:)])
-        return;
-
-    m_observer = [databaseContext() addDatabaseChangeObserver4WebKit:^(xpc_object_t change) {
+    m_observer = [LSDatabaseContext.sharedDatabaseContext addDatabaseChangeObserver4WebKit:^(xpc_object_t change) {
         auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
         xpc_dictionary_set_string(message.get(), XPCEndpoint::xpcMessageNameKey, LaunchServicesDatabaseXPCConstants::xpcUpdateLaunchServicesDatabaseMessageName);
         xpc_dictionary_set_value(message.get(), LaunchServicesDatabaseXPCConstants::xpcLaunchServicesDatabaseKey, change);
@@ -78,22 +63,15 @@
     }
 
 #if HAVE(LSDATABASECONTEXT)
-    if (![databaseContext() respondsToSelector:@selector(addDatabaseChangeObserver4WebKit:)]) {
+    RetainPtr<id> observer = [LSDatabaseContext.sharedDatabaseContext addDatabaseChangeObserver4WebKit:^(xpc_object_t change) {
         auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
         xpc_dictionary_set_string(message.get(), XPCEndpoint::xpcMessageNameKey, LaunchServicesDatabaseXPCConstants::xpcUpdateLaunchServicesDatabaseMessageName);
-        xpc_connection_send_message(connection.get(), message.get());
-        return;
-    }
-
-    RetainPtr<id> observer = [databaseContext() addDatabaseChangeObserver4WebKit:^(xpc_object_t change) {
-        auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
-        xpc_dictionary_set_string(message.get(), XPCEndpoint::xpcMessageNameKey, LaunchServicesDatabaseXPCConstants::xpcUpdateLaunchServicesDatabaseMessageName);
         xpc_dictionary_set_value(message.get(), LaunchServicesDatabaseXPCConstants::xpcLaunchServicesDatabaseKey, change);
 
         xpc_connection_send_message(connection.get(), message.get());
     }];
 
-    [databaseContext() removeDatabaseChangeObserver4WebKit:observer.get()];
+    [LSDatabaseContext.sharedDatabaseContext removeDatabaseChangeObserver4WebKit:observer.get()];
 #else
     auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
     xpc_dictionary_set_string(message.get(), XPCEndpoint::xpcMessageNameKey, LaunchServicesDatabaseXPCConstants::xpcUpdateLaunchServicesDatabaseMessageName);
@@ -104,10 +82,7 @@
 LaunchServicesDatabaseObserver::~LaunchServicesDatabaseObserver()
 {
 #if HAVE(LSDATABASECONTEXT)
-    if (![databaseContext() respondsToSelector:@selector(removeDatabaseChangeObserver4WebKit:)])
-        return;
-
-    [databaseContext() removeDatabaseChangeObserver4WebKit:m_observer.get()];
+    [LSDatabaseContext.sharedDatabaseContext removeDatabaseChangeObserver4WebKit:m_observer.get()];
 #endif
 }
 

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (293757 => 293758)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2022-05-04 02:27:25 UTC (rev 293757)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2022-05-04 03:17:09 UTC (rev 293758)
@@ -241,6 +241,8 @@
     , m_throttler(*this, WebProcessPool::anyProcessPoolNeedsUIBackgroundAssertion())
     , m_cookieManager(makeUniqueRef<WebCookieManagerProxy>(*this))
 {
+    RELEASE_LOG(Process, "%p - NetworkProcessProxy::NetworkProcessProxy", this);
+
     connect();
     sendCreationParametersToNewProcess();
     updateProcessAssertion();
@@ -549,6 +551,8 @@
 
 void NetworkProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connection::Identifier connectionIdentifier)
 {
+    RELEASE_LOG(Process, "%p - NetworkProcessProxy::didFinishLaunching", this);
+
     AuxiliaryProcessProxy::didFinishLaunching(launcher, connectionIdentifier);
 
     if (!IPC::Connection::identifierIsValid(connectionIdentifier)) {

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxyCocoa.mm (293757 => 293758)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxyCocoa.mm	2022-05-04 02:27:25 UTC (rev 293757)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxyCocoa.mm	2022-05-04 03:17:09 UTC (rev 293758)
@@ -80,15 +80,18 @@
 
 bool NetworkProcessProxy::sendXPCEndpointToProcess(AuxiliaryProcessProxy& process)
 {
+    RELEASE_LOG(Process, "%p - NetworkProcessProxy::sendXPCEndpointToProcess(%p) state = %d has connection = %d XPC endpoint message = %p", this, &process, process.state(), process.hasConnection(), xpcEndpointMessage());
+
     if (process.state() != AuxiliaryProcessProxy::State::Running)
         return false;
-    auto* connection = process.connection();
-    if (!connection)
+    if (!process.hasConnection())
         return false;
     auto message = xpcEndpointMessage();
     if (!message)
         return false;
-    xpc_connection_send_message(connection->xpcConnection(), message);
+    auto xpcConnection = process.connection()->xpcConnection();
+    RELEASE_ASSERT(xpcConnection);
+    xpc_connection_send_message(xpcConnection, message);
     return true;
 }
 

Modified: trunk/Source/WebKit/WebProcess/cocoa/LaunchServicesDatabaseManager.mm (293757 => 293758)


--- trunk/Source/WebKit/WebProcess/cocoa/LaunchServicesDatabaseManager.mm	2022-05-04 02:27:25 UTC (rev 293757)
+++ trunk/Source/WebKit/WebProcess/cocoa/LaunchServicesDatabaseManager.mm	2022-05-04 03:17:09 UTC (rev 293758)
@@ -49,12 +49,10 @@
 #if HAVE(LSDATABASECONTEXT)
         auto database = xpc_dictionary_get_value(message, LaunchServicesDatabaseXPCConstants::xpcLaunchServicesDatabaseKey);
 
-        if (database) {
-            auto context = [NSClassFromString(@"LSDatabaseContext") sharedDatabaseContext];
-            if (![context respondsToSelector:@selector(observeDatabaseChange4WebKit:)])
-                return;
-            [context observeDatabaseChange4WebKit:database];
-        }
+        RELEASE_LOG(Loading, "Received Launch Services database %p", database);
+
+        if (database)
+            [LSDatabaseContext.sharedDatabaseContext observeDatabaseChange4WebKit:database];
 #endif
         m_semaphore.signal();
         m_hasReceivedLaunchServicesDatabase = true;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to