Web Inspector: Timelines: Develop > Start Timeline Recording doesn't work when focuse...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Aug 2019 20:39:21 +0000 (20:39 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Aug 2019 20:39:21 +0000 (20:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200125
<rdar://problem/53543008>

Reviewed by Brian Burg.

Always show the Timelines tab in Web Inspector whenever timeline recording starts/stops.
Notify the UIProcess whenever the timeline recording state changes.

Source/WebCore:

* inspector/InspectorClient.h:
(WebCore::InspectorClient::timelineRecordingChanged): Added.

* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
(WebCore::InspectorTimelineAgent::internalStart):
(WebCore::InspectorTimelineAgent::internalStop):

Source/WebInspectorUI:

* UserInterface/Protocol/InspectorFrontendAPI.js:
(InspectorFrontendAPI.setTimelineProfilingEnabled):

Source/WebKit:

* WebProcess/WebPage/WebInspector.messages.in:
* WebProcess/WebPage/WebInspector.h:
* WebProcess/WebPage/WebInspector.cpp:
(WebKit::WebInspector::startPageProfiling):
(WebKit::WebInspector::stopPageProfiling):
(WebKit::WebInspector::timelineRecordingChanged): Added.
(WebKit::WebInspector::showTimelines): Deleted.

* WebProcess/WebPage/WebInspectorUI.messages.in:
* WebProcess/WebPage/WebInspectorUI.h:
* WebProcess/WebPage/WebInspectorUI.cpp:
(WebKit::WebInspectorUI::showTimelines): Deleted.

* WebProcess/WebCoreSupport/WebInspectorClient.h:
* WebProcess/WebCoreSupport/WebInspectorClient.cpp:
(WebKit::WebInspectorClient::timelineRecordingChanged): Added.

* UIProcess/WebInspectorProxy.messages.in:
* UIProcess/WebInspectorProxy.h:
* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::togglePageProfiling):
(WebKit::WebInspectorProxy::timelineRecordingChanged): Added.
(WebKit::WebInspectorProxy::showTimelines): Deleted.

* UIProcess/API/C/WKInspector.cpp:
(WKInspectorTogglePageProfiling):

* UIProcess/API/Cocoa/_WKInspector.h:
* UIProcess/API/Cocoa/_WKInspector.mm:
(-[_WKInspector showTimelines]): Deleted.

* WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp:
(WKBundleInspectorSetPageProfilingEnabled):

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

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorClient.h
Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp
Source/WebCore/inspector/agents/InspectorTimelineAgent.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/C/WKInspector.cpp
Source/WebKit/UIProcess/API/Cocoa/_WKInspector.h
Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm
Source/WebKit/UIProcess/WebInspectorProxy.cpp
Source/WebKit/UIProcess/WebInspectorProxy.h
Source/WebKit/UIProcess/WebInspectorProxy.messages.in
Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.h
Source/WebKit/WebProcess/WebPage/WebInspector.cpp
Source/WebKit/WebProcess/WebPage/WebInspector.h
Source/WebKit/WebProcess/WebPage/WebInspector.messages.in
Source/WebKit/WebProcess/WebPage/WebInspectorUI.cpp
Source/WebKit/WebProcess/WebPage/WebInspectorUI.h
Source/WebKit/WebProcess/WebPage/WebInspectorUI.messages.in

index 2da9542..704a7d6 100644 (file)
@@ -1,3 +1,23 @@
+2019-08-02  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Timelines: Develop > Start Timeline Recording doesn't work when focused on a detached inspector window
+        https://bugs.webkit.org/show_bug.cgi?id=200125
+        <rdar://problem/53543008>
+
+        Reviewed by Brian Burg.
+
+        Always show the Timelines tab in Web Inspector whenever timeline recording starts/stops.
+        Notify the UIProcess whenever the timeline recording state changes.
+
+        * inspector/InspectorClient.h:
+        (WebCore::InspectorClient::timelineRecordingChanged): Added.
+
+        * inspector/agents/InspectorTimelineAgent.h:
+        * inspector/agents/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
+        (WebCore::InspectorTimelineAgent::internalStart):
+        (WebCore::InspectorTimelineAgent::internalStop):
+
 2019-08-02  Yury Semikhatsky  <yurys@chromium.org>
 
         Web Inspector: Crash when interacting with Template Content in Console
index acf9d57..29aac20 100644 (file)
@@ -62,6 +62,7 @@ public:
     virtual void showPaintRect(const FloatRect&) { }
     virtual void didSetSearchingForNode(bool) { }
     virtual void elementSelectionChanged(bool) { }
+    virtual void timelineRecordingChanged(bool) { }
 
     virtual void setMockCaptureDevicesEnabledOverride(Optional<bool>) { }
 
index 43a24ea..3d29e2c 100644 (file)
@@ -37,6 +37,7 @@
 #include "Event.h"
 #include "Frame.h"
 #include "InspectorCPUProfilerAgent.h"
+#include "InspectorClient.h"
 #include "InspectorMemoryAgent.h"
 #include "InspectorPageAgent.h"
 #include "InstrumentingAgents.h"
@@ -83,10 +84,11 @@ static CFRunLoopRef currentRunLoop()
 }
 #endif
 
-InspectorTimelineAgent::InspectorTimelineAgent(WebAgentContext& context)
+InspectorTimelineAgent::InspectorTimelineAgent(PageAgentContext& context)
     : InspectorAgentBase("Timeline"_s, context)
     , m_frontendDispatcher(std::make_unique<Inspector::TimelineFrontendDispatcher>(context.frontendRouter))
     , m_backendDispatcher(Inspector::TimelineBackendDispatcher::create(context.backendDispatcher, this))
+    , m_inspectedPage(context.inspectedPage)
 {
 }
 
@@ -205,6 +207,9 @@ void InspectorTimelineAgent::internalStart(const int* maxCallStackDepth)
 #endif
 
     m_frontendDispatcher->recordingStarted(timestamp());
+
+    if (auto* client = m_inspectedPage.inspectorController().inspectorClient())
+        client->timelineRecordingChanged(true);
 }
 
 void InspectorTimelineAgent::internalStop()
@@ -233,6 +238,9 @@ void InspectorTimelineAgent::internalStop()
     m_autoCapturePhase = AutoCapturePhase::None;
 
     m_frontendDispatcher->recordingStopped(timestamp());
+
+    if (auto* client = m_inspectedPage.inspectorController().inspectorClient())
+        client->timelineRecordingChanged(false);
 }
 
 double InspectorTimelineAgent::timestamp()
index aac38ff..f22cebb 100644 (file)
@@ -88,7 +88,7 @@ class InspectorTimelineAgent final
     WTF_MAKE_NONCOPYABLE(InspectorTimelineAgent);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    InspectorTimelineAgent(WebAgentContext&);
+    InspectorTimelineAgent(PageAgentContext&);
     virtual ~InspectorTimelineAgent();
 
     void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) final;
@@ -206,6 +206,7 @@ private:
 
     std::unique_ptr<Inspector::TimelineFrontendDispatcher> m_frontendDispatcher;
     RefPtr<Inspector::TimelineBackendDispatcher> m_backendDispatcher;
+    Page& m_inspectedPage;
 
     Vector<TimelineRecordEntry> m_recordStack;
     Vector<TimelineRecordEntry> m_pendingConsoleProfileRecords;
index 16d47bd..1785c7c 100644 (file)
@@ -1,5 +1,19 @@
 2019-08-02  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: Timelines: Develop > Start Timeline Recording doesn't work when focused on a detached inspector window
+        https://bugs.webkit.org/show_bug.cgi?id=200125
+        <rdar://problem/53543008>
+
+        Reviewed by Brian Burg.
+
+        Always show the Timelines tab in Web Inspector whenever timeline recording starts/stops.
+        Notify the UIProcess whenever the timeline recording state changes.
+
+        * UserInterface/Protocol/InspectorFrontendAPI.js:
+        (InspectorFrontendAPI.setTimelineProfilingEnabled):
+
+2019-08-02  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: "Inspector.initialized" happens before breakpoints are set
         https://bugs.webkit.org/show_bug.cgi?id=200364
 
index aeba887..8fdf8b4 100644 (file)
@@ -44,6 +44,8 @@ InspectorFrontendAPI = {
 
     setTimelineProfilingEnabled: function(enabled)
     {
+        WI.showTimelineTab();
+
         if (WI.timelineManager.isCapturing() === enabled)
             return;
 
@@ -106,6 +108,7 @@ InspectorFrontendAPI = {
 
     },
 
+    // COMPATIBILITY (iOS 13.1): merged into InspectorFrontendAPI.setTimelineProfilingEnabled.
     showTimelines: function()
     {
         WI.showTimelineTab();
index af872aa..e672a8b 100644 (file)
@@ -1,3 +1,48 @@
+2019-08-02  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Timelines: Develop > Start Timeline Recording doesn't work when focused on a detached inspector window
+        https://bugs.webkit.org/show_bug.cgi?id=200125
+        <rdar://problem/53543008>
+
+        Reviewed by Brian Burg.
+
+        Always show the Timelines tab in Web Inspector whenever timeline recording starts/stops.
+        Notify the UIProcess whenever the timeline recording state changes.
+
+        * WebProcess/WebPage/WebInspector.messages.in:
+        * WebProcess/WebPage/WebInspector.h:
+        * WebProcess/WebPage/WebInspector.cpp:
+        (WebKit::WebInspector::startPageProfiling):
+        (WebKit::WebInspector::stopPageProfiling):
+        (WebKit::WebInspector::timelineRecordingChanged): Added.
+        (WebKit::WebInspector::showTimelines): Deleted.
+
+        * WebProcess/WebPage/WebInspectorUI.messages.in:
+        * WebProcess/WebPage/WebInspectorUI.h:
+        * WebProcess/WebPage/WebInspectorUI.cpp:
+        (WebKit::WebInspectorUI::showTimelines): Deleted.
+
+        * WebProcess/WebCoreSupport/WebInspectorClient.h:
+        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
+        (WebKit::WebInspectorClient::timelineRecordingChanged): Added.
+
+        * UIProcess/WebInspectorProxy.messages.in:
+        * UIProcess/WebInspectorProxy.h:
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::togglePageProfiling):
+        (WebKit::WebInspectorProxy::timelineRecordingChanged): Added.
+        (WebKit::WebInspectorProxy::showTimelines): Deleted.
+
+        * UIProcess/API/C/WKInspector.cpp:
+        (WKInspectorTogglePageProfiling):
+
+        * UIProcess/API/Cocoa/_WKInspector.h:
+        * UIProcess/API/Cocoa/_WKInspector.mm:
+        (-[_WKInspector showTimelines]): Deleted.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp:
+        (WKBundleInspectorSetPageProfilingEnabled):
+
 2019-08-02  Jer Noble  <jer.noble@apple.com>
 
         [iPadOS] slides.google.com: Full Screen API warning is presented when swiping through slides
index cd29eb6..39327c5 100644 (file)
@@ -117,7 +117,6 @@ bool WKInspectorIsProfilingPage(WKInspectorRef inspectorRef)
 
 void WKInspectorTogglePageProfiling(WKInspectorRef inspectorRef)
 {
-    toImpl(inspectorRef)->showTimelines();
     toImpl(inspectorRef)->togglePageProfiling();
 }
 
index 2e4ca07..e35f7ac 100644 (file)
@@ -52,7 +52,6 @@ WK_CLASS_AVAILABLE(macos(10.14.4), ios(12.2))
 - (void)showMainResourceForFrame:(_WKFrameHandle *)frame;
 - (void)attach;
 - (void)detach;
-- (void)showTimelines;
 - (void)togglePageProfiling;
 - (void)toggleElementSelection;
 - (void)printErrorToConsole:(NSString *)error;
index 74b999d..c499b18 100644 (file)
     _inspector->detach();
 }
 
-- (void)showTimelines
-{
-    _inspector->showTimelines();
-}
-
 - (void)togglePageProfiling
 {
     _inspector->togglePageProfiling();
index 7a33e69..f93fa67 100644 (file)
@@ -242,16 +242,6 @@ void WebInspectorProxy::showResources()
     m_inspectedPage->process().send(Messages::WebInspector::ShowResources(), m_inspectedPage->pageID());
 }
 
-void WebInspectorProxy::showTimelines()
-{
-    if (!m_inspectedPage)
-        return;
-
-    createFrontendPage();
-
-    m_inspectedPage->process().send(Messages::WebInspector::ShowTimelines(), m_inspectedPage->pageID());
-}
-
 void WebInspectorProxy::showMainResourceForFrame(WebFrameProxy* frame)
 {
     if (!m_inspectedPage)
@@ -356,9 +346,6 @@ void WebInspectorProxy::togglePageProfiling()
         m_inspectedPage->process().send(Messages::WebInspector::StopPageProfiling(), m_inspectedPage->pageID());
     else
         m_inspectedPage->process().send(Messages::WebInspector::StartPageProfiling(), m_inspectedPage->pageID());
-
-    // FIXME: have the WebProcess notify us on state changes.
-    m_isProfilingPage = !m_isProfilingPage;
 }
 
 void WebInspectorProxy::toggleElementSelection()
@@ -593,6 +580,11 @@ void WebInspectorProxy::elementSelectionChanged(bool active)
         bringToFront();
 }
 
+void WebInspectorProxy::timelineRecordingChanged(bool active)
+{
+    m_isProfilingPage = active;
+}
+
 void WebInspectorProxy::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
 {
 #if ENABLE(MEDIA_STREAM)
index 4b31b6a..7e8f2f0 100644 (file)
@@ -133,7 +133,6 @@ public:
 
     void showConsole();
     void showResources();
-    void showTimelines();
     void showMainResourceForFrame(WebFrameProxy*);
 
     AttachmentSide attachmentSide() const { return m_attachmentSide; }
@@ -227,6 +226,7 @@ private:
     void inspectedURLChanged(const String&);
     void showCertificate(const WebCore::CertificateInfo&);
     void elementSelectionChanged(bool);
+    void timelineRecordingChanged(bool);
     void setMockCaptureDevicesEnabledOverride(Optional<bool>);
 
     void save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
index d9da795..a4ef0cc 100644 (file)
@@ -35,6 +35,7 @@ messages -> WebInspectorProxy {
     InspectedURLChanged(String urlString)
     ShowCertificate(WebCore::CertificateInfo certificateInfo)
     ElementSelectionChanged(bool active)
+    TimelineRecordingChanged(bool active)
     SetMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
 
     Save(String filename, String content, bool base64Encoded, bool forceSaveAs)
index fa94af9..3466751 100644 (file)
@@ -52,8 +52,6 @@ void WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspectorRef, W
 
 void WKBundleInspectorSetPageProfilingEnabled(WKBundleInspectorRef inspectorRef, bool enabled)
 {
-    WebKit::toImpl(inspectorRef)->showTimelines();
-
     if (enabled)
         WebKit::toImpl(inspectorRef)->startPageProfiling();
     else
index 3e20a7f..7cdaacd 100644 (file)
@@ -211,6 +211,12 @@ void WebInspectorClient::elementSelectionChanged(bool active)
         m_page->inspector()->elementSelectionChanged(active);
 }
 
+void WebInspectorClient::timelineRecordingChanged(bool active)
+{
+    if (m_page->inspector())
+        m_page->inspector()->timelineRecordingChanged(active);
+}
+
 void WebInspectorClient::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
 {
     if (m_page->inspector())
index 6ab8b20..f5ecc64 100644 (file)
@@ -67,6 +67,7 @@ private:
 #endif
 
     void elementSelectionChanged(bool) override;
+    void timelineRecordingChanged(bool) override;
 
     bool overridesShowPaintRects() const override { return true; }
     void showPaintRect(const WebCore::FloatRect&) override;
index c1e9c22..f28de56 100644 (file)
@@ -209,18 +209,6 @@ void WebInspector::showResources()
     });
 }
 
-void WebInspector::showTimelines()
-{
-    if (!m_page->corePage())
-        return;
-
-    m_page->corePage()->inspectorController().show();
-
-    whenFrontendConnectionEstablished([=] {
-        m_frontendConnection->send(Messages::WebInspectorUI::ShowTimelines(), 0);
-    });
-}
-
 void WebInspector::showMainResourceForFrame(uint64_t frameIdentifier)
 {
     WebFrame* frame = WebProcess::singleton().webFrame(frameIdentifier);
@@ -244,6 +232,8 @@ void WebInspector::startPageProfiling()
     if (!m_page->corePage())
         return;
 
+    m_page->corePage()->inspectorController().show();
+
     whenFrontendConnectionEstablished([=] {
         m_frontendConnection->send(Messages::WebInspectorUI::StartPageProfiling(), 0);
     });
@@ -254,6 +244,8 @@ void WebInspector::stopPageProfiling()
     if (!m_page->corePage())
         return;
 
+    m_page->corePage()->inspectorController().show();
+
     whenFrontendConnectionEstablished([=] {
         m_frontendConnection->send(Messages::WebInspectorUI::StopPageProfiling(), 0);
     });
@@ -284,6 +276,11 @@ void WebInspector::elementSelectionChanged(bool active)
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::ElementSelectionChanged(active), m_page->pageID());
 }
 
+void WebInspector::timelineRecordingChanged(bool active)
+{
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::TimelineRecordingChanged(active), m_page->pageID());
+}
+
 void WebInspector::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
 {
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::SetMockCaptureDevicesEnabledOverride(enabled), m_page->pageID());
index 89cb83b..489e41c 100644 (file)
@@ -59,7 +59,6 @@ public:
 
     void showConsole();
     void showResources();
-    void showTimelines();
 
     void showMainResourceForFrame(uint64_t frameIdentifier);
 
@@ -73,6 +72,7 @@ public:
     void startElementSelection();
     void stopElementSelection();
     void elementSelectionChanged(bool);
+    void timelineRecordingChanged(bool);
     void setMockCaptureDevicesEnabledOverride(Optional<bool>);
 
     void setFrontendConnection(IPC::Attachment);
index bd754c1..b6f3c01 100644 (file)
@@ -28,7 +28,6 @@ messages -> WebInspector {
 
     ShowConsole()
     ShowResources()
-    ShowTimelines()
 
     ShowMainResourceForFrame(uint64_t frameIdentifier)
 
index 6e242d9..efaa4a5 100644 (file)
@@ -297,11 +297,6 @@ void WebInspectorUI::showResources()
     m_frontendAPIDispatcher.dispatchCommand("showResources"_s);
 }
 
-void WebInspectorUI::showTimelines()
-{
-    m_frontendAPIDispatcher.dispatchCommand("showTimelines"_s);
-}
-
 void WebInspectorUI::showMainResourceForFrame(const String& frameIdentifier)
 {
     m_frontendAPIDispatcher.dispatchCommand("showMainResourceForFrame"_s, frameIdentifier);
index 8beb13f..a1fb4d8 100644 (file)
@@ -58,7 +58,6 @@ public:
 
     void showConsole();
     void showResources();
-    void showTimelines();
 
     void showMainResourceForFrame(const String& frameIdentifier);
 
index 43190aa..375a38e 100644 (file)
@@ -33,7 +33,6 @@ messages -> WebInspectorUI {
 
     ShowConsole()
     ShowResources()
-    ShowTimelines()
 
     ShowMainResourceForFrame(String frameIdentifier)