Title: [185749] trunk/Source
Revision
185749
Author
ander...@apple.com
Date
2015-06-19 09:53:49 -0700 (Fri, 19 Jun 2015)

Log Message

Spintracer treats the web process as hung when it's showing _javascript_ dialogs in the UI process
https://bugs.webkit.org/show_bug.cgi?id=146124
rdar://problem/21449395

Reviewed by Geoffrey Garen.

Add a HangDetectionDisabler RAII object and use it for _javascript_ panels.

* Shared/HangDetectionDisabler.h: Added.
(WebKit::HangDetectionDisabler::HangDetectionDisabler):
(WebKit::HangDetectionDisabler::~HangDetectionDisabler):
* Shared/mac/HangDetectionDisablerMac.mm: Added.
(WebKit::clientsMayIgnoreEvents):
(WebKit::setClientsMayIgnoreEvents):
(WebKit::HangDetectionDisabler::HangDetectionDisabler):
(WebKit::HangDetectionDisabler::~HangDetectionDisabler):
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::runBeforeUnloadConfirmPanel):
(WebKit::WebChromeClient::runJavaScriptAlert):
(WebKit::WebChromeClient::runJavaScriptConfirm):
(WebKit::WebChromeClient::runJavaScriptPrompt):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (185748 => 185749)


--- trunk/Source/WebCore/ChangeLog	2015-06-19 16:05:54 UTC (rev 185748)
+++ trunk/Source/WebCore/ChangeLog	2015-06-19 16:53:49 UTC (rev 185749)
@@ -1,3 +1,13 @@
+2015-06-19  Anders Carlsson  <ander...@apple.com>
+
+        Spintracer treats the web process as hung when it's showing _javascript_ dialogs in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=146124
+        rdar://problem/21449395
+
+        Reviewed by Geoffrey Garen.
+
+        * platform/spi/cg/CoreGraphicsSPI.h:
+
 2015-06-19  Csaba Osztrogonác  <o...@webkit.org>
 
         Remove unnecessary svn:executable flags

Modified: trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h (185748 => 185749)


--- trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h	2015-06-19 16:05:54 UTC (rev 185748)
+++ trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h	2015-06-19 16:53:49 UTC (rev 185749)
@@ -179,6 +179,8 @@
 #if PLATFORM(MAC)
 CGSConnectionID CGSMainConnectionID(void);
 CFArrayRef CGSHWCaptureWindowList(CGSConnectionID cid, CGSWindowIDList windowList, CGSWindowCount windowCount, CGSWindowCaptureOptions options);
+CGError CGSSetConnectionProperty(CGSConnectionID, CGSConnectionID ownerCid, CFStringRef key, CFTypeRef value);
+CGError CGSCopyConnectionProperty(CGSConnectionID, CGSConnectionID ownerCid, CFStringRef key, CFTypeRef *value);
 #endif
 
 WTF_EXTERN_C_END

Modified: trunk/Source/WebKit2/ChangeLog (185748 => 185749)


--- trunk/Source/WebKit2/ChangeLog	2015-06-19 16:05:54 UTC (rev 185748)
+++ trunk/Source/WebKit2/ChangeLog	2015-06-19 16:53:49 UTC (rev 185749)
@@ -1,3 +1,28 @@
+2015-06-19  Anders Carlsson  <ander...@apple.com>
+
+        Spintracer treats the web process as hung when it's showing _javascript_ dialogs in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=146124
+        rdar://problem/21449395
+
+        Reviewed by Geoffrey Garen.
+
+        Add a HangDetectionDisabler RAII object and use it for _javascript_ panels.
+
+        * Shared/HangDetectionDisabler.h: Added.
+        (WebKit::HangDetectionDisabler::HangDetectionDisabler):
+        (WebKit::HangDetectionDisabler::~HangDetectionDisabler):
+        * Shared/mac/HangDetectionDisablerMac.mm: Added.
+        (WebKit::clientsMayIgnoreEvents):
+        (WebKit::setClientsMayIgnoreEvents):
+        (WebKit::HangDetectionDisabler::HangDetectionDisabler):
+        (WebKit::HangDetectionDisabler::~HangDetectionDisabler):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::runBeforeUnloadConfirmPanel):
+        (WebKit::WebChromeClient::runJavaScriptAlert):
+        (WebKit::WebChromeClient::runJavaScriptConfirm):
+        (WebKit::WebChromeClient::runJavaScriptPrompt):
+
 2015-06-19  Dan Bernstein  <m...@apple.com>
 
         Fixed the build for platforms that don’t have SafariServices.

Added: trunk/Source/WebKit2/Shared/HangDetectionDisabler.h (0 => 185749)


--- trunk/Source/WebKit2/Shared/HangDetectionDisabler.h	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/HangDetectionDisabler.h	2015-06-19 16:53:49 UTC (rev 185749)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HangDetectionDisabler_h
+#define HangDetectionDisabler_h
+
+namespace WebKit {
+
+class HangDetectionDisabler {
+public:
+    HangDetectionDisabler();
+    ~HangDetectionDisabler();
+
+private:
+#if PLATFORM(MAC)
+    bool m_clientsMayIgnoreEvents;
+#endif
+};
+
+#if !PLATFORM(MAC)
+inline HangDetectionDisabler::HangDetectionDisabler()
+{
+}
+
+inline HangDetectionDisabler::~HangDetectionDisabler()
+{
+}
+#endif
+
+}
+
+#endif // HangDetectionDisabler_h

Added: trunk/Source/WebKit2/Shared/mac/HangDetectionDisablerMac.mm (0 => 185749)


--- trunk/Source/WebKit2/Shared/mac/HangDetectionDisablerMac.mm	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/mac/HangDetectionDisablerMac.mm	2015-06-19 16:53:49 UTC (rev 185749)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "HangDetectionDisabler.h"
+
+#if PLATFORM(MAC)
+
+#include <WebCore/CoreGraphicsSPI.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebKit {
+
+static const auto clientsMayIgnoreEventsKey = CFSTR("ClientMayIgnoreEvents");
+
+static bool clientsMayIgnoreEvents()
+{
+    CFTypeRef valuePtr;
+    if (CGSCopyConnectionProperty(CGSMainConnectionID(), CGSMainConnectionID(), clientsMayIgnoreEventsKey, &valuePtr) != kCGErrorSuccess)
+        return false;
+
+    auto value = adoptCF(valuePtr);
+
+    if (!value || CFGetTypeID(value.get()) != CFBooleanGetTypeID())
+        return false;
+
+    return value == kCFBooleanTrue;
+}
+
+static void setClientsMayIgnoreEvents(bool clientsMayIgnoreEvents)
+{
+    if (CGSSetConnectionProperty(CGSMainConnectionID(), CGSMainConnectionID(), clientsMayIgnoreEventsKey, clientsMayIgnoreEvents ? kCFBooleanTrue : kCFBooleanFalse) != kCGErrorSuccess)
+        ASSERT_NOT_REACHED();
+}
+
+HangDetectionDisabler::HangDetectionDisabler()
+    : m_clientsMayIgnoreEvents(clientsMayIgnoreEvents())
+{
+    setClientsMayIgnoreEvents(true);
+}
+
+HangDetectionDisabler::~HangDetectionDisabler()
+{
+    setClientsMayIgnoreEvents(m_clientsMayIgnoreEvents);
+}
+
+}
+
+#endif

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (185748 => 185749)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-06-19 16:05:54 UTC (rev 185748)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-06-19 16:53:49 UTC (rev 185749)
@@ -438,6 +438,8 @@
 		1AC7537C183A9FDB0072CB15 /* PageLoadState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC7537A183A9FDB0072CB15 /* PageLoadState.h */; };
 		1AC7537F183BE50F0072CB15 /* DataReference.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC7537D183BE50F0072CB15 /* DataReference.cpp */; };
 		1AC75380183BE50F0072CB15 /* DataReference.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC7537E183BE50F0072CB15 /* DataReference.h */; };
+		1AC75A1B1B3368270056745B /* HangDetectionDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC75A1A1B3368270056745B /* HangDetectionDisabler.h */; };
+		1AC75A1E1B33695E0056745B /* HangDetectionDisablerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AC75A1C1B33695E0056745B /* HangDetectionDisablerMac.mm */; };
 		1AC86FF3130B46D3002C1257 /* WKPluginSiteDataManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC86FF1130B46D3002C1257 /* WKPluginSiteDataManager.cpp */; };
 		1AC86FF4130B46D3002C1257 /* WKPluginSiteDataManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC86FF2130B46D3002C1257 /* WKPluginSiteDataManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1ACC87BA1981C341003D1AF4 /* WKNavigationPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACC87B91981C341003D1AF4 /* WKNavigationPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2563,6 +2565,8 @@
 		1AC7537A183A9FDB0072CB15 /* PageLoadState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageLoadState.h; sourceTree = "<group>"; };
 		1AC7537D183BE50F0072CB15 /* DataReference.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataReference.cpp; sourceTree = "<group>"; };
 		1AC7537E183BE50F0072CB15 /* DataReference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataReference.h; sourceTree = "<group>"; };
+		1AC75A1A1B3368270056745B /* HangDetectionDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HangDetectionDisabler.h; sourceTree = "<group>"; };
+		1AC75A1C1B33695E0056745B /* HangDetectionDisablerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HangDetectionDisablerMac.mm; sourceTree = "<group>"; };
 		1AC86FF1130B46D3002C1257 /* WKPluginSiteDataManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKPluginSiteDataManager.cpp; sourceTree = "<group>"; };
 		1AC86FF2130B46D3002C1257 /* WKPluginSiteDataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPluginSiteDataManager.h; sourceTree = "<group>"; };
 		1ACC87B91981C341003D1AF4 /* WKNavigationPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationPrivate.h; sourceTree = "<group>"; };
@@ -4699,6 +4703,7 @@
 				BCE81D8A1319F7EF00241910 /* FontInfo.cpp */,
 				BCE81D8B1319F7EF00241910 /* FontInfo.h */,
 				762B7481120BBA0100819339 /* FontSmoothingLevel.h */,
+				1AC75A1A1B3368270056745B /* HangDetectionDisabler.h */,
 				F638954F133BEF38008941D5 /* HTTPCookieAcceptPolicy.h */,
 				BCCF6B2312C93E7A008F9C35 /* ImageOptions.h */,
 				C58CDF2B1887609F00871536 /* InteractionInformationAtPosition.cpp */,
@@ -6448,6 +6453,7 @@
 				CDC3830D1721242D008A2FC3 /* CookieStorageShim.mm */,
 				CDC382F9172116D3008A2FC3 /* CookieStorageShimLibrary.cpp */,
 				CDC3830B172121CE008A2FC3 /* CookieStorageShimLibrary.h */,
+				1AC75A1C1B33695E0056745B /* HangDetectionDisablerMac.mm */,
 				5163EA431ACC74AE0012D1E4 /* NativeContextMenuItem.mm */,
 				C02BFF1D1251502E009CCBEA /* NativeWebKeyboardEventMac.mm */,
 				31EA25D0134F78B2005B1452 /* NativeWebMouseEventMac.mm */,
@@ -7996,6 +8002,7 @@
 				BC032DD110F4389F0058C15A /* WebPageProxy.h in Headers */,
 				BCBD3915125BB1A800D2C29F /* WebPageProxyMessages.h in Headers */,
 				512127C41908239A00DAF35C /* WebPasteboardOverrides.h in Headers */,
+				1AC75A1B1B3368270056745B /* HangDetectionDisabler.h in Headers */,
 				7C4694D11A51E36800AD5845 /* WebPasteboardProxy.h in Headers */,
 				7C4694CA1A4B4EA100AD5845 /* WebPasteboardProxyMessages.h in Headers */,
 				1A3E736111CC2659007BD539 /* WebPlatformStrategies.h in Headers */,
@@ -10032,6 +10039,7 @@
 				37948408150C4B9700E52CE9 /* WKRenderLayer.cpp in Sources */,
 				37608822150414F700FC82C7 /* WKRenderObject.cpp in Sources */,
 				3336763A130C99DC006C9DE2 /* WKResourceCacheManager.cpp in Sources */,
+				1AC75A1E1B33695E0056745B /* HangDetectionDisablerMac.mm in Sources */,
 				1A7E377818E4A4FE003D0FFF /* WKScriptMessage.mm in Sources */,
 				0FCB4E5518BBE044000FCFC9 /* WKScrollView.mm in Sources */,
 				F634445C12A885E9000612D8 /* WKSecurityOrigin.cpp in Sources */,

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (185748 => 185749)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2015-06-19 16:05:54 UTC (rev 185748)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2015-06-19 16:53:49 UTC (rev 185749)
@@ -30,6 +30,7 @@
 #include "APIArray.h"
 #include "APISecurityOrigin.h"
 #include "DrawingArea.h"
+#include "HangDetectionDisabler.h"
 #include "InjectedBundleNavigationAction.h"
 #include "InjectedBundleNodeHandle.h"
 #include "LayerTreeHost.h"
@@ -334,6 +335,8 @@
 
     bool shouldClose = false;
 
+    HangDetectionDisabler hangDetectionDisabler;
+
     unsigned syncSendFlags = IPC::InformPlatformProcessWillSuspend;
     if (WebPage::synchronousMessagesShouldSpinRunLoop())
         syncSendFlags |= IPC::SpinRunLoopWhileWaitingForReply;
@@ -371,6 +374,8 @@
     // Notify the bundle client.
     m_page->injectedBundleUIClient().willRunJavaScriptAlert(m_page, alertText, webFrame);
 
+    HangDetectionDisabler hangDetectionDisabler;
+
     unsigned syncSendFlags = IPC::InformPlatformProcessWillSuspend;
     if (WebPage::synchronousMessagesShouldSpinRunLoop())
         syncSendFlags |= IPC::SpinRunLoopWhileWaitingForReply;
@@ -385,6 +390,8 @@
     // Notify the bundle client.
     m_page->injectedBundleUIClient().willRunJavaScriptConfirm(m_page, message, webFrame);
 
+    HangDetectionDisabler hangDetectionDisabler;
+
     unsigned syncSendFlags = IPC::InformPlatformProcessWillSuspend;
     if (WebPage::synchronousMessagesShouldSpinRunLoop())
         syncSendFlags |= IPC::SpinRunLoopWhileWaitingForReply;
@@ -403,6 +410,8 @@
     // Notify the bundle client.
     m_page->injectedBundleUIClient().willRunJavaScriptPrompt(m_page, message, defaultValue, webFrame);
 
+    HangDetectionDisabler hangDetectionDisabler;
+
     unsigned syncSendFlags = IPC::InformPlatformProcessWillSuspend;
     if (WebPage::synchronousMessagesShouldSpinRunLoop())
         syncSendFlags |= IPC::SpinRunLoopWhileWaitingForReply;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to