Changeset 248286 in webkit
- Timestamp:
- Aug 5, 2019 7:21:59 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r248285 r248286 1 2019-08-05 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Timelines: disable related agents when the tab is closed 4 https://bugs.webkit.org/show_bug.cgi?id=200118 5 6 Reviewed by Joseph Pecoraro. 7 8 * inspector/timeline/line-column.html: 9 * inspector/timeline/setInstruments-errors.html: 10 * inspector/timeline/setInstruments-programmatic-capture.html: 11 1 12 2019-08-05 Fujii Hironori <Hironori.Fujii@sony.com> 2 13 -
trunk/LayoutTests/inspector/timeline/line-column.html
r244195 r248286 34 34 } 35 35 36 function test() { 37 ProtocolTest.debug(); 36 function test() 37 { 38 let suite = ProtocolTest.createAsyncSuite("Timeline.LineColumn"); 38 39 39 40 InspectorProtocol.sendCommand("Page.enable"); 40 41 let suite = ProtocolTest.createAsyncSuite("Timeline.LineColumn"); 41 InspectorProtocol.sendCommand("Timeline.enable"); 42 42 43 43 function replacer(key, value) { -
trunk/LayoutTests/inspector/timeline/setInstruments-errors.html
r210062 r248286 7 7 { 8 8 let suite = ProtocolTest.createAsyncSuite("Timeline.setInstruments.errors"); 9 10 InspectorProtocol.sendCommand("Heap.enable"); 11 InspectorProtocol.sendCommand("Memory.enable"); 12 InspectorProtocol.sendCommand("Timeline.enable"); 9 13 10 14 suite.addTestCase({ -
trunk/LayoutTests/inspector/timeline/setInstruments-programmatic-capture.html
r244195 r248286 18 18 19 19 InspectorProtocol.sendCommand("Heap.enable"); 20 InspectorProtocol.sendCommand("Timeline.enable"); 20 21 21 22 InspectorProtocol.eventHandler["Timeline.recordingStarted"] = () => { -
trunk/Source/JavaScriptCore/ChangeLog
r248274 r248286 1 2019-08-05 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Timelines: disable related agents when the tab is closed 4 https://bugs.webkit.org/show_bug.cgi?id=200118 5 6 Reviewed by Joseph Pecoraro. 7 8 Rework how `enable`/`disable` is used for timeline-related agents so that events are not sent 9 and data isn't kept alive when the Timelines tab isn't enabled. 10 11 * inspector/protocol/Timeline.json: 12 Add `enable`/`disable` commands. 13 14 * inspector/agents/InspectorHeapAgent.cpp: 15 (Inspector::InspectorHeapAgent::willDestroyFrontendAndBackend): 16 (Inspector::InspectorHeapAgent::enable): 17 (Inspector::InspectorHeapAgent::disable): 18 1 19 2019-08-05 Devin Rousso <drousso@apple.com> 2 20 -
trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp
r243150 r248286 55 55 void InspectorHeapAgent::willDestroyFrontendAndBackend(DisconnectReason) 56 56 { 57 // Stop tracking without taking a snapshot.58 m_tracking = false;59 60 57 ErrorString ignored; 61 58 disable(ignored); 62 59 } 63 60 64 void InspectorHeapAgent::enable(ErrorString&) 65 { 66 if (m_enabled) 67 return; 61 void InspectorHeapAgent::enable(ErrorString& errorString) 62 { 63 if (m_enabled) { 64 errorString = "HeapAgent already enabled"_s; 65 return; 66 } 68 67 69 68 m_enabled = true; … … 72 71 } 73 72 74 void InspectorHeapAgent::disable(ErrorString&) 75 { 76 if (!m_enabled) 77 return; 73 void InspectorHeapAgent::disable(ErrorString& errorString) 74 { 75 if (!m_enabled) { 76 errorString = "HeapAgent already disabled"_s; 77 return; 78 } 78 79 79 80 m_enabled = false; 81 m_tracking = false; 80 82 81 83 m_environment.vm().heap.removeObserver(this); -
trunk/Source/JavaScriptCore/inspector/protocol/Timeline.json
r244195 r248286 58 58 "commands": [ 59 59 { 60 "name": "enable", 61 "description": "Enables Timeline domain events." 62 }, 63 { 64 "name": "disable", 65 "description": "Disables Timeline domain events." 66 }, 67 { 60 68 "name": "start", 61 69 "description": "Starts capturing instrumentation events.", -
trunk/Source/WebCore/ChangeLog
r248285 r248286 1 2019-08-05 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Timelines: disable related agents when the tab is closed 4 https://bugs.webkit.org/show_bug.cgi?id=200118 5 6 Reviewed by Joseph Pecoraro. 7 8 Rework how `enable`/`disable` is used for timeline-related agents so that events are not sent 9 and data isn't kept alive when the Timelines tab isn't enabled. 10 11 * inspector/agents/InspectorTimelineAgent.h: 12 * inspector/agents/InspectorTimelineAgent.cpp: 13 (WebCore::InspectorTimelineAgent::didCreateFrontendAndBackend): 14 (WebCore::InspectorTimelineAgent::willDestroyFrontendAndBackend): 15 (WebCore::InspectorTimelineAgent::enable): 16 (WebCore::InspectorTimelineAgent::disable): 17 (WebCore::InspectorTimelineAgent::start): 18 (WebCore::InspectorTimelineAgent::stop): 19 (WebCore::InspectorTimelineAgent::internalStart): 20 (WebCore::InspectorTimelineAgent::internalStop): 21 (WebCore::InspectorTimelineAgent::startFromConsole): 22 (WebCore::InspectorTimelineAgent::stopFromConsole): 23 (WebCore::InspectorTimelineAgent::mainFrameStartedLoading): 24 (WebCore::InspectorTimelineAgent::startProgrammaticCapture): 25 (WebCore::InspectorTimelineAgent::stopProgrammaticCapture): 26 Rename `m_enabled*` to `m_tracking*` to match other timeline-related agents. 27 28 * inspector/agents/InspectorMemoryAgent.h: 29 * inspector/agents/InspectorMemoryAgent.cpp: 30 (WebCore::InspectorMemoryAgent::didCreateFrontendAndBackend): 31 (WebCore::InspectorMemoryAgent::willDestroyFrontendAndBackend): 32 (WebCore::InspectorMemoryAgent::enable): 33 (WebCore::InspectorMemoryAgent::disable): 34 (WebCore::InspectorMemoryAgent::didHandleMemoryPressure): 35 36 * inspector/InstrumentingAgents.h: 37 (WebCore::InstrumentingAgents::trackingInspectorTimelineAgent): Added. 38 (WebCore::InstrumentingAgents::setTrackingInspectorTimelineAgent): Added. 39 (WebCore::InstrumentingAgents::persistentInspectorTimelineAgent): Added. 40 (WebCore::InstrumentingAgents::setPersistentInspectorTimelineAgent): Added. 41 * inspector/InstrumentingAgents.cpp: 42 (WebCore::InstrumentingAgents::reset): 43 * inspector/InspectorInstrumentation.h: 44 * inspector/InspectorInstrumentation.cpp: 45 (WebCore::InspectorInstrumentation::didInstallTimerImpl): 46 (WebCore::InspectorInstrumentation::didRemoveTimerImpl): 47 (WebCore::InspectorInstrumentation::willCallFunctionImpl): 48 (WebCore::InspectorInstrumentation::willDispatchEventImpl): 49 (WebCore::InspectorInstrumentation::willDispatchEventOnWindowImpl): 50 (WebCore::InspectorInstrumentation::willEvaluateScriptImpl): 51 (WebCore::InspectorInstrumentation::willFireTimerImpl): 52 (WebCore::InspectorInstrumentation::didInvalidateLayoutImpl): 53 (WebCore::InspectorInstrumentation::willLayoutImpl): 54 (WebCore::InspectorInstrumentation::willCompositeImpl): 55 (WebCore::InspectorInstrumentation::didCompositeImpl): 56 (WebCore::InspectorInstrumentation::willPaintImpl): 57 (WebCore::InspectorInstrumentation::didPaintImpl): 58 (WebCore::InspectorInstrumentation::willRecalculateStyleImpl): 59 (WebCore::InspectorInstrumentation::didScheduleStyleRecalculationImpl): 60 (WebCore::InspectorInstrumentation::didCommitLoadImpl): 61 (WebCore::InspectorInstrumentation::frameStartedLoadingImpl): 62 (WebCore::InspectorInstrumentation::startConsoleTimingImpl): 63 (WebCore::InspectorInstrumentation::stopConsoleTimingImpl): 64 (WebCore::InspectorInstrumentation::consoleTimeStampImpl): 65 (WebCore::InspectorInstrumentation::startProfilingImpl): 66 (WebCore::InspectorInstrumentation::stopProfilingImpl): 67 (WebCore::InspectorInstrumentation::timelineAgentTracking): Added. 68 (WebCore::InspectorInstrumentation::didRequestAnimationFrameImpl): 69 (WebCore::InspectorInstrumentation::didCancelAnimationFrameImpl): 70 (WebCore::InspectorInstrumentation::willFireAnimationFrameImpl): 71 (WebCore::InspectorInstrumentation::willFireObserverCallbackImpl): 72 (WebCore::InspectorInstrumentation::retrieveTimelineAgent): 73 (WebCore::InspectorInstrumentation::timelineAgentEnabled): Deleted. 74 * bindings/js/JSExecStateInstrumentation.h: 75 (WebCore::JSExecState::instrumentFunctionInternal): 76 Rename for clarity/correctness: 77 - `inspectorTimelineAgent` => `trackingInspectorTimelineAgent` 78 - `persistentInspectorTimelineAgent` => `inspectorTimelineAgent` 79 1 80 2019-08-05 Fujii Hironori <Hironori.Fujii@sony.com> 2 81 -
trunk/Source/WebCore/bindings/js/JSExecStateInstrumentation.h
r240323 r248286 36 36 inline InspectorInstrumentationCookie JSExecState::instrumentFunctionInternal(ScriptExecutionContext* context, Type callType, const DataType& callData) 37 37 { 38 if (!InspectorInstrumentation::timelineAgent Enabled(context))38 if (!InspectorInstrumentation::timelineAgentTracking(context)) 39 39 return InspectorInstrumentationCookie(); 40 40 String resourceName; -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r247278 r248286 317 317 debuggerAgent->didScheduleAsyncCall(context.execState(), InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId, singleShot); 318 318 319 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent())319 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 320 320 timelineAgent->didInstallTimer(timerId, timeout, singleShot, frameForScriptExecutionContext(context)); 321 321 } … … 325 325 if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent()) 326 326 debuggerAgent->didCancelAsyncCall(InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId); 327 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent())327 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 328 328 timelineAgent->didRemoveTimer(timerId, frameForScriptExecutionContext(context)); 329 329 } … … 379 379 { 380 380 int timelineAgentId = 0; 381 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent()) {381 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) { 382 382 timelineAgent->willCallFunction(scriptName, scriptLine, scriptColumn, frameForScriptExecutionContext(context)); 383 383 timelineAgentId = timelineAgent->id(); … … 395 395 { 396 396 int timelineAgentId = 0; 397 InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent();397 InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent(); 398 398 if (timelineAgent && hasEventListeners) { 399 399 timelineAgent->willDispatchEvent(event, document.frame()); … … 431 431 { 432 432 int timelineAgentId = 0; 433 InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent();433 InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent(); 434 434 if (timelineAgent && window.hasEventListeners(event.type())) { 435 435 timelineAgent->willDispatchEvent(event, window.frame()); … … 455 455 { 456 456 int timelineAgentId = 0; 457 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent()) {457 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) { 458 458 timelineAgent->willEvaluateScript(url, lineNumber, columnNumber, frame); 459 459 timelineAgentId = timelineAgent->id(); … … 477 477 478 478 int timelineAgentId = 0; 479 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent()) {479 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) { 480 480 timelineAgent->willFireTimer(timerId, frameForScriptExecutionContext(context)); 481 481 timelineAgentId = timelineAgent->id(); … … 494 494 void InspectorInstrumentation::didInvalidateLayoutImpl(InstrumentingAgents& instrumentingAgents, Frame& frame) 495 495 { 496 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent())496 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 497 497 timelineAgent->didInvalidateLayout(frame); 498 498 } … … 501 501 { 502 502 int timelineAgentId = 0; 503 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent()) {503 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) { 504 504 timelineAgent->willLayout(frame); 505 505 timelineAgentId = timelineAgent->id(); … … 519 519 void InspectorInstrumentation::willCompositeImpl(InstrumentingAgents& instrumentingAgents, Frame& frame) 520 520 { 521 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent())521 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 522 522 timelineAgent->willComposite(frame); 523 523 } … … 525 525 void InspectorInstrumentation::didCompositeImpl(InstrumentingAgents& instrumentingAgents) 526 526 { 527 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent())527 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 528 528 timelineAgent->didComposite(); 529 529 } … … 531 531 void InspectorInstrumentation::willPaintImpl(InstrumentingAgents& instrumentingAgents, RenderObject& renderer) 532 532 { 533 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent())533 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 534 534 timelineAgent->willPaint(renderer.frame()); 535 535 } … … 537 537 void InspectorInstrumentation::didPaintImpl(InstrumentingAgents& instrumentingAgents, RenderObject& renderer, const LayoutRect& rect) 538 538 { 539 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent())539 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 540 540 timelineAgent->didPaint(renderer, rect); 541 541 … … 547 547 { 548 548 int timelineAgentId = 0; 549 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent()) {549 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) { 550 550 timelineAgent->willRecalculateStyle(document.frame()); 551 551 timelineAgentId = timelineAgent->id(); … … 573 573 void InspectorInstrumentation::didScheduleStyleRecalculationImpl(InstrumentingAgents& instrumentingAgents, Document& document) 574 574 { 575 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent())575 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 576 576 timelineAgent->didScheduleStyleRecalculation(document.frame()); 577 577 if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent()) … … 755 755 756 756 if (frame.isMainFrame()) { 757 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent())757 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 758 758 timelineAgent->mainFrameNavigated(); 759 759 } … … 780 780 if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent()) 781 781 pageDebuggerAgent->mainFrameStartedLoading(); 782 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. persistentInspectorTimelineAgent())782 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent()) 783 783 timelineAgent->mainFrameStartedLoading(); 784 784 } … … 875 875 return; 876 876 877 if (auto* timelineAgent = instrumentingAgents. inspectorTimelineAgent())877 if (auto* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 878 878 timelineAgent->time(frame, label); 879 879 if (auto* consoleAgent = instrumentingAgents.webConsoleAgent()) … … 906 906 if (auto* consoleAgent = instrumentingAgents.webConsoleAgent()) 907 907 consoleAgent->stopTiming(exec, label); 908 if (auto* timelineAgent = instrumentingAgents. inspectorTimelineAgent())908 if (auto* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 909 909 timelineAgent->timeEnd(frame, label); 910 910 } … … 921 921 void InspectorInstrumentation::consoleTimeStampImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, Ref<ScriptArguments>&& arguments) 922 922 { 923 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent()) {923 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) { 924 924 String message; 925 925 arguments->getFirstArgumentAsString(message); … … 930 930 void InspectorInstrumentation::startProfilingImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* exec, const String& title) 931 931 { 932 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. persistentInspectorTimelineAgent())932 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent()) 933 933 timelineAgent->startFromConsole(exec, title); 934 934 } … … 936 936 void InspectorInstrumentation::stopProfilingImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* exec, const String& title) 937 937 { 938 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. persistentInspectorTimelineAgent())938 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent()) 939 939 timelineAgent->stopFromConsole(exec, title); 940 940 } … … 1113 1113 } 1114 1114 1115 bool InspectorInstrumentation::timelineAgent Enabled(ScriptExecutionContext* scriptExecutionContext)1115 bool InspectorInstrumentation::timelineAgentTracking(ScriptExecutionContext* scriptExecutionContext) 1116 1116 { 1117 1117 FAST_RETURN_IF_NO_FRONTENDS(false); 1118 1118 if (auto* instrumentingAgents = instrumentingAgentsForContext(scriptExecutionContext)) 1119 return instrumentingAgents-> inspectorTimelineAgent();1119 return instrumentingAgents->trackingInspectorTimelineAgent(); 1120 1120 return false; 1121 1121 } … … 1125 1125 if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent()) 1126 1126 pageDebuggerAgent->didRequestAnimationFrame(callbackId, document); 1127 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent())1127 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 1128 1128 timelineAgent->didRequestAnimationFrame(callbackId, document.frame()); 1129 1129 } … … 1133 1133 if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent()) 1134 1134 pageDebuggerAgent->didCancelAnimationFrame(callbackId); 1135 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent())1135 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) 1136 1136 timelineAgent->didCancelAnimationFrame(callbackId, document.frame()); 1137 1137 } … … 1146 1146 1147 1147 int timelineAgentId = 0; 1148 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent()) {1148 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) { 1149 1149 timelineAgent->willFireAnimationFrame(callbackId, document.frame()); 1150 1150 timelineAgentId = timelineAgent->id(); … … 1164 1164 { 1165 1165 int timelineAgentId = 0; 1166 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents. inspectorTimelineAgent()) {1166 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent()) { 1167 1167 timelineAgent->willFireObserverCallback(callbackType, frameForScriptExecutionContext(&context)); 1168 1168 timelineAgentId = timelineAgent->id(); … … 1202 1202 return nullptr; 1203 1203 1204 InspectorTimelineAgent* timelineAgent = cookie.instrumentingAgents()-> inspectorTimelineAgent();1204 InspectorTimelineAgent* timelineAgent = cookie.instrumentingAgents()->trackingInspectorTimelineAgent(); 1205 1205 if (timelineAgent && cookie.hasMatchingTimelineAgentId(timelineAgent->id())) 1206 1206 return timelineAgent; -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r247278 r248286 295 295 296 296 static bool consoleAgentEnabled(ScriptExecutionContext*); 297 static bool timelineAgent Enabled(ScriptExecutionContext*);297 static bool timelineAgentTracking(ScriptExecutionContext*); 298 298 299 299 static InstrumentingAgents* instrumentingAgentsForPage(Page*); -
trunk/Source/WebCore/inspector/InstrumentingAgents.cpp
r243119 r248286 56 56 m_inspectorScriptProfilerAgent = nullptr; 57 57 m_inspectorTimelineAgent = nullptr; 58 m_ persistentInspectorTimelineAgent = nullptr;58 m_trackingInspectorTimelineAgent = nullptr; 59 59 m_inspectorDOMStorageAgent = nullptr; 60 60 #if ENABLE(RESOURCE_USAGE) -
trunk/Source/WebCore/inspector/InstrumentingAgents.h
r243119 r248286 110 110 void setInspectorTimelineAgent(InspectorTimelineAgent* agent) { m_inspectorTimelineAgent = agent; } 111 111 112 InspectorTimelineAgent* persistentInspectorTimelineAgent() const { return m_persistentInspectorTimelineAgent; }113 void set PersistentInspectorTimelineAgent(InspectorTimelineAgent* agent) { m_persistentInspectorTimelineAgent = agent; }112 InspectorTimelineAgent* trackingInspectorTimelineAgent() const { return m_trackingInspectorTimelineAgent; } 113 void setTrackingInspectorTimelineAgent(InspectorTimelineAgent* agent) { m_trackingInspectorTimelineAgent = agent; } 114 114 115 115 InspectorDOMStorageAgent* inspectorDOMStorageAgent() const { return m_inspectorDOMStorageAgent; } … … 164 164 Inspector::InspectorScriptProfilerAgent* m_inspectorScriptProfilerAgent { nullptr }; 165 165 InspectorTimelineAgent* m_inspectorTimelineAgent { nullptr }; 166 InspectorTimelineAgent* m_ persistentInspectorTimelineAgent { nullptr };166 InspectorTimelineAgent* m_trackingInspectorTimelineAgent { nullptr }; 167 167 InspectorDOMStorageAgent* m_inspectorDOMStorageAgent { nullptr }; 168 168 #if ENABLE(RESOURCE_USAGE) -
trunk/Source/WebCore/inspector/agents/InspectorMemoryAgent.cpp
r244195 r248286 48 48 void InspectorMemoryAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) 49 49 { 50 m_instrumentingAgents.setInspectorMemoryAgent(this);51 50 } 52 51 53 52 void InspectorMemoryAgent::willDestroyFrontendAndBackend(DisconnectReason) 54 53 { 55 m_instrumentingAgents.setInspectorMemoryAgent(nullptr);56 57 54 ErrorString ignored; 58 stopTracking(ignored);59 55 disable(ignored); 60 56 } 61 57 62 void InspectorMemoryAgent::enable(ErrorString& )58 void InspectorMemoryAgent::enable(ErrorString& errorString) 63 59 { 64 m_enabled = true; 60 if (m_instrumentingAgents.inspectorMemoryAgent() == this) { 61 errorString = "MemoryAgent already enabled"_s; 62 return; 63 } 64 65 m_instrumentingAgents.setInspectorMemoryAgent(this); 65 66 } 66 67 67 void InspectorMemoryAgent::disable(ErrorString& )68 void InspectorMemoryAgent::disable(ErrorString& errorString) 68 69 { 69 m_enabled = false; 70 if (m_instrumentingAgents.inspectorMemoryAgent() != this) { 71 errorString = "MemoryAgent already disabled"_s; 72 return; 73 } 74 75 m_instrumentingAgents.setInspectorMemoryAgent(nullptr); 76 77 m_tracking = false; 78 79 ResourceUsageThread::removeObserver(this); 70 80 } 71 81 … … 98 108 void InspectorMemoryAgent::didHandleMemoryPressure(Critical critical) 99 109 { 100 if (!m_enabled)101 return;102 103 110 MemoryFrontendDispatcher::Severity severity = critical == Critical::Yes ? MemoryFrontendDispatcher::Severity::Critical : MemoryFrontendDispatcher::Severity::NonCritical; 104 111 m_frontendDispatcher->memoryPressure(m_environment.executionStopwatch()->elapsedTime().seconds(), severity); -
trunk/Source/WebCore/inspector/agents/InspectorMemoryAgent.h
r228218 r248286 62 62 std::unique_ptr<Inspector::MemoryFrontendDispatcher> m_frontendDispatcher; 63 63 RefPtr<Inspector::MemoryBackendDispatcher> m_backendDispatcher; 64 bool m_enabled { false };65 64 bool m_tracking { false }; 66 65 }; -
trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp
r248177 r248286 97 97 void InspectorTimelineAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) 98 98 { 99 m_instrumentingAgents.setPersistentInspectorTimelineAgent(this);100 99 } 101 100 102 101 void InspectorTimelineAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason) 103 102 { 104 m_instrumentingAgents.setPersistentInspectorTimelineAgent(nullptr); 103 } 104 105 void InspectorTimelineAgent::enable(ErrorString& errorString) 106 { 107 if (m_instrumentingAgents.inspectorTimelineAgent() == this) { 108 errorString = "TimelineAgent already enabled"_s; 109 return; 110 } 111 112 m_instrumentingAgents.setInspectorTimelineAgent(this); 113 } 114 115 void InspectorTimelineAgent::disable(ErrorString& errorString) 116 { 117 if (m_instrumentingAgents.inspectorTimelineAgent() != this) { 118 errorString = "TimelineAgent already disabled"_s; 119 return; 120 } 121 122 m_instrumentingAgents.setInspectorTimelineAgent(nullptr); 105 123 106 124 ErrorString unused; … … 113 131 void InspectorTimelineAgent::start(ErrorString&, const int* maxCallStackDepth) 114 132 { 115 m_ enabledFromFrontend = true;133 m_trackingFromFrontend = true; 116 134 117 135 internalStart(maxCallStackDepth); … … 122 140 internalStop(); 123 141 124 m_ enabledFromFrontend = false;142 m_trackingFromFrontend = false; 125 143 } 126 144 … … 156 174 void InspectorTimelineAgent::internalStart(const int* maxCallStackDepth) 157 175 { 158 if (m_ enabled)176 if (m_tracking) 159 177 return; 160 178 … … 164 182 m_maxCallStackDepth = 5; 165 183 166 m_instrumentingAgents.set InspectorTimelineAgent(this);184 m_instrumentingAgents.setTrackingInspectorTimelineAgent(this); 167 185 168 186 m_environment.scriptDebugServer().addListener(this); 169 187 170 m_ enabled= true;188 m_tracking = true; 171 189 172 190 // FIXME: Abstract away platform-specific code once https://bugs.webkit.org/show_bug.cgi?id=142748 is fixed. … … 174 192 #if PLATFORM(COCOA) 175 193 m_frameStartObserver = std::make_unique<RunLoopObserver>(static_cast<CFIndex>(RunLoopObserver::WellKnownRunLoopOrders::InspectorFrameBegin), [this]() { 176 if (!m_ enabled|| m_environment.scriptDebugServer().isPaused())194 if (!m_tracking || m_environment.scriptDebugServer().isPaused()) 177 195 return; 178 196 … … 183 201 184 202 m_frameStopObserver = std::make_unique<RunLoopObserver>(static_cast<CFIndex>(RunLoopObserver::WellKnownRunLoopOrders::InspectorFrameEnd), [this]() { 185 if (!m_ enabled|| m_environment.scriptDebugServer().isPaused())203 if (!m_tracking || m_environment.scriptDebugServer().isPaused()) 186 204 return; 187 205 … … 215 233 void InspectorTimelineAgent::internalStop() 216 234 { 217 if (!m_ enabled)218 return; 219 220 m_instrumentingAgents.set InspectorTimelineAgent(nullptr);235 if (!m_tracking) 236 return; 237 238 m_instrumentingAgents.setTrackingInspectorTimelineAgent(nullptr); 221 239 222 240 m_environment.scriptDebugServer().removeListener(this, true); … … 234 252 clearRecordStack(); 235 253 236 m_ enabled= false;254 m_tracking = false; 237 255 m_startedComposite = false; 238 256 m_autoCapturePhase = AutoCapturePhase::None; … … 267 285 } 268 286 269 if (!m_ enabled&& m_pendingConsoleProfileRecords.isEmpty())287 if (!m_tracking && m_pendingConsoleProfileRecords.isEmpty()) 270 288 startProgrammaticCapture(); 271 289 … … 286 304 m_pendingConsoleProfileRecords.remove(i); 287 305 288 if (!m_ enabledFromFrontend && m_pendingConsoleProfileRecords.isEmpty())306 if (!m_trackingFromFrontend && m_pendingConsoleProfileRecords.isEmpty()) 289 307 stopProgrammaticCapture(); 290 308 … … 440 458 void InspectorTimelineAgent::mainFrameStartedLoading() 441 459 { 442 if (m_ enabled)460 if (m_tracking) 443 461 return; 444 462 … … 474 492 void InspectorTimelineAgent::startProgrammaticCapture() 475 493 { 476 ASSERT(!m_ enabled);494 ASSERT(!m_tracking); 477 495 478 496 // Disable breakpoints during programmatic capture. … … 493 511 void InspectorTimelineAgent::stopProgrammaticCapture() 494 512 { 495 ASSERT(m_ enabled);496 ASSERT(!m_ enabledFromFrontend);513 ASSERT(m_tracking); 514 ASSERT(!m_trackingFromFrontend); 497 515 498 516 toggleInstruments(InstrumentState::Stop); -
trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.h
r248177 r248286 95 95 void willDestroyFrontendAndBackend(Inspector::DisconnectReason) final; 96 96 97 // TimelineBackendDispatcherHandler 98 void enable(ErrorString&) final; 99 void disable(ErrorString&) final; 97 100 void start(ErrorString&, const int* maxCallStackDepth = nullptr) final; 98 101 void stop(ErrorString&) final; … … 215 218 int m_maxCallStackDepth { 5 }; 216 219 217 bool m_ enabled{ false };218 bool m_ enabledFromFrontend { false };220 bool m_tracking { false }; 221 bool m_trackingFromFrontend { false }; 219 222 bool m_programmaticCaptureRestoreBreakpointActiveValue { false }; 220 223 -
trunk/Source/WebInspectorUI/ChangeLog
r248284 r248286 1 2019-08-05 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Timelines: disable related agents when the tab is closed 4 https://bugs.webkit.org/show_bug.cgi?id=200118 5 6 Reviewed by Joseph Pecoraro. 7 8 Rework how `enable`/`disable` is used for timeline-related agents so that events are not sent 9 and data isn't kept alive when the Timelines tab isn't enabled. 10 11 * UserInterface/Controllers/TimelineManager.js: 12 (WI.TimelineManager): 13 (WI.TimelineManager.prototype.get domains): Added. 14 (WI.TimelineManager.prototype.activateExtraDomain): Added. 15 (WI.TimelineManager.prototype.initializeTarget): 16 (WI.TimelineManager.prototype.reset): 17 (WI.TimelineManager.prototype.set autoCaptureOnPageLoad): 18 (WI.TimelineManager.prototype.enable): Added. 19 (WI.TimelineManager.prototype.disable): Added. 20 (WI.TimelineManager.prototype.startCapturing): 21 (WI.TimelineManager.prototype.stopCapturing): 22 (WI.TimelineManager.prototype.async processJSON): 23 (WI.TimelineManager.prototype.capturingStarted): 24 (WI.TimelineManager.prototype.capturingStopped): 25 (WI.TimelineManager.prototype.autoCaptureStarted): 26 (WI.TimelineManager.prototype.eventRecorded): 27 (WI.TimelineManager.prototype.pageDOMContentLoadedEventFired): 28 (WI.TimelineManager.prototype.pageLoadEventFired): 29 (WI.TimelineManager.prototype.cpuProfilerTrackingUpdated): 30 (WI.TimelineManager.prototype.memoryTrackingUpdated): 31 (WI.TimelineManager.prototype.heapTrackingStarted): 32 (WI.TimelineManager.prototype.heapTrackingCompleted): 33 (WI.TimelineManager.prototype.heapSnapshotAdded): 34 (WI.TimelineManager.prototype._loadNewRecording): 35 (WI.TimelineManager.prototype._legacyAttemptStartAutoCapturingForFrame): 36 (WI.TimelineManager.prototype._provisionalLoadStarted): 37 (WI.TimelineManager.prototype._mainResourceDidChange): 38 (WI.TimelineManager.prototype._resourceWasAdded): 39 (WI.TimelineManager.prototype._garbageCollected): 40 (WI.TimelineManager.prototype._memoryPressure): 41 (WI.TimelineManager.prototype.scriptProfilerTrackingUpdated): 42 (WI.TimelineManager.prototype.scriptProfilerTrackingCompleted): 43 (WI.TimelineManager.prototype._updateAutoCaptureInstruments): 44 (WI.TimelineManager.prototype._handleDOMNodeDidFireEvent): 45 (WI.TimelineManager.prototype._handleDOMNodePowerEfficientPlaybackStateChanged): 46 * UserInterface/Models/Instrument.js: 47 (WI.Instrument.startLegacyTimelineAgent): 48 (WI.Instrument.stopLegacyTimelineAgent): 49 50 * UserInterface/Controllers/HeapManager.js: 51 (WI.HeapManager): Added. 52 (WI.HeapManager.prototype.get domains): Added. 53 (WI.HeapManager.prototype.activateExtraDomain): Added. 54 (WI.HeapManager.prototype.initializeTarget): 55 (WI.HeapManager.prototype.enable): Added. 56 (WI.HeapManager.prototype.disable): Added. 57 (WI.HeapManager.prototype.snapshot): Added. 58 (WI.HeapManager.prototype.getPreview): Added. 59 (WI.HeapManager.prototype.getRemoteObject): Added. 60 (WI.HeapManager.prototype.garbageCollected): 61 62 * UserInterface/Controllers/MemoryManager.js: 63 (WI.MemoryManager): Added. 64 (WI.MemoryManager.prototype.get domains): Added. 65 (WI.MemoryManager.prototype.activateExtraDomain): Added. 66 (WI.MemoryManager.prototype.initializeTarget): 67 (WI.MemoryManager.prototype.enable): Added. 68 (WI.MemoryManager.prototype.disable): Added. 69 (WI.MemoryManager.prototype.memoryPressure): 70 71 * UserInterface/Views/TimelineTabContentView.js: 72 (WI.TimelineTabContentView): 73 (WI.TimelineTabContentView.prototype.closed): 74 75 * UserInterface/Models/HeapAllocationsInstrument.js: 76 (WI.HeapAllocationsInstrument): 77 (WI.HeapAllocationsInstrument.prototype._takeHeapSnapshot): 78 * UserInterface/Views/HeapAllocationsTimelineView.js: 79 (WI.HeapAllocationsTimelineView.prototype._takeHeapSnapshotClicked): 80 * UserInterface/Views/HeapSnapshotInstanceDataGridNode.js: 81 (WI.HeapSnapshotInstanceDataGridNode.logHeapSnapshotNode): 82 (WI.HeapSnapshotInstanceDataGridNode.prototype._populatePreview): 83 (WI.HeapSnapshotInstanceDataGridNode.prototype._mouseoverHandler.appendPathRow): 84 Go through the `HeapManager` for `HeapAgent` commands so it can better manage state. 85 86 * UserInterface/Test/Test.js: 87 (WI.contentLoaded): 88 1 89 2019-08-05 Nikita Vasilyev <nvasilyev@apple.com> 2 90 -
trunk/Source/WebInspectorUI/UserInterface/Controllers/HeapManager.js
r237652 r248286 24 24 */ 25 25 26 // FIXME: HeapManager lacks advanced multi-target support. (Instruments/Profilers per-target) 27 26 28 WI.HeapManager = class HeapManager extends WI.Object 27 29 { 30 constructor() 31 { 32 super(); 33 34 this._enabled = false; 35 } 36 37 // Agent 38 39 get domains() { return ["Heap"]; } 40 41 activateExtraDomain(domain) 42 { 43 console.assert(domain === "Heap"); 44 45 for (let target of WI.targets) 46 this.initializeTarget(target); 47 } 48 28 49 // Target 29 50 30 51 initializeTarget(target) 31 52 { 53 if (!this._enabled) 54 return; 55 32 56 if (target.HeapAgent) 33 57 target.HeapAgent.enable(); … … 36 60 // Public 37 61 62 enable() 63 { 64 if (this._enabled) 65 return; 66 67 this._enabled = true; 68 69 for (let target of WI.targets) 70 this.initializeTarget(target); 71 } 72 73 disable() 74 { 75 if (!this._enabled) 76 return; 77 78 for (let target of WI.targets) { 79 if (target.HeapAgent) 80 target.HeapAgent.disable(); 81 } 82 83 this._enabled = false; 84 } 85 86 snapshot(callback) 87 { 88 console.assert(this._enabled); 89 console.assert(window.HeapAgent); 90 HeapAgent.snapshot((error, timestamp, snapshotStringData) => { 91 if (error) 92 WI.reportInternalError(error); 93 callback(error, timestamp, snapshotStringData); 94 }); 95 } 96 97 getPreview(node, callback) 98 { 99 console.assert(this._enabled); 100 console.assert(window.HeapAgent); 101 console.assert(node instanceof WI.HeapSnapshotNodeProxy); 102 HeapAgent.getPreview(node.id, (error, string, functionDetails, preview) => { 103 if (error) 104 WI.reportInternalError(error); 105 callback(error, string, functionDetails, preview); 106 }); 107 } 108 109 getRemoteObject(node, objectGroup, callback) 110 { 111 console.assert(this._enabled); 112 console.assert(window.HeapAgent); 113 console.assert(node instanceof WI.HeapSnapshotNodeProxy); 114 HeapAgent.getRemoteObject(node.id, objectGroup, (error, result) => { 115 if (error) 116 WI.reportInternalError(error); 117 callback(error, result); 118 }); 119 } 120 121 // HeapObserver 122 38 123 garbageCollected(target, payload) 39 124 { 40 // Called from WI.HeapObserver. 125 if (!this._enabled) 126 return; 41 127 42 128 // FIXME: <https://webkit.org/b/167323> Web Inspector: Enable Memory profiling in Workers -
trunk/Source/WebInspectorUI/UserInterface/Controllers/MemoryManager.js
r237652 r248286 26 26 WI.MemoryManager = class MemoryManager extends WI.Object 27 27 { 28 constructor() 29 { 30 super(); 31 32 this._enabled = false; 33 } 34 35 // Agent 36 37 get domains() { return ["Memory"]; } 38 39 activateExtraDomain(domain) 40 { 41 console.assert(domain === "Memory"); 42 43 for (let target of WI.targets) 44 this.initializeTarget(target); 45 } 46 28 47 // Target 29 48 30 49 initializeTarget(target) 31 50 { 51 if (!this._enabled) 52 return; 53 32 54 if (target.MemoryAgent) 33 55 target.MemoryAgent.enable(); … … 36 58 // Public 37 59 60 enable() 61 { 62 if (this._enabled) 63 return; 64 65 this._enabled = true; 66 67 for (let target of WI.targets) 68 this.initializeTarget(target); 69 } 70 71 disable() 72 { 73 if (!this._enabled) 74 return; 75 76 for (let target of WI.targets) { 77 if (target.MemoryAgent) 78 target.MemoryAgent.disable(); 79 } 80 81 this._enabled = false; 82 } 83 84 // MemoryObserver 85 38 86 memoryPressure(timestamp, protocolSeverity) 39 87 { 40 // Called from WI.MemoryObserver. 88 if (!this._enabled) 89 return; 41 90 42 91 let memoryPressureEvent = WI.MemoryPressureEvent.fromPayload(timestamp, protocolSeverity); -
trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js
r247249 r248286 32 32 super(); 33 33 34 this._enabled = false; 35 34 36 WI.Frame.addEventListener(WI.Frame.Event.ProvisionalLoadStarted, this._provisionalLoadStarted, this); 35 37 WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this); … … 62 64 } 63 65 66 // Agent 67 68 get domains() { return ["Timeline"]; } 69 70 activateExtraDomain(domain) 71 { 72 console.assert(domain === "Timeline"); 73 74 for (let target of WI.targets) 75 this.initializeTarget(target); 76 } 77 64 78 // Target 65 79 66 80 initializeTarget(target) 67 81 { 82 if (!this._enabled) 83 return; 84 68 85 if (target.TimelineAgent) { 86 // COMPATIBILITY (iOS 13.1): Timeline.enable did not exist. 87 if (target.TimelineAgent.enable) 88 target.TimelineAgent.enable(); 89 69 90 this._updateAutoCaptureInstruments([target]); 70 91 … … 155 176 reset() 156 177 { 157 if (this. isCapturing())178 if (this._capturingState === TimelineManager.CapturingState.Starting || this._capturingState === TimelineManager.CapturingState.Active) 158 179 this.stopCapturing(); 159 180 … … 184 205 set autoCaptureOnPageLoad(autoCapture) 185 206 { 207 console.assert(this._enabled); 208 186 209 autoCapture = !!autoCapture; 187 210 … … 238 261 } 239 262 263 enable() 264 { 265 if (this._enabled) 266 return; 267 268 this._enabled = true; 269 270 this.reset(); 271 272 for (let target of WI.targets) 273 this.initializeTarget(target); 274 } 275 276 disable() 277 { 278 if (!this._enabled) 279 return; 280 281 this.reset(); 282 283 for (let target of WI.targets) { 284 // COMPATIBILITY (iOS 13.1): Timeline.disable did not exist. 285 if (target.TimelineAgent && target.TimelineAgent.disable) 286 target.TimelineAgent.disable(); 287 } 288 289 this._enabled = false; 290 } 291 240 292 startCapturing(shouldCreateRecording) 241 293 { 294 console.assert(this._enabled); 295 242 296 console.assert(this._capturingState === TimelineManager.CapturingState.Stopping || this._capturingState === TimelineManager.CapturingState.Inactive, "TimelineManager is already capturing."); 243 297 if (this._capturingState !== TimelineManager.CapturingState.Stopping && this._capturingState !== TimelineManager.CapturingState.Inactive) … … 255 309 stopCapturing() 256 310 { 311 console.assert(this._enabled); 312 257 313 console.assert(this._capturingState === TimelineManager.CapturingState.Starting || this._capturingState === TimelineManager.CapturingState.Active, "TimelineManager is not capturing."); 258 314 if (this._capturingState !== TimelineManager.CapturingState.Starting && this._capturingState !== TimelineManager.CapturingState.Active) … … 296 352 this.dispatchEventToListeners(WI.TimelineManager.Event.RecordingCreated, {recording: newRecording}); 297 353 298 if (this. isCapturing())354 if (this._capturingState === TimelineManager.CapturingState.Starting || this._capturingState === TimelineManager.CapturingState.Active) 299 355 this.stopCapturing(); 300 356 … … 324 380 } 325 381 326 // Protected 382 heapSnapshotAdded(timestamp, snapshot) 383 { 384 if (!this._enabled) 385 return; 386 387 this._addRecord(new WI.HeapAllocationsTimelineRecord(timestamp, snapshot)); 388 } 389 390 // TimelineObserver 327 391 328 392 capturingStarted(startTime) 329 393 { 330 // Called from WI.TimelineObserver.331 332 394 // The frontend didn't start capturing, so this was a programmatic start. 333 395 if (this._capturingState === TimelineManager.CapturingState.Inactive) { … … 375 437 capturingStopped(endTime) 376 438 { 377 // Called from WI.TimelineObserver.378 379 439 // The frontend didn't stop capturing, so this was a programmatic stop. 380 440 if (this._capturingState === TimelineManager.CapturingState.Active) { … … 418 478 autoCaptureStarted() 419 479 { 420 // Called from WI.TimelineObserver.480 console.assert(this._enabled); 421 481 422 482 let waitingForCapturingStartedEvent = this._capturingState === TimelineManager.CapturingState.Starting; 423 483 424 if (this. isCapturing())484 if (this._capturingState === TimelineManager.CapturingState.Starting || this._capturingState === TimelineManager.CapturingState.Active) 425 485 this.stopCapturing(); 426 486 … … 440 500 eventRecorded(recordPayload) 441 501 { 442 // Called from WI.TimelineObserver. 502 if (!this._enabled) 503 return; 443 504 444 505 console.assert(this.isCapturing()); … … 483 544 } 484 545 546 // PageObserver 547 485 548 pageDOMContentLoadedEventFired(timestamp) 486 549 { 487 // Called from WI.PageObserver. 550 if (!this._enabled) 551 return; 488 552 489 553 console.assert(this._activeRecording); … … 500 564 pageLoadEventFired(timestamp) 501 565 { 502 // Called from WI.PageObserver. 566 if (!this._enabled) 567 return; 503 568 504 569 console.assert(this._activeRecording); … … 515 580 } 516 581 582 // CPUProfilerObserver 583 517 584 cpuProfilerTrackingStarted(timestamp) 518 585 { 519 // Called from WI.CPUProfilerObserver.520 521 586 this.capturingStarted(timestamp); 522 587 } … … 524 589 cpuProfilerTrackingUpdated(event) 525 590 { 526 // Called from WI.CPUProfilerObserver. 591 if (!this._enabled) 592 return; 527 593 528 594 console.assert(this.isCapturing()); … … 535 601 cpuProfilerTrackingCompleted(timestamp) 536 602 { 537 // Called from WI.CPUProfilerObserver.538 539 603 this.capturingStopped(timestamp); 540 604 } 541 605 606 // MemoryObserver 607 542 608 memoryTrackingStarted(timestamp) 543 609 { 544 // Called from WI.MemoryObserver.545 546 610 this.capturingStarted(timestamp); 547 611 } … … 549 613 memoryTrackingUpdated(event) 550 614 { 551 // Called from WI.MemoryObserver. 615 if (!this._enabled) 616 return; 552 617 553 618 console.assert(this.isCapturing()); … … 560 625 memoryTrackingCompleted(timestamp) 561 626 { 562 // Called from WI.MemoryObserver.563 564 627 this.capturingStopped(timestamp); 565 628 } 566 629 630 // HeapObserver 631 567 632 heapTrackingStarted(timestamp, snapshot) 568 633 { 569 // Called from WI.HeapObserver.570 571 634 this.capturingStarted(timestamp); 572 635 573 this._addRecord(new WI.HeapAllocationsTimelineRecord(timestamp, snapshot)); 636 if (this._enabled) 637 this._addRecord(new WI.HeapAllocationsTimelineRecord(timestamp, snapshot)); 574 638 } 575 639 576 640 heapTrackingCompleted(timestamp, snapshot) 577 641 { 578 // Called from WI.HeapObserver. 579 580 this._addRecord(new WI.HeapAllocationsTimelineRecord(timestamp, snapshot)); 642 if (this._enabled) 643 this._addRecord(new WI.HeapAllocationsTimelineRecord(timestamp, snapshot)); 581 644 582 645 this.capturingStopped(); 583 }584 585 heapSnapshotAdded(timestamp, snapshot)586 {587 // Called from WI.HeapAllocationsInstrument.588 589 this._addRecord(new WI.HeapAllocationsTimelineRecord(timestamp, snapshot));590 646 } 591 647 … … 828 884 this.dispatchEventToListeners(WI.TimelineManager.Event.RecordingCreated, {recording: newRecording}); 829 885 830 if (this. isCapturing())886 if (this._capturingState === TimelineManager.CapturingState.Starting || this._capturingState === TimelineManager.CapturingState.Active) 831 887 this.stopCapturing(); 832 888 … … 918 974 this._isCapturingPageReload = oldMainResource !== null && oldMainResource.url === mainResource.url; 919 975 920 if (this. isCapturing())976 if (this._capturingState === TimelineManager.CapturingState.Starting || this._capturingState === TimelineManager.CapturingState.Active) 921 977 this.stopCapturing(); 922 978 … … 980 1036 _provisionalLoadStarted(event) 981 1037 { 1038 if (!this._enabled) 1039 return; 1040 982 1041 this._attemptAutoCapturingForFrame(event.target); 983 1042 } … … 985 1044 _mainResourceDidChange(event) 986 1045 { 1046 if (!this._enabled) 1047 return; 1048 987 1049 // Ignore resource events when there isn't a main frame yet. Those events are triggered by 988 1050 // loading the cached resources when the inspector opens, and they do not have timing information. … … 1017 1079 _resourceWasAdded(event) 1018 1080 { 1081 if (!this._enabled) 1082 return; 1083 1019 1084 // Ignore resource events when there isn't a main frame yet. Those events are triggered by 1020 1085 // loading the cached resources when the inspector opens, and they do not have timing information. … … 1027 1092 _garbageCollected(event) 1028 1093 { 1094 if (!this._enabled) 1095 return; 1096 1029 1097 let {collection} = event.data; 1030 1098 this._addRecord(new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.GarbageCollected, collection.startTime, collection.endTime, null, null, collection)); … … 1033 1101 _memoryPressure(event) 1034 1102 { 1103 if (!this._enabled) 1104 return; 1105 1035 1106 this._activeRecording.addMemoryPressureEvent(event.data.memoryPressureEvent); 1036 1107 } … … 1069 1140 scriptProfilerTrackingUpdated(event) 1070 1141 { 1142 if (!this._enabled) 1143 return; 1144 1071 1145 let {startTime, endTime, type} = event; 1072 1146 let scriptRecordType = this._scriptProfilerTypeToScriptTimelineRecordType(type); … … 1085 1159 scriptProfilerTrackingCompleted(timestamp, samples) 1086 1160 { 1087 console.assert(!this._webTimelineScriptRecordsExpectingScriptProfilerEvents || this._scriptProfilerRecords.length >= this._webTimelineScriptRecordsExpectingScriptProfilerEvents.length); 1088 1089 if (samples) { 1090 let {stackTraces} = samples; 1091 let topDownCallingContextTree = this._activeRecording.topDownCallingContextTree; 1092 1093 // Calculate a per-sample duration. 1094 let timestampIndex = 0; 1095 let timestampCount = stackTraces.length; 1096 let sampleDurations = new Array(timestampCount); 1097 let sampleDurationIndex = 0; 1098 const defaultDuration = 1 / 1000; // 1ms. 1099 for (let i = 0; i < this._scriptProfilerRecords.length; ++i) { 1100 let record = this._scriptProfilerRecords[i]; 1161 if (this._enabled) { 1162 console.assert(!this._webTimelineScriptRecordsExpectingScriptProfilerEvents || this._scriptProfilerRecords.length >= this._webTimelineScriptRecordsExpectingScriptProfilerEvents.length); 1163 1164 if (samples) { 1165 let {stackTraces} = samples; 1166 let topDownCallingContextTree = this._activeRecording.topDownCallingContextTree; 1167 1168 // Calculate a per-sample duration. 1169 let timestampIndex = 0; 1170 let timestampCount = stackTraces.length; 1171 let sampleDurations = new Array(timestampCount); 1172 let sampleDurationIndex = 0; 1173 const defaultDuration = 1 / 1000; // 1ms. 1174 for (let i = 0; i < this._scriptProfilerRecords.length; ++i) { 1175 let record = this._scriptProfilerRecords[i]; 1176 1177 // Use a default duration for timestamps recorded outside of ScriptProfiler events. 1178 while (timestampIndex < timestampCount && stackTraces[timestampIndex].timestamp < record.startTime) { 1179 sampleDurations[sampleDurationIndex++] = defaultDuration; 1180 timestampIndex++; 1181 } 1182 1183 // Average the duration per sample across all samples during the record. 1184 let samplesInRecord = 0; 1185 while (timestampIndex < timestampCount && stackTraces[timestampIndex].timestamp < record.endTime) { 1186 timestampIndex++; 1187 samplesInRecord++; 1188 } 1189 if (samplesInRecord) { 1190 let averageDuration = (record.endTime - record.startTime) / samplesInRecord; 1191 sampleDurations.fill(averageDuration, sampleDurationIndex, sampleDurationIndex + samplesInRecord); 1192 sampleDurationIndex += samplesInRecord; 1193 } 1194 } 1101 1195 1102 1196 // Use a default duration for timestamps recorded outside of ScriptProfiler events. 1103 while (timestampIndex < timestampCount && stackTraces[timestampIndex].timestamp < record.startTime) { 1104 sampleDurations[sampleDurationIndex++] = defaultDuration; 1105 timestampIndex++; 1106 } 1107 1108 // Average the duration per sample across all samples during the record. 1109 let samplesInRecord = 0; 1110 while (timestampIndex < timestampCount && stackTraces[timestampIndex].timestamp < record.endTime) { 1111 timestampIndex++; 1112 samplesInRecord++; 1113 } 1114 if (samplesInRecord) { 1115 let averageDuration = (record.endTime - record.startTime) / samplesInRecord; 1116 sampleDurations.fill(averageDuration, sampleDurationIndex, sampleDurationIndex + samplesInRecord); 1117 sampleDurationIndex += samplesInRecord; 1197 if (timestampIndex < timestampCount) 1198 sampleDurations.fill(defaultDuration, sampleDurationIndex); 1199 1200 this._activeRecording.initializeCallingContextTrees(stackTraces, sampleDurations); 1201 1202 // FIXME: This transformation should not be needed after introducing ProfileView. 1203 // Once we eliminate ProfileNodeTreeElements and ProfileNodeDataGridNodes. 1204 // <https://webkit.org/b/154973> Web Inspector: Timelines UI redesign: Remove TimelineSidebarPanel 1205 for (let i = 0; i < this._scriptProfilerRecords.length; ++i) { 1206 let record = this._scriptProfilerRecords[i]; 1207 record.profilePayload = topDownCallingContextTree.toCPUProfilePayload(record.startTime, record.endTime); 1118 1208 } 1119 1209 } 1120 1210 1121 // Use a default duration for timestamps recorded outside of ScriptProfiler events. 1122 if (timestampIndex < timestampCount) 1123 sampleDurations.fill(defaultDuration, sampleDurationIndex); 1124 1125 this._activeRecording.initializeCallingContextTrees(stackTraces, sampleDurations); 1126 1127 // FIXME: This transformation should not be needed after introducing ProfileView. 1128 // Once we eliminate ProfileNodeTreeElements and ProfileNodeDataGridNodes. 1129 // <https://webkit.org/b/154973> Web Inspector: Timelines UI redesign: Remove TimelineSidebarPanel 1130 for (let i = 0; i < this._scriptProfilerRecords.length; ++i) { 1131 let record = this._scriptProfilerRecords[i]; 1132 record.profilePayload = topDownCallingContextTree.toCPUProfilePayload(record.startTime, record.endTime); 1211 // Associate the ScriptProfiler created records with Web Timeline records. 1212 // Filter out the already added ScriptProfiler events which should not have been wrapped. 1213 if (WI.sharedApp.debuggableType !== WI.DebuggableType.JavaScript) { 1214 this._scriptProfilerRecords = this._scriptProfilerRecords.filter((x) => x.__scriptProfilerType === ScriptProfilerAgent.EventType.Other); 1215 this._mergeScriptProfileRecords(); 1133 1216 } 1134 } 1135 1136 // Associate the ScriptProfiler created records with Web Timeline records. 1137 // Filter out the already added ScriptProfiler events which should not have been wrapped. 1138 if (WI.sharedApp.debuggableType !== WI.DebuggableType.JavaScript) { 1139 this._scriptProfilerRecords = this._scriptProfilerRecords.filter((x) => x.__scriptProfilerType === ScriptProfilerAgent.EventType.Other); 1140 this._mergeScriptProfileRecords(); 1141 } 1142 1143 this._scriptProfilerRecords = null; 1144 1145 let timeline = this._activeRecording.timelineForRecordType(WI.TimelineRecord.Type.Script); 1146 timeline.refresh(); 1217 1218 this._scriptProfilerRecords = null; 1219 1220 let timeline = this._activeRecording.timelineForRecordType(WI.TimelineRecord.Type.Script); 1221 timeline.refresh(); 1222 } 1147 1223 1148 1224 this.capturingStopped(timestamp); … … 1207 1283 _updateAutoCaptureInstruments(targets) 1208 1284 { 1285 console.assert(this._enabled); 1286 1209 1287 let enabledTimelineTypes = this.enabledTimelineTypes; 1210 1288 … … 1245 1323 _handleDOMNodeDidFireEvent(event) 1246 1324 { 1325 if (!this._enabled) 1326 return; 1327 1247 1328 let {domEvent} = event.data; 1248 1329 … … 1255 1336 _handleDOMNodePowerEfficientPlaybackStateChanged(event) 1256 1337 { 1338 if (!this._enabled) 1339 return; 1340 1257 1341 let {timestamp, isPowerEfficient} = event.data; 1258 1342 -
trunk/Source/WebInspectorUI/UserInterface/Models/HeapAllocationsInstrument.js
r241219 r248286 76 76 _takeHeapSnapshot() 77 77 { 78 HeapAgent.snapshot(function(error, timestamp, snapshotStringData){78 WI.heapManager.snapshot((error, timestamp, snapshotStringData) => { 79 79 let workerProxy = WI.HeapSnapshotWorkerProxy.singleton(); 80 80 workerProxy.createSnapshot(snapshotStringData, ({objectId, snapshot: serializedSnapshot}) => { -
trunk/Source/WebInspectorUI/UserInterface/Models/Instrument.js
r240457 r248286 55 55 static startLegacyTimelineAgent(initiatedByBackend) 56 56 { 57 console.assert(WI.timelineManager._enabled); 57 58 console.assert(window.TimelineAgent, "Attempted to start legacy timeline agent without TimelineAgent."); 58 59 … … 70 71 static stopLegacyTimelineAgent(initiatedByBackend) 71 72 { 73 console.assert(WI.timelineManager._enabled); 74 console.assert(window.TimelineAgent, "Attempted to stop legacy timeline agent without TimelineAgent."); 75 72 76 if (!WI.Instrument._legacyTimelineAgentStarted) 73 77 return; -
trunk/Source/WebInspectorUI/UserInterface/Test/Test.js
r248179 r248286 135 135 WI.applicationCacheManager.enable(); 136 136 WI.canvasManager.enable(); 137 WI.databaseManager.enable(); 137 138 WI.domStorageManager.enable(); 138 WI. databaseManager.enable();139 WI.heapManager.enable(); 139 140 WI.indexedDBManager.enable(); 141 WI.memoryManager.enable(); 142 WI.timelineManager.enable(); 140 143 141 144 // Signal that the frontend is now ready to receive messages. -
trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.js
r248198 r248286 409 409 _takeHeapSnapshotClicked() 410 410 { 411 HeapAgent.snapshot((error, timestamp, snapshotStringData) => {411 WI.heapManager.snapshot((error, timestamp, snapshotStringData) => { 412 412 let workerProxy = WI.HeapSnapshotWorkerProxy.singleton(); 413 413 workerProxy.createSnapshot(snapshotStringData, ({objectId, snapshot: serializedSnapshot}) => { -
trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js
r244275 r248286 82 82 83 83 if (node.className === "string") { 84 HeapAgent.getPreview(node.id, function(error, string, functionDetails, objectPreviewPayload) {84 WI.heapManager.getPreview(node, function(error, string, functionDetails, objectPreviewPayload) { 85 85 let remoteObject = error ? WI.RemoteObject.fromPrimitiveValue(undefined) : WI.RemoteObject.fromPrimitiveValue(string); 86 86 WI.consoleLogViewController.appendImmediateExecutionWithResult(text, remoteObject, addSpecialUserLogClass, shouldRevealConsole); 87 87 }); 88 88 } else { 89 HeapAgent.getRemoteObject(node.id, WI.RuntimeManager.ConsoleObjectGroup, function(error, remoteObjectPayload) {89 WI.heapManager.getRemoteObject(node, WI.RuntimeManager.ConsoleObjectGroup, function(error, remoteObjectPayload) { 90 90 let remoteObject = error ? WI.RemoteObject.fromPrimitiveValue(undefined) : WI.RemoteObject.fromPayload(remoteObjectPayload, WI.assumingMainTarget()); 91 91 WI.consoleLogViewController.appendImmediateExecutionWithResult(text, remoteObject, addSpecialUserLogClass, shouldRevealConsole); … … 266 266 _populateWindowPreview(containerElement) 267 267 { 268 HeapAgent.getRemoteObject(this._node.id, (error, remoteObjectPayload) => { 268 const objectGroup = undefined; 269 WI.heapManager.getRemoteObject(this._node, objectGroup, (error, remoteObjectPayload) => { 269 270 if (error) { 270 271 this._populateError(containerElement); … … 292 293 _populatePreview(containerElement) 293 294 { 294 HeapAgent.getPreview(this._node.id, (error, string, functionDetails, objectPreviewPayload) => {295 WI.heapManager.getPreview(this._node, (error, string, functionDetails, objectPreviewPayload) => { 295 296 if (error) { 296 297 this._populateError(containerElement); … … 429 430 goToArrowPlaceHolderElement.style.display = "inline-block"; 430 431 goToArrowPlaceHolderElement.style.width = "10px"; 431 HeapAgent.getPreview(node.id, function(error, string, functionDetails, objectPreviewPayload) {432 WI.heapManager.getPreview(node, function(error, string, functionDetails, objectPreviewPayload) { 432 433 if (functionDetails) { 433 434 let location = functionDetails.location; -
trunk/Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js
r248198 r248286 92 92 // Explicitly update the path for the navigation bar to prevent it from showing up as blank. 93 93 this.contentBrowser.updateHierarchicalPathForCurrentContentView(); 94 95 WI.heapManager.enable(); 96 WI.memoryManager.enable(); 97 WI.timelineManager.enable(); 94 98 } 95 99 … … 328 332 closed() 329 333 { 330 super.closed(); 334 WI.timelineManager.disable(); 335 WI.memoryManager.disable(); 336 WI.heapManager.disable(); 331 337 332 338 if (WI.FPSInstrument.supported()) … … 335 341 WI.timelineManager.removeEventListener(null, null, this); 336 342 WI.notifications.removeEventListener(null, null, this); 343 344 super.closed(); 337 345 } 338 346
Note: See TracChangeset
for help on using the changeset viewer.