Convert ProcessPrivilege assertions to regular debug-only assertions
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2018 20:20:35 +0000 (20:20 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2018 20:20:35 +0000 (20:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185775
<rdar://problem/40372286>

Reviewed by Geoffrey Garen.

In Bug 184322 I added a number of RELEASE_ASSERT checks that certain
UI-only calls were not being made in the WebContent process.

Measurements have shown that these RELEASE_ASSERTs have regressed performance
by around 1% on some benchmarks, so we should convert them to normal asserts.

This patch changes the RELEASE_ASSERTs into ASSERTs.

Source/WebCore:

* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::setDragImage):
* platform/mac/PlatformScreenMac.mm:
(WebCore::displayID):
(WebCore::firstScreen):
(WebCore::window):
(WebCore::screen):
(WebCore::getScreenProperties):
(WebCore::screenIsMonochrome):

Source/WebKit:

* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::WebViewImpl):
(WebKit::WebViewImpl::becomeFirstResponder):
(WebKit::WebViewImpl::pluginFocusOrWindowFocusChanged):
(WebKit::WebViewImpl::validateUserInterfaceItem):
(WebKit::WebViewImpl::startSpeaking):
(WebKit::WebViewImpl::stopSpeaking):
(WebKit::applicationFlagsForDrag):
(WebKit::WebViewImpl::doneWithKeyEvent):
* UIProcess/Gamepad/mac/UIGamepadProviderMac.mm:
(WebKit::UIGamepadProvider::platformWebPageProxyForGamepadInput):
* UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
(WebKit::PluginProcessProxy::enterFullscreen):
(WebKit::PluginProcessProxy::beginModal):
(WebKit::PluginProcessProxy::endModal):
* UIProcess/mac/DisplayLink.cpp:
(WebKit::DisplayLink::DisplayLink):
(WebKit::DisplayLink::~DisplayLink):
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::getIsSpeaking):
(WebKit::WebPageProxy::speak):
(WebKit::WebPageProxy::stopSpeaking):
(WebKit::WebPageProxy::startDisplayLink):
* UIProcess/mac/WebPopupMenuProxyMac.mm:
(WebKit::WebPopupMenuProxyMac::showPopupMenu):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231980 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mac/PasteboardMac.mm
Source/WebCore/platform/mac/PlatformScreenMac.mm
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit/UIProcess/Gamepad/mac/UIGamepadProviderMac.mm
Source/WebKit/UIProcess/Plugins/mac/PluginProcessProxyMac.mm
Source/WebKit/UIProcess/mac/DisplayLink.cpp
Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm

index a7ebd69..066fa11 100644 (file)
@@ -1,3 +1,29 @@
+2018-05-18  Brent Fulgham  <bfulgham@apple.com>
+
+        Convert ProcessPrivilege assertions to regular debug-only assertions
+        https://bugs.webkit.org/show_bug.cgi?id=185775
+        <rdar://problem/40372286>
+
+        Reviewed by Geoffrey Garen.
+
+        In Bug 184322 I added a number of RELEASE_ASSERT checks that certain
+        UI-only calls were not being made in the WebContent process.
+
+        Measurements have shown that these RELEASE_ASSERTs have regressed performance
+        by around 1% on some benchmarks, so we should convert them to normal asserts.
+
+        This patch changes the RELEASE_ASSERTs into ASSERTs.
+
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::Pasteboard::setDragImage):
+        * platform/mac/PlatformScreenMac.mm:
+        (WebCore::displayID):
+        (WebCore::firstScreen):
+        (WebCore::window):
+        (WebCore::screen):
+        (WebCore::getScreenProperties):
+        (WebCore::screenIsMonochrome):
+
 2018-05-18  Eric Carlson  <eric.carlson@apple.com>
 
         Handle failure to extend sandbox gracefully
index 6582af3..47636c5 100644 (file)
@@ -676,7 +676,7 @@ void Pasteboard::setDragImage(DragImage image, const IntPoint& location)
     // This is only relevant in WK1. Do not execute in the WebContent process, since it is now using
     // NSRunLoop, and not the NSApplication run loop.
     if ([NSApp isRunning]) {
-        RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+        ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
         NSEvent* event = [NSEvent mouseEventWithType:NSEventTypeMouseMoved location:NSZeroPoint
             modifierFlags:0 timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:0 pressure:0];
         [NSApp postEvent:event atStart:YES];
index f479519..c31add9 100644 (file)
@@ -48,7 +48,7 @@ namespace WebCore {
 
 static PlatformDisplayID displayID(NSScreen *screen)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     return [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
 }
 
@@ -71,7 +71,7 @@ static PlatformDisplayID displayID(Widget* widget)
 // Screen containing the menubar.
 static NSScreen *firstScreen()
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     NSArray *screens = [NSScreen screens];
     if (![screens count])
         return nil;
@@ -80,7 +80,7 @@ static NSScreen *firstScreen()
 
 static NSWindow *window(Widget* widget)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     if (!widget)
         return nil;
     return widget->platformWidget().window;
@@ -88,7 +88,7 @@ static NSWindow *window(Widget* widget)
 
 static NSScreen *screen(Widget* widget)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     // If the widget is in a window, use that, otherwise use the display ID from the host window.
     // First case is for when the NSWindow is in the same process, second case for when it's not.
     if (auto screenFromWindow = window(widget).screen)
@@ -110,7 +110,7 @@ static PlatformDisplayID& primaryScreenDisplayID()
 
 std::pair<PlatformDisplayID, HashMap<PlatformDisplayID, ScreenProperties>> getScreenProperties()
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
 
     HashMap<PlatformDisplayID, ScreenProperties> screenProperties;
     std::optional<PlatformDisplayID> firstScreen;
@@ -171,7 +171,7 @@ bool screenIsMonochrome(Widget* widget)
         return getScreenProperties(widget).screenIsMonochrome;
 
     // This is a system-wide accessibility setting, same on all screens.
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     return CGDisplayUsesForceToGray();
 }
 
@@ -246,13 +246,13 @@ FloatRect screenAvailableRect(Widget* widget)
 
 NSScreen *screen(NSWindow *window)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     return [window screen] ?: firstScreen();
 }
 
 NSScreen *screen(PlatformDisplayID displayID)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     for (NSScreen *screen in [NSScreen screens]) {
         if (WebCore::displayID(screen) == displayID)
             return screen;
index 5b8d1f6..5be0b4e 100644 (file)
@@ -1,3 +1,47 @@
+2018-05-18  Brent Fulgham  <bfulgham@apple.com>
+
+        Convert ProcessPrivilege assertions to regular debug-only assertions
+        https://bugs.webkit.org/show_bug.cgi?id=185775
+        <rdar://problem/40372286>
+
+        Reviewed by Geoffrey Garen.
+
+        In Bug 184322 I added a number of RELEASE_ASSERT checks that certain
+        UI-only calls were not being made in the WebContent process.
+
+        Measurements have shown that these RELEASE_ASSERTs have regressed performance
+        by around 1% on some benchmarks, so we should convert them to normal asserts.
+
+        This patch changes the RELEASE_ASSERTs into ASSERTs.
+
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess):
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::WebViewImpl):
+        (WebKit::WebViewImpl::becomeFirstResponder):
+        (WebKit::WebViewImpl::pluginFocusOrWindowFocusChanged):
+        (WebKit::WebViewImpl::validateUserInterfaceItem):
+        (WebKit::WebViewImpl::startSpeaking):
+        (WebKit::WebViewImpl::stopSpeaking):
+        (WebKit::applicationFlagsForDrag):
+        (WebKit::WebViewImpl::doneWithKeyEvent):
+        * UIProcess/Gamepad/mac/UIGamepadProviderMac.mm:
+        (WebKit::UIGamepadProvider::platformWebPageProxyForGamepadInput):
+        * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
+        (WebKit::PluginProcessProxy::enterFullscreen):
+        (WebKit::PluginProcessProxy::beginModal):
+        (WebKit::PluginProcessProxy::endModal):
+        * UIProcess/mac/DisplayLink.cpp:
+        (WebKit::DisplayLink::DisplayLink):
+        (WebKit::DisplayLink::~DisplayLink):
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::getIsSpeaking):
+        (WebKit::WebPageProxy::speak):
+        (WebKit::WebPageProxy::stopSpeaking):
+        (WebKit::WebPageProxy::startDisplayLink):
+        * UIProcess/mac/WebPopupMenuProxyMac.mm:
+        (WebKit::WebPopupMenuProxyMac::showPopupMenu):
+
 2018-05-18  Eric Carlson  <eric.carlson@apple.com>
 
         Handle failure to extend sandbox gracefully
index 894dc9e..3823945 100644 (file)
@@ -180,7 +180,7 @@ void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters&
 #if PLATFORM(MAC)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     parameters.accessibilityEnhancedUserInterfaceEnabled = [[NSApp accessibilityAttributeValue:@"AXEnhancedUserInterface"] boolValue];
 #pragma clang diagnostic pop
 #else
index 5d1ffd6..591b02e 100644 (file)
@@ -1295,7 +1295,7 @@ WebViewImpl::WebViewImpl(NSView <WebViewImplDelegate> *view, WKWebView *outerWeb
 {
     static_cast<PageClientImpl&>(*m_pageClient).setImpl(*this);
 
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     [NSApp registerServicesMenuSendTypes:PasteboardTypes::forSelection() returnTypes:PasteboardTypes::forEditing()];
 
     [view addTrackingArea:m_primaryTrackingArea.get()];
@@ -1429,7 +1429,7 @@ bool WebViewImpl::acceptsFirstResponder()
 
 bool WebViewImpl::becomeFirstResponder()
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     // If we just became first responder again, there is no need to do anything,
     // since resignFirstResponder has correctly detected this situation.
     if (m_willBecomeFirstResponderAgain) {
@@ -2386,7 +2386,7 @@ bool WebViewImpl::tryHandlePluginComplexTextInputKeyDown(NSEvent *event)
 
 void WebViewImpl::pluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus, uint64_t pluginComplexTextInputIdentifier)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     BOOL inputSourceChanged = m_pluginComplexTextInputIdentifier;
 
     if (pluginHasFocusAndWindowHasFocus) {
@@ -2696,7 +2696,7 @@ static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
 
 bool WebViewImpl::validateUserInterfaceItem(id <NSValidatedUserInterfaceItem> item)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     SEL action = [item action];
 
     if (action == @selector(showGuessPanel:)) {
@@ -2818,7 +2818,7 @@ void WebViewImpl::setUserInterfaceItemState(NSString *commandName, bool enabled,
 
 void WebViewImpl::startSpeaking()
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     m_page->getSelectionOrContentsAsString([](const String& string, WebKit::CallbackBase::Error error) {
         if (error != WebKit::CallbackBase::Error::None)
             return;
@@ -2831,7 +2831,7 @@ void WebViewImpl::startSpeaking()
 
 void WebViewImpl::stopSpeaking(id sender)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     [NSApp stopSpeaking:sender];
 }
 
@@ -3639,7 +3639,7 @@ void WebViewImpl::draggedImage(NSImage *image, CGPoint endPoint, NSDragOperation
 
 static WebCore::DragApplicationFlags applicationFlagsForDrag(NSView *view, id <NSDraggingInfo> draggingInfo)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     uint32_t flags = 0;
     if ([NSApp modalWindow])
         flags = WebCore::DragApplicationIsModal;
@@ -4252,7 +4252,7 @@ void WebViewImpl::didRestoreScrollPosition()
 
 void WebViewImpl::doneWithKeyEvent(NSEvent *event, bool eventWasHandled)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     if ([event type] != NSEventTypeKeyDown)
         return;
 
index a6aff84..895d42c 100644 (file)
@@ -38,7 +38,7 @@ namespace WebKit {
 
 WebPageProxy* UIGamepadProvider::platformWebPageProxyForGamepadInput()
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     auto responder = [[NSApp keyWindow] firstResponder];
 
 #if WK_API_ENABLED
index 73a132e..25ace26 100644 (file)
@@ -132,7 +132,7 @@ void PluginProcessProxy::setFullscreenWindowIsShowing(bool fullscreenWindowIsSho
 
 void PluginProcessProxy::enterFullscreen()
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     // Get the current presentation options.
     m_preFullscreenAppPresentationOptions = [NSApp presentationOptions];
 
@@ -193,7 +193,7 @@ void PluginProcessProxy::beginModal()
 {
     ASSERT(!m_placeholderWindow);
     ASSERT(!m_activationObserver);
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
 
     m_placeholderWindow = adoptNS([[WKPlaceholderModalWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1) styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:YES]);
     [m_placeholderWindow setReleasedWhenClosed:NO];
@@ -215,7 +215,7 @@ void PluginProcessProxy::endModal()
 {
     ASSERT(m_placeholderWindow);
     ASSERT(m_activationObserver);
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
 
     [[NSNotificationCenter defaultCenter] removeObserver:m_activationObserver.get()];
     m_activationObserver = nullptr;
index a2ff561..c3b0c2d 100644 (file)
@@ -37,7 +37,7 @@ namespace WebKit {
     
 DisplayLink::DisplayLink(WebCore::PlatformDisplayID displayID, WebPageProxy& webPageProxy)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     CVReturn error = CVDisplayLinkCreateWithCGDisplay(displayID, &m_displayLink);
     if (error) {
         WTFLogAlways("Could not create a display link: %d", error);
@@ -57,7 +57,7 @@ DisplayLink::DisplayLink(WebCore::PlatformDisplayID displayID, WebPageProxy& web
 
 DisplayLink::~DisplayLink()
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     ASSERT(m_displayLink);
     if (!m_displayLink)
         return;
index f62f169..37af08c 100644 (file)
@@ -133,19 +133,19 @@ String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent
 
 void WebPageProxy::getIsSpeaking(bool& isSpeaking)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     isSpeaking = [NSApp isSpeaking];
 }
 
 void WebPageProxy::speak(const String& string)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     [NSApp speakString:nsStringFromWebCoreString(string)];
 }
 
 void WebPageProxy::stopSpeaking()
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     [NSApp stopSpeaking:nil];
 }
 
@@ -684,7 +684,7 @@ _WKRemoteObjectRegistry *WebPageProxy::remoteObjectRegistry()
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
 void WebPageProxy::startDisplayLink(unsigned observerID)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     if (!m_displayLink) {
         uint32_t displayID = [[[[platformWindow() screen] deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
         m_displayLink = std::make_unique<DisplayLink>(displayID, *this);
index 6374159..bda42bc 100644 (file)
@@ -99,7 +99,7 @@ void WebPopupMenuProxyMac::populate(const Vector<WebPopupItem>& items, NSFont *f
 
 void WebPopupMenuProxyMac::showPopupMenu(const IntRect& rect, TextDirection textDirection, double pageScaleFactor, const Vector<WebPopupItem>& items, const PlatformPopupMenuData& data, int32_t selectedIndex)
 {
-    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     NSFont *font;
     if (data.fontInfo.fontAttributeDictionary) {
         NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:(NSDictionary *)data.fontInfo.fontAttributeDictionary.get()];