Title: [238660] trunk/Source
Revision
238660
Author
joep...@webkit.org
Date
2018-11-28 20:39:45 -0800 (Wed, 28 Nov 2018)

Log Message

Web Inspector: REGRESSION(?): all "Show *" develop menu items cause the page to crash
https://bugs.webkit.org/show_bug.cgi?id=192016
<rdar://problem/46284417>

Reviewed by Devin Rousso.

Source/WebInspectorUI:

* UserInterface/Base/Main.js:
(WI.loaded):
(WI.initializeBackendTarget):
(WI.contentLoaded):
(WI.whenTargetsAvailable):
Don't evaluate any InspectorFrontendAPI commands until the frontend
has initialized a main target and the user interface.

Source/WebKit:

Previously calling the Page's inspectorController.show()
would create a frontend connection on the WebProcess side.
However now the frontend connection is handed to the WebProcess
once the UIProcess creates it. So queue actions that take place
immediately after showing the inspector until we have a frontend
to send the actions to.

* WebProcess/WebPage/WebInspector.h:
* WebProcess/WebPage/WebInspector.cpp:
(WebKit::WebInspector::setFrontendConnection):
(WebKit::WebInspector::closeFrontendConnection):
(WebKit::WebInspector::whenFrontendConnectionEstablished):
(WebKit::WebInspector::showConsole):
(WebKit::WebInspector::showResources):
(WebKit::WebInspector::showTimelines):
(WebKit::WebInspector::showMainResourceForFrame):
(WebKit::WebInspector::startPageProfiling):
(WebKit::WebInspector::stopPageProfiling):
(WebKit::WebInspector::startElementSelection):
(WebKit::WebInspector::stopElementSelection):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (238659 => 238660)


--- trunk/Source/WebInspectorUI/ChangeLog	2018-11-29 04:14:02 UTC (rev 238659)
+++ trunk/Source/WebInspectorUI/ChangeLog	2018-11-29 04:39:45 UTC (rev 238660)
@@ -1,3 +1,19 @@
+2018-11-28  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: REGRESSION(?): all "Show *" develop menu items cause the page to crash
+        https://bugs.webkit.org/show_bug.cgi?id=192016
+        <rdar://problem/46284417>
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Base/Main.js:
+        (WI.loaded):
+        (WI.initializeBackendTarget):
+        (WI.contentLoaded):
+        (WI.whenTargetsAvailable):
+        Don't evaluate any InspectorFrontendAPI commands until the frontend
+        has initialized a main target and the user interface.
+
 2018-11-28  Nikita Vasilyev  <nvasil...@apple.com>
 
         Web Inspector: Styles: enable selection of multiple properties by default

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (238659 => 238660)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2018-11-29 04:14:02 UTC (rev 238659)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2018-11-29 04:39:45 UTC (rev 238660)
@@ -157,6 +157,7 @@
     this.modifierKeys = {altKey: false, metaKey: false, shiftKey: false};
     this.visible = false;
     this._windowKeydownListeners = [];
+    this._targetsAvailablePromise = new WI.WrappedPromise;
 
     // Targets.
     WI.backendTarget = null;
@@ -181,6 +182,8 @@
     WI.backendTarget = target;
 
     WI.resetMainExecutionContext();
+
+    this._targetsAvailablePromise.resolve();
 };
 
 WI.initializePageTarget = function(target)
@@ -551,7 +554,9 @@
     this.tabBar.addEventListener(WI.TabBar.Event.TabBarItemsReordered, this._rememberOpenTabs, this);
 
     // Signal that the frontend is now ready to receive messages.
-    InspectorFrontendAPI.loadCompleted();
+    WI.whenTargetsAvailable().then(() => {
+        InspectorFrontendAPI.loadCompleted();
+    });
 
     // Tell the InspectorFrontendHost we loaded, which causes the window to display
     // and pending InspectorFrontendAPI commands to be sent.
@@ -580,6 +585,11 @@
     }
 };
 
+WI.whenTargetsAvailable = function()
+{
+    return this._targetsAvailablePromise.promise;
+};
+
 WI.isTabTypeAllowed = function(tabType)
 {
     let tabClass = this._knownTabClassesByType.get(tabType);

Modified: trunk/Source/WebKit/ChangeLog (238659 => 238660)


--- trunk/Source/WebKit/ChangeLog	2018-11-29 04:14:02 UTC (rev 238659)
+++ trunk/Source/WebKit/ChangeLog	2018-11-29 04:39:45 UTC (rev 238660)
@@ -1,3 +1,32 @@
+2018-11-28  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: REGRESSION(?): all "Show *" develop menu items cause the page to crash
+        https://bugs.webkit.org/show_bug.cgi?id=192016
+        <rdar://problem/46284417>
+
+        Reviewed by Devin Rousso.
+
+        Previously calling the Page's inspectorController.show()
+        would create a frontend connection on the WebProcess side.
+        However now the frontend connection is handed to the WebProcess
+        once the UIProcess creates it. So queue actions that take place
+        immediately after showing the inspector until we have a frontend
+        to send the actions to.
+
+        * WebProcess/WebPage/WebInspector.h:
+        * WebProcess/WebPage/WebInspector.cpp:
+        (WebKit::WebInspector::setFrontendConnection):
+        (WebKit::WebInspector::closeFrontendConnection):
+        (WebKit::WebInspector::whenFrontendConnectionEstablished):
+        (WebKit::WebInspector::showConsole):
+        (WebKit::WebInspector::showResources):
+        (WebKit::WebInspector::showTimelines):
+        (WebKit::WebInspector::showMainResourceForFrame):
+        (WebKit::WebInspector::startPageProfiling):
+        (WebKit::WebInspector::stopPageProfiling):
+        (WebKit::WebInspector::startElementSelection):
+        (WebKit::WebInspector::stopElementSelection):
+
 2018-11-28  Vivek Seth  <v_s...@apple.com>
 
         Consult dummy storage for HTTPS Upgrade, Apply If Appropriate

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp (238659 => 238660)


--- trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp	2018-11-29 04:14:02 UTC (rev 238659)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp	2018-11-29 04:39:45 UTC (rev 238660)
@@ -100,6 +100,10 @@
 
     m_frontendConnection = IPC::Connection::createClientConnection(connectionIdentifier, *this);
     m_frontendConnection->open();
+
+    for (auto& callback : m_frontendConnectionActions)
+        callback();
+    m_frontendConnectionActions.clear();
 }
 
 void WebInspector::closeFrontendConnection()
@@ -112,6 +116,8 @@
         m_frontendConnection = nullptr;
     }
 
+    m_frontendConnectionActions.clear();
+
     m_attached = false;
     m_previousCanAttach = false;
 }
@@ -121,6 +127,16 @@
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::BringToFront(), m_page->pageID());
 }
 
+void WebInspector::whenFrontendConnectionEstablished(Function<void()>&& callback)
+{
+    if (m_frontendConnection) {
+        callback();
+        return;
+    }
+
+    m_frontendConnectionActions.append(WTFMove(callback));
+}
+
 // Called by WebInspector messages
 void WebInspector::show()
 {
@@ -175,7 +191,10 @@
         return;
 
     m_page->corePage()->inspectorController().show();
-    m_frontendConnection->send(Messages::WebInspectorUI::ShowConsole(), 0);
+
+    whenFrontendConnectionEstablished([=] {
+        m_frontendConnection->send(Messages::WebInspectorUI::ShowConsole(), 0);
+    });
 }
 
 void WebInspector::showResources()
@@ -184,7 +203,10 @@
         return;
 
     m_page->corePage()->inspectorController().show();
-    m_frontendConnection->send(Messages::WebInspectorUI::ShowResources(), 0);
+
+    whenFrontendConnectionEstablished([=] {
+        m_frontendConnection->send(Messages::WebInspectorUI::ShowResources(), 0);
+    });
 }
 
 void WebInspector::showTimelines()
@@ -193,7 +215,10 @@
         return;
 
     m_page->corePage()->inspectorController().show();
-    m_frontendConnection->send(Messages::WebInspectorUI::ShowTimelines(), 0);
+
+    whenFrontendConnectionEstablished([=] {
+        m_frontendConnection->send(Messages::WebInspectorUI::ShowTimelines(), 0);
+    });
 }
 
 void WebInspector::showMainResourceForFrame(uint64_t frameIdentifier)
@@ -208,7 +233,10 @@
     m_page->corePage()->inspectorController().show();
 
     String inspectorFrameIdentifier = m_page->corePage()->inspectorController().pageAgent()->frameId(frame->coreFrame());
-    m_frontendConnection->send(Messages::WebInspectorUI::ShowMainResourceForFrame(inspectorFrameIdentifier), 0);
+
+    whenFrontendConnectionEstablished([=] {
+        m_frontendConnection->send(Messages::WebInspectorUI::ShowMainResourceForFrame(inspectorFrameIdentifier), 0);
+    });
 }
 
 void WebInspector::startPageProfiling()
@@ -216,7 +244,9 @@
     if (!m_page->corePage())
         return;
 
-    m_frontendConnection->send(Messages::WebInspectorUI::StartPageProfiling(), 0);
+    whenFrontendConnectionEstablished([=] {
+        m_frontendConnection->send(Messages::WebInspectorUI::StartPageProfiling(), 0);
+    });
 }
 
 void WebInspector::stopPageProfiling()
@@ -224,7 +254,9 @@
     if (!m_page->corePage())
         return;
 
-    m_frontendConnection->send(Messages::WebInspectorUI::StopPageProfiling(), 0);
+    whenFrontendConnectionEstablished([=] {
+        m_frontendConnection->send(Messages::WebInspectorUI::StopPageProfiling(), 0);
+    });
 }
 
 void WebInspector::startElementSelection()
@@ -232,7 +264,9 @@
     if (!m_page->corePage())
         return;
 
-    m_frontendConnection->send(Messages::WebInspectorUI::StartElementSelection(), 0);
+    whenFrontendConnectionEstablished([=] {
+        m_frontendConnection->send(Messages::WebInspectorUI::StartElementSelection(), 0);
+    });
 }
 
 void WebInspector::stopElementSelection()
@@ -240,7 +274,9 @@
     if (!m_page->corePage())
         return;
 
-    m_frontendConnection->send(Messages::WebInspectorUI::StopElementSelection(), 0);
+    whenFrontendConnectionEstablished([=] {
+        m_frontendConnection->send(Messages::WebInspectorUI::StopElementSelection(), 0);
+    });
 }
 
 void WebInspector::elementSelectionChanged(bool active)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebInspector.h (238659 => 238660)


--- trunk/Source/WebKit/WebProcess/WebPage/WebInspector.h	2018-11-29 04:14:02 UTC (rev 238659)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebInspector.h	2018-11-29 04:39:45 UTC (rev 238660)
@@ -92,9 +92,12 @@
 
     void bringToFront();
 
+    void whenFrontendConnectionEstablished(Function<void()>&&);
+
     WebPage* m_page;
 
     RefPtr<IPC::Connection> m_frontendConnection;
+    Vector<Function<void()>> m_frontendConnectionActions;
 
     bool m_attached { false };
     bool m_previousCanAttach { false };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to