Title: [272017] trunk/Source
Revision
272017
Author
pvol...@apple.com
Date
2021-01-28 10:01:25 -0800 (Thu, 28 Jan 2021)

Log Message

[macOS] Crash when updating color preferences
https://bugs.webkit.org/show_bug.cgi?id=221088
<rdar://problem/73709142>

Reviewed by Brent Fulgham.

Source/WebCore:

Remove previous workaround in r271965 for preventing Launch Services connections, since this is covered
by the new approach in this patch.

* platform/mac/ThemeMac.mm:
(-[WebCoreThemeWindow isKeyWindow]):
(-[WebCoreThemeWindow invalidateRestorableState]): Deleted.

Source/WebCore/PAL:

Declare NSApplication SPI for updating application information with Launch Services.

* pal/spi/mac/NSApplicationSPI.h:

Source/WebKit:

After r271965, the WebContent process is no longer allowed to connect to the Launch Services daemon. This introduced a crash
in the WebContent process when color preferences were changed in System Preferences, since AppKit will then attempt to set
application information with Launch Services, which causes a crash when that fails. This patch addresses this issue by
overriding the AppKit method that updates the specific application information with Launch Services, since updating this
information should be required in the WebContent process.

* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::updateCanQuitQuietlyAndSafely):
(WebKit::WebProcess::platformInitializeWebProcess):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (272016 => 272017)


--- trunk/Source/WebCore/ChangeLog	2021-01-28 17:28:29 UTC (rev 272016)
+++ trunk/Source/WebCore/ChangeLog	2021-01-28 18:01:25 UTC (rev 272017)
@@ -1,3 +1,18 @@
+2021-01-28  Per Arne  <pvol...@apple.com>
+
+        [macOS] Crash when updating color preferences
+        https://bugs.webkit.org/show_bug.cgi?id=221088
+        <rdar://problem/73709142>
+
+        Reviewed by Brent Fulgham.
+
+        Remove previous workaround in r271965 for preventing Launch Services connections, since this is covered
+        by the new approach in this patch.
+
+        * platform/mac/ThemeMac.mm:
+        (-[WebCoreThemeWindow isKeyWindow]):
+        (-[WebCoreThemeWindow invalidateRestorableState]): Deleted.
+
 2021-01-28  Ada Chan  <ada.c...@apple.com>
 
         REGRESSION (r271988): XRSession.end() promise is not resolved if PlatformXR::Device::supportsSessionShutdownNotification() returns false

Modified: trunk/Source/WebCore/PAL/ChangeLog (272016 => 272017)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-01-28 17:28:29 UTC (rev 272016)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-01-28 18:01:25 UTC (rev 272017)
@@ -1,3 +1,15 @@
+2021-01-28  Per Arne  <pvol...@apple.com>
+
+        [macOS] Crash when updating color preferences
+        https://bugs.webkit.org/show_bug.cgi?id=221088
+        <rdar://problem/73709142>
+
+        Reviewed by Brent Fulgham.
+
+        Declare NSApplication SPI for updating application information with Launch Services.
+
+        * pal/spi/mac/NSApplicationSPI.h:
+
 2021-01-21  Alex Christensen  <achristen...@webkit.org>
 
         Add experimental feature to use network loader

Modified: trunk/Source/WebCore/PAL/pal/spi/mac/NSApplicationSPI.h (272016 => 272017)


--- trunk/Source/WebCore/PAL/pal/spi/mac/NSApplicationSPI.h	2021-01-28 17:28:29 UTC (rev 272016)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/NSApplicationSPI.h	2021-01-28 18:01:25 UTC (rev 272017)
@@ -35,6 +35,8 @@
 - (void)accessibilitySetEnhancedUserInterfaceAttribute:(id)value;
 - (id)accessibilityEnhancedUserInterfaceAttribute;
 
+- (void)_updateCanQuitQuietlyAndSafely;
+
 // Conditionally define this only for !USE_APPLE_INTERNAL_SDK when <rdar://problem/63864711> is fixed.
 @property (copy, setter=_setAccentColor:) NSColor *_accentColor;
 @property (readonly, copy) NSColor *_effectiveAccentColor;

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (272016 => 272017)


--- trunk/Source/WebCore/platform/mac/ThemeMac.mm	2021-01-28 17:28:29 UTC (rev 272016)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm	2021-01-28 18:01:25 UTC (rev 272017)
@@ -66,10 +66,6 @@
 {
     return themeWindowHasKeyAppearance;
 }
-
-- (void)invalidateRestorableState
-{
-}
 @end
 
 @implementation WebCoreThemeView

Modified: trunk/Source/WebKit/ChangeLog (272016 => 272017)


--- trunk/Source/WebKit/ChangeLog	2021-01-28 17:28:29 UTC (rev 272016)
+++ trunk/Source/WebKit/ChangeLog	2021-01-28 18:01:25 UTC (rev 272017)
@@ -1,3 +1,21 @@
+2021-01-28  Per Arne  <pvol...@apple.com>
+
+        [macOS] Crash when updating color preferences
+        https://bugs.webkit.org/show_bug.cgi?id=221088
+        <rdar://problem/73709142>
+
+        Reviewed by Brent Fulgham.
+
+        After r271965, the WebContent process is no longer allowed to connect to the Launch Services daemon. This introduced a crash
+        in the WebContent process when color preferences were changed in System Preferences, since AppKit will then attempt to set
+        application information with Launch Services, which causes a crash when that fails. This patch addresses this issue by
+        overriding the AppKit method that updates the specific application information with Launch Services, since updating this
+        information should be required in the WebContent process.
+
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::updateCanQuitQuietlyAndSafely):
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
 2021-01-28  Brent Fulgham  <bfulg...@apple.com>
 
         [macOS] Remove reference to deprecated SubmitDiagInfo.domains path

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (272016 => 272017)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-01-28 17:28:29 UTC (rev 272016)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-01-28 18:01:25 UTC (rev 272017)
@@ -183,7 +183,15 @@
 
     return [page->accessibilityRemoteObject() accessibilityFocusedUIElement];
 }
+
+#if ENABLE(SET_WEBCONTENT_PROCESS_INFORMATION_IN_NETWORK_PROCESS)
+static void preventAppKitFromContactingLaunchServices(NSApplication*, SEL)
+{
+    // WebKit prohibits communication with Launch Services after entering the sandbox. This method override
+    // prevents AppKit from attempting to update application information with Launch Services from the WebContent process.
+}
 #endif
+#endif
 
 
 #if PLATFORM(MAC)
@@ -320,6 +328,9 @@
     updateProcessName();
 
 #if ENABLE(SET_WEBCONTENT_PROCESS_INFORMATION_IN_NETWORK_PROCESS)
+    auto method = class_getInstanceMethod([NSApplication class], @selector(_updateCanQuitQuietlyAndSafely));
+    method_setImplementation(method, (IMP)preventAppKitFromContactingLaunchServices);
+
     // FIXME: Replace the constant 4 with kLSServerConnectionStatusReleaseNotificationsMask when available in the SDK, see <https://bugs.webkit.org/show_bug.cgi?id=220988>.
     _LSSetApplicationLaunchServicesServerConnectionStatus(kLSServerConnectionStatusDoNotConnectToServerMask | /*kLSServerConnectionStatusReleaseNotificationsMask*/ 4, nullptr);
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to