Title: [177610] trunk/Source/WebKit2
Revision
177610
Author
[email protected]
Date
2014-12-19 16:57:55 -0800 (Fri, 19 Dec 2014)

Log Message

Web Inspector: Inspector does not reopen correctly after Inspector Process crashes
https://bugs.webkit.org/show_bug.cgi?id=139838

Patch by Joseph Pecoraro <[email protected]> on 2014-12-19
Reviewed by Timothy Hatcher.

When the WebContentProcess holding the Inspector Frontend crashes, we
would properly tear down the inspector objects. However, the next time
the inspector is opened, when creating the new page in the Inspector
Page Group, a WebPageProxy is created with a Terminated WebProcessProxy.

That Terminated WebProcessProxy is automatically replaced with the next
load request is given. The newly created process was missing the
message listeners and assumed URL access settings that the
WebInspectorProxy had set on the old process.

So, WebInspectorProxy now listens for and resets the process properties
when the inspector process is recreated.

* UIProcess/WebInspectorProxy.h:
* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::didRelaunchInspectorPageProcess):
Reset process properties when the process is relaunched.

(WebKit::WebInspectorProxy::createInspectorPage):
(WebKit::WebInspectorProxy::didClose):
Save connection identifier if we need to establish connections later.

* UIProcess/mac/WebInspectorProxyMac.mm:
(-[WKWebInspectorProxyObjCAdapter didRelaunchProcess]):
(-[WKWebInspectorWKView _didRelaunchProcess]):
(WebKit::WebInspectorProxy::closeTimerFired):
(WebKit::WebInspectorProxy::platformCreateInspectorPage):
Send WebInspectorProxy a message when the process underlying the
WKView is relaunched.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (177609 => 177610)


--- trunk/Source/WebKit2/ChangeLog	2014-12-20 00:52:35 UTC (rev 177609)
+++ trunk/Source/WebKit2/ChangeLog	2014-12-20 00:57:55 UTC (rev 177610)
@@ -1,3 +1,40 @@
+2014-12-19  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Inspector does not reopen correctly after Inspector Process crashes
+        https://bugs.webkit.org/show_bug.cgi?id=139838
+
+        Reviewed by Timothy Hatcher.
+
+        When the WebContentProcess holding the Inspector Frontend crashes, we
+        would properly tear down the inspector objects. However, the next time
+        the inspector is opened, when creating the new page in the Inspector
+        Page Group, a WebPageProxy is created with a Terminated WebProcessProxy.
+
+        That Terminated WebProcessProxy is automatically replaced with the next
+        load request is given. The newly created process was missing the
+        message listeners and assumed URL access settings that the
+        WebInspectorProxy had set on the old process.
+
+        So, WebInspectorProxy now listens for and resets the process properties
+        when the inspector process is recreated.
+
+        * UIProcess/WebInspectorProxy.h:
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::didRelaunchInspectorPageProcess):
+        Reset process properties when the process is relaunched.
+
+        (WebKit::WebInspectorProxy::createInspectorPage):
+        (WebKit::WebInspectorProxy::didClose):
+        Save connection identifier if we need to establish connections later.
+
+        * UIProcess/mac/WebInspectorProxyMac.mm:
+        (-[WKWebInspectorProxyObjCAdapter didRelaunchProcess]):
+        (-[WKWebInspectorWKView _didRelaunchProcess]):
+        (WebKit::WebInspectorProxy::closeTimerFired):
+        (WebKit::WebInspectorProxy::platformCreateInspectorPage):
+        Send WebInspectorProxy a message when the process underlying the
+        WKView is relaunched.
+
 2014-12-19  Anders Carlsson  <[email protected]>
 
         Get rid of the hardcoded set of structs in the message generation script

Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp (177609 => 177610)


--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp	2014-12-20 00:52:35 UTC (rev 177609)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp	2014-12-20 00:57:55 UTC (rev 177610)
@@ -236,6 +236,17 @@
     didClose();
 }
 
+void WebInspectorProxy::didRelaunchInspectorPageProcess()
+{
+    m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_page->pageID(), *this);
+    m_inspectorPage->process().assumeReadAccessToBaseURL(inspectorBaseURL());
+
+    // When didRelaunchInspectorPageProcess is called we can assume it is during a load request.
+    // Any messages we would have sent to a terminated process need to be re-sent.
+
+    m_inspectorPage->process().send(Messages::WebInspectorUI::EstablishConnection(m_connectionIdentifier, m_page->pageID(), m_underTest), m_inspectorPage->pageID());
+}
+
 void WebInspectorProxy::showConsole()
 {
     if (!m_page)
@@ -526,8 +537,9 @@
         return;
 
     m_underTest = underTest;
+    m_connectionIdentifier = connectionIdentifier;
 
-    m_inspectorPage->process().send(Messages::WebInspectorUI::EstablishConnection(connectionIdentifier, m_page->pageID(), m_underTest), m_inspectorPage->pageID());
+    m_inspectorPage->process().send(Messages::WebInspectorUI::EstablishConnection(m_connectionIdentifier, m_page->pageID(), m_underTest), m_inspectorPage->pageID());
 
     if (!m_underTest) {
         m_canAttach = canAttach;
@@ -581,6 +593,7 @@
     m_isAttached = false;
     m_canAttach = false;
     m_underTest = false;
+    m_connectionIdentifier = IPC::Attachment();
 
     platformDidClose();
 }

Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h (177609 => 177610)


--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h	2014-12-20 00:52:35 UTC (rev 177609)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h	2014-12-20 00:57:55 UTC (rev 177610)
@@ -94,6 +94,8 @@
     void show();
     void hide();
     void close();
+
+    void didRelaunchInspectorPageProcess();
     
 #if PLATFORM(MAC)
     void createInspectorWindow();
@@ -224,6 +226,8 @@
     // all the inspectors in the same group will make it impossible to debug
     // the inspector code, so we use the level to make different page groups.
     unsigned m_level;
+    
+    IPC::Attachment m_connectionIdentifier;
 
     AttachmentSide m_attachmentSide;
 

Modified: trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm (177609 => 177610)


--- trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm	2014-12-20 00:52:35 UTC (rev 177609)
+++ trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm	2014-12-20 00:57:55 UTC (rev 177610)
@@ -35,7 +35,7 @@
 #import "WKOpenPanelResultListener.h"
 #import "WKRetainPtr.h"
 #import "WKURLCF.h"
-#import "WKViewPrivate.h"
+#import "WKViewInternal.h"
 #import "WebContext.h"
 #import "WebInspectorMessages.h"
 #import "WebInspectorUIMessages.h"
@@ -86,6 +86,7 @@
 
 - (id)initWithWebInspectorProxy:(WebInspectorProxy*)inspectorProxy;
 - (void)close;
+- (void)didRelaunchProcess;
 
 @end
 
@@ -123,6 +124,11 @@
     _inspectorProxy = nullptr;
 }
 
+- (void)didRelaunchProcess
+{
+    static_cast<WebInspectorProxy*>(_inspectorProxy)->didRelaunchInspectorPageProcess();
+}
+
 - (void)windowDidMove:(NSNotification *)notification
 {
     static_cast<WebInspectorProxy*>(_inspectorProxy)->windowFrameDidChange();
@@ -165,6 +171,7 @@
 @end
 
 @interface WKWebInspectorWKView : WKView
+@property (nonatomic, assign) WKWebInspectorProxyObjCAdapter *inspectorProxyObjCAdapter;
 @end
 
 @implementation WKWebInspectorWKView
@@ -174,6 +181,13 @@
     return WKInspectorViewTag;
 }
 
+- (void)_didRelaunchProcess
+{
+    [super _didRelaunchProcess];
+
+    [self.inspectorProxyObjCAdapter didRelaunchProcess];
+}
+
 @end
 
 @interface NSView (AppKitDetails)
@@ -294,6 +308,7 @@
     if (m_inspectorView) {
         WebPageProxy* inspectorPage = toImpl(m_inspectorView.get().pageRef);
         inspectorPage->close();
+        [m_inspectorView setInspectorProxyObjCAdapter:nil];
         m_inspectorView = nil;
     }
 
@@ -469,6 +484,8 @@
     m_inspectorProxyObjCAdapter = adoptNS([[WKWebInspectorProxyObjCAdapter alloc] initWithWebInspectorProxy:this]);
     ASSERT(m_inspectorProxyObjCAdapter);
 
+    [m_inspectorView setInspectorProxyObjCAdapter:m_inspectorProxyObjCAdapter.get()];
+
     WebPageProxy* inspectorPage = toImpl(m_inspectorView.get().pageRef);
     ASSERT(inspectorPage);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to