Title: [206410] trunk/Source/WebKit2
Revision
206410
Author
m...@apple.com
Date
2016-09-26 20:35:01 -0700 (Mon, 26 Sep 2016)

Log Message

-_webViewWebProcessDidBecomeUnresponsive: gets called when the Web process is stopped in the debugger
https://bugs.webkit.org/show_bug.cgi?id=162234

Reviewed by Sam Weinig.

* UIProcess/Cocoa/WebProcessProxyCocoa.mm:
(WebKit::WebProcessProxy::platformIsBeingDebugged): Use the KERN_PROC sysctl to get the
  process flags and check for P_TRACED.

* UIProcess/ResponsivenessTimer.cpp:
(WebKit::ResponsivenessTimer::timerFired): Call the new client function
  mayBecomeUnresponsive. If it returns false, restart the timer and bail out without
  changing the responsiveness state.

* UIProcess/ResponsivenessTimer.h: Declared new client function mayBecomeUnresponsive.

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::platformIsBeingDebugged): A generic implementation that always
  returns false.
(WebKit::WebProcessProxy::mayBecomeUnresponsive): Implement this new
  ResponsivenessTimer::Client function to return true unless the process is being debugged.
* UIProcess/WebProcessProxy.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (206409 => 206410)


--- trunk/Source/WebKit2/ChangeLog	2016-09-27 03:06:26 UTC (rev 206409)
+++ trunk/Source/WebKit2/ChangeLog	2016-09-27 03:35:01 UTC (rev 206410)
@@ -1,3 +1,28 @@
+2016-09-26  Dan Bernstein  <m...@apple.com>
+
+        -_webViewWebProcessDidBecomeUnresponsive: gets called when the Web process is stopped in the debugger
+        https://bugs.webkit.org/show_bug.cgi?id=162234
+
+        Reviewed by Sam Weinig.
+
+        * UIProcess/Cocoa/WebProcessProxyCocoa.mm:
+        (WebKit::WebProcessProxy::platformIsBeingDebugged): Use the KERN_PROC sysctl to get the
+          process flags and check for P_TRACED.
+
+        * UIProcess/ResponsivenessTimer.cpp:
+        (WebKit::ResponsivenessTimer::timerFired): Call the new client function
+          mayBecomeUnresponsive. If it returns false, restart the timer and bail out without
+          changing the responsiveness state.
+
+        * UIProcess/ResponsivenessTimer.h: Declared new client function mayBecomeUnresponsive.
+
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::platformIsBeingDebugged): A generic implementation that always
+          returns false.
+        (WebKit::WebProcessProxy::mayBecomeUnresponsive): Implement this new
+          ResponsivenessTimer::Client function to return true unless the process is being debugged.
+        * UIProcess/WebProcessProxy.h:
+
 2016-09-26  Chris Dumez  <cdu...@apple.com>
 
         [WK2] BlobDownloadClient should use asynchronous IPC to decide destination path

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessProxyCocoa.mm (206409 => 206410)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessProxyCocoa.mm	2016-09-27 03:06:26 UTC (rev 206409)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessProxyCocoa.mm	2016-09-27 03:35:01 UTC (rev 206410)
@@ -30,6 +30,7 @@
 #import "WKBrowsingContextControllerInternal.h"
 #import "WKBrowsingContextHandleInternal.h"
 #import "WKTypeRefWrapper.h"
+#import <sys/sysctl.h>
 #import <wtf/NeverDestroyed.h>
 
 namespace WebKit {
@@ -120,4 +121,15 @@
     return ObjCObjectGraph::create(ObjCObjectGraph::transform(objectGraph.rootObject(), Transformer()).get());
 }
 
+bool WebProcessProxy::platformIsBeingDebugged() const
+{
+    struct kinfo_proc info;
+    int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, processIdentifier() };
+    size_t size = sizeof(info);
+    if (sysctl(mib, WTF_ARRAY_LENGTH(mib), &info, &size, nullptr, 0) == -1)
+        return false;
+
+    return info.kp_proc.p_flag & P_TRACED;
 }
+
+}

Modified: trunk/Source/WebKit2/UIProcess/ResponsivenessTimer.cpp (206409 => 206410)


--- trunk/Source/WebKit2/UIProcess/ResponsivenessTimer.cpp	2016-09-27 03:06:26 UTC (rev 206409)
+++ trunk/Source/WebKit2/UIProcess/ResponsivenessTimer.cpp	2016-09-27 03:35:01 UTC (rev 206410)
@@ -52,6 +52,11 @@
     if (!m_isResponsive)
         return;
 
+    if (!m_client.mayBecomeUnresponsive()) {
+        m_timer.startOneShot(responsivenessTimeout);
+        return;
+    }
+
     m_client.willChangeIsResponsive();
     m_isResponsive = false;
     m_client.didChangeIsResponsive();

Modified: trunk/Source/WebKit2/UIProcess/ResponsivenessTimer.h (206409 => 206410)


--- trunk/Source/WebKit2/UIProcess/ResponsivenessTimer.h	2016-09-27 03:06:26 UTC (rev 206409)
+++ trunk/Source/WebKit2/UIProcess/ResponsivenessTimer.h	2016-09-27 03:35:01 UTC (rev 206410)
@@ -40,6 +40,8 @@
 
         virtual void willChangeIsResponsive() = 0;
         virtual void didChangeIsResponsive() = 0;
+
+        virtual bool mayBecomeUnresponsive() = 0;
     };
 
     explicit ResponsivenessTimer(ResponsivenessTimer::Client&);

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (206409 => 206410)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2016-09-27 03:06:26 UTC (rev 206409)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2016-09-27 03:35:01 UTC (rev 206410)
@@ -472,6 +472,13 @@
     m_pageURLRetainCountMap.clear();
 }
 
+#if !PLATFORM(COCOA)
+bool WebProcessProxy::platformIsBeingDebugged() const
+{
+    return false;
+}
+#endif
+
 void WebProcessProxy::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
 {
     if (dispatchMessage(connection, decoder))
@@ -579,6 +586,11 @@
         page->didChangeProcessIsResponsive();
 }
 
+bool WebProcessProxy::mayBecomeUnresponsive()
+{
+    return !platformIsBeingDebugged();
+}
+
 void WebProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connection::Identifier connectionIdentifier)
 {
     ChildProcessProxy::didFinishLaunching(launcher, connectionIdentifier);

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (206409 => 206410)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2016-09-27 03:06:26 UTC (rev 206409)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2016-09-27 03:35:01 UTC (rev 206410)
@@ -186,6 +186,8 @@
     void releaseIconForPageURL(const String& pageURL);
     void releaseRemainingIconsForPageURLs();
 
+    bool platformIsBeingDebugged() const;
+
     static const HashSet<String>& platformPathsWithAssumedReadAccess();
 
     // IPC::Connection::Client
@@ -200,6 +202,7 @@
     void didBecomeResponsive() override;
     void willChangeIsResponsive() override;
     void didChangeIsResponsive() override;
+    bool mayBecomeUnresponsive() override;
 
     // ProcessThrottlerClient
     void sendProcessWillSuspendImminently() override;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to