Title: [238289] trunk/Source
Revision
238289
Author
[email protected]
Date
2018-11-16 10:52:59 -0800 (Fri, 16 Nov 2018)

Log Message

[Mac] Regression: WebContent process's display name is no longer set
https://bugs.webkit.org/show_bug.cgi?id=191722
<rdar://problem/45960550>

Reviewed by Per Arne Vollan.

Source/WebCore/PAL:

* pal/spi/cocoa/LaunchServicesSPI.h:

Source/WebKit:

Make sure The WebContent process calls _RegisterApplication() during initialization and
*before* trying to set its display name. Setting the display name fails otherwise.

* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::initializeProcessName):
(WebKit::WebProcess::platformInitializeProcess):

Modified Paths

Diff

Modified: trunk/Source/WebCore/PAL/ChangeLog (238288 => 238289)


--- trunk/Source/WebCore/PAL/ChangeLog	2018-11-16 18:20:18 UTC (rev 238288)
+++ trunk/Source/WebCore/PAL/ChangeLog	2018-11-16 18:52:59 UTC (rev 238289)
@@ -1,3 +1,13 @@
+2018-11-16  Chris Dumez  <[email protected]>
+
+        [Mac] Regression: WebContent process's display name is no longer set
+        https://bugs.webkit.org/show_bug.cgi?id=191722
+        <rdar://problem/45960550>
+
+        Reviewed by Per Arne Vollan.
+
+        * pal/spi/cocoa/LaunchServicesSPI.h:
+
 2018-11-15  Brent Fulgham  <[email protected]>
 
         Additional Windows build fix after r238253.

Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h (238288 => 238289)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h	2018-11-16 18:20:18 UTC (rev 238288)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h	2018-11-16 18:52:59 UTC (rev 238289)
@@ -79,6 +79,7 @@
 
 typedef const struct CF_BRIDGED_TYPE(id) __LSASN* LSASNRef;
 typedef enum LSSessionID LSSessionID;
+typedef struct ProcessSerialNumber ProcessSerialNumber;
 
 WTF_EXTERN_C_BEGIN
 
@@ -86,7 +87,10 @@
 
 LSASNRef _LSGetCurrentApplicationASN();
 OSStatus _LSSetApplicationInformationItem(LSSessionID, LSASNRef, CFStringRef keyToSetRef, CFTypeRef valueToSetRef, CFDictionaryRef* newInformationDictRef);
+CFTypeRef _LSCopyApplicationInformationItem(LSSessionID, LSASNRef, CFTypeRef);
 
+OSStatus _RegisterApplication(CFDictionaryRef, ProcessSerialNumber*);
+
 WTF_EXTERN_C_END
 
 #endif // PLATFORM(MAC)

Modified: trunk/Source/WebKit/ChangeLog (238288 => 238289)


--- trunk/Source/WebKit/ChangeLog	2018-11-16 18:20:18 UTC (rev 238288)
+++ trunk/Source/WebKit/ChangeLog	2018-11-16 18:52:59 UTC (rev 238289)
@@ -1,3 +1,18 @@
+2018-11-16  Chris Dumez  <[email protected]>
+
+        [Mac] Regression: WebContent process's display name is no longer set
+        https://bugs.webkit.org/show_bug.cgi?id=191722
+        <rdar://problem/45960550>
+
+        Reviewed by Per Arne Vollan.
+
+        Make sure The WebContent process calls _RegisterApplication() during initialization and
+        *before* trying to set its display name. Setting the display name fails otherwise.
+
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::initializeProcessName):
+        (WebKit::WebProcess::platformInitializeProcess):
+
 2018-11-16  Ryosuke Niwa  <[email protected]>
 
         Enable process swap on cross-site navigation by default on iOS

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (238288 => 238289)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2018-11-16 18:20:18 UTC (rev 238288)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2018-11-16 18:52:59 UTC (rev 238289)
@@ -223,8 +223,22 @@
 #endif
     else
         applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.uiProcessName];
-    _LSSetApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey, (CFStringRef)applicationName, nullptr);
+
+    dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{
+        // Note that it is important for _RegisterApplication() to have been called before setting the display name.
+        auto error = _LSSetApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey, (CFStringRef)applicationName, nullptr);
+        ASSERT(!error);
+        if (error) {
+            RELEASE_LOG_ERROR(Process, "Failed to set the display name of the WebContent process, error code: %ld", static_cast<long>(error));
+            return;
+        }
+#if !ASSERT_DISABLED
+        // It is possible for _LSSetApplicationInformationItem() to return 0 and yet fail to set the display name so we make sure the display name has actually been set.
+        String actualApplicationName = adoptCF((CFStringRef)_LSCopyApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey)).get();
+        ASSERT(!actualApplicationName.isEmpty());
 #endif
+    });
+#endif
 }
 
 static void registerWithAccessibility()
@@ -336,7 +350,12 @@
     CGSShutdownServerConnections();
 
     SwitchingGPUClient::setSingleton(WebSwitchingGPUClient::singleton());
+
+    // This is necessary so that we are able to set the process' display name.
+    _RegisterApplication(nullptr, nullptr);
+
 #else
+
     if (![NSApp isRunning]) {
         // This call is needed when the WebProcess is not running the NSApplication event loop.
         // Otherwise, calling enableSandboxStyleFileQuarantine() will fail.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to