Changeset 244191 in webkit
- Timestamp:
- Apr 11, 2019 10:45:05 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r244185 r244191 1 2019-04-11 Truitt Savell <tsavell@apple.com> 2 3 Unreviewed, rolling out r244158. 4 5 Casued 8 inspector/timeline/ test failures. 6 7 Reverted changeset: 8 9 "Web Inspector: Timelines: can't reliably stop/start a 10 recording" 11 https://bugs.webkit.org/show_bug.cgi?id=196778 12 https://trac.webkit.org/changeset/244158 13 1 14 2019-04-10 Saam Barati <sbarati@apple.com> 2 15 -
trunk/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.cpp
r244158 r244191 122 122 ErrorString unused; 123 123 124 // FIXME: <https://webkit.org/b/158753> Generalize the concept of Instruments on the backend to work equally for JSContext and Web inspection 125 if (m_scriptProfilerAgent) 126 m_scriptProfilerAgent->programmaticCaptureStarted(); 127 124 128 if (m_debuggerAgent) { 125 129 m_profileRestoreBreakpointActiveValue = m_debuggerAgent->breakpointsActive(); … … 142 146 if (m_debuggerAgent) 143 147 m_debuggerAgent->setBreakpointsActive(unused, m_profileRestoreBreakpointActiveValue); 148 149 // FIXME: <https://webkit.org/b/158753> Generalize the concept of Instruments on the backend to work equally for JSContext and Web inspection 150 if (m_scriptProfilerAgent) 151 m_scriptProfilerAgent->programmaticCaptureStopped(); 144 152 } 145 153 -
trunk/Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.cpp
r244158 r244191 204 204 void InspectorScriptProfilerAgent::trackingComplete() 205 205 { 206 auto timestamp = m_environment.executionStopwatch()->elapsedTime().seconds();207 208 206 #if ENABLE(SAMPLING_PROFILER) 209 207 if (m_enabledSamplingProfiler) { … … 223 221 m_enabledSamplingProfiler = false; 224 222 225 m_frontendDispatcher->trackingComplete( timestamp,WTFMove(samples));223 m_frontendDispatcher->trackingComplete(WTFMove(samples)); 226 224 } else 227 m_frontendDispatcher->trackingComplete( timestamp,nullptr);225 m_frontendDispatcher->trackingComplete(nullptr); 228 226 #else 229 m_frontendDispatcher->trackingComplete( timestamp,nullptr);227 m_frontendDispatcher->trackingComplete(nullptr); 230 228 #endif // ENABLE(SAMPLING_PROFILER) 231 229 } … … 249 247 } 250 248 249 void InspectorScriptProfilerAgent::programmaticCaptureStarted() 250 { 251 m_frontendDispatcher->programmaticCaptureStarted(); 252 } 253 254 void InspectorScriptProfilerAgent::programmaticCaptureStopped() 255 { 256 m_frontendDispatcher->programmaticCaptureStopped(); 257 } 258 251 259 } // namespace Inspector -
trunk/Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.h
r244158 r244191 54 54 void stopTracking(ErrorString&) override; 55 55 56 void programmaticCaptureStarted(); 57 void programmaticCaptureStopped(); 58 56 59 // Debugger::ProfilingClient 57 60 bool isAlreadyProfiling() const override; -
trunk/Source/JavaScriptCore/inspector/protocol/CPUProfiler.json
r244158 r244191 53 53 { 54 54 "name": "trackingComplete", 55 "description": "Tracking stopped.", 56 "parameters": [ 57 { "name": "timestamp", "type": "number" } 58 ] 55 "description": "Tracking stopped. Includes any buffered data during tracking, such as profiling information." 59 56 } 60 57 ] -
trunk/Source/JavaScriptCore/inspector/protocol/Memory.json
r244158 r244191 65 65 { 66 66 "name": "trackingComplete", 67 "description": "Tracking stopped.", 68 "parameters": [ 69 { "name": "timestamp", "type": "number" } 70 ] 67 "description": "Tracking stopped." 71 68 } 72 69 ] -
trunk/Source/JavaScriptCore/inspector/protocol/ScriptProfiler.json
r244158 r244191 86 86 "description": "Tracking stopped. Includes any buffered data during tracking, such as profiling information.", 87 87 "parameters": [ 88 { "name": "timestamp", "type": "number" },89 88 { "name": "samples", "$ref": "Samples", "optional": true, "description": "Stack traces." } 90 89 ] 90 }, 91 { 92 "name": "programmaticCaptureStarted", 93 "description": "Fired when programmatic capture starts (console.profile). JSContext inspection only." 94 }, 95 { 96 "name": "programmaticCaptureStopped", 97 "description": "Fired when programmatic capture stops (console.profileEnd). JSContext inspection only." 91 98 } 92 99 ] -
trunk/Source/JavaScriptCore/inspector/protocol/Timeline.json
r244158 r244191 108 108 "name": "autoCaptureStarted", 109 109 "description": "Fired when auto capture started." 110 }, 111 { 112 "name": "programmaticCaptureStarted", 113 "description": "Fired when programmatic capture starts (console.profile)." 114 }, 115 { 116 "name": "programmaticCaptureStopped", 117 "description": "Fired when programmatic capture stops (console.profileEnd)." 110 118 } 111 119 ] -
trunk/Source/WebCore/ChangeLog
r244188 r244191 1 2019-04-11 Truitt Savell <tsavell@apple.com> 2 3 Unreviewed, rolling out r244158. 4 5 Casued 8 inspector/timeline/ test failures. 6 7 Reverted changeset: 8 9 "Web Inspector: Timelines: can't reliably stop/start a 10 recording" 11 https://bugs.webkit.org/show_bug.cgi?id=196778 12 https://trac.webkit.org/changeset/244158 13 1 14 2019-04-11 Pablo Saavedra <psaavedra@igalia.com> 2 15 -
trunk/Source/WebCore/inspector/agents/InspectorCPUProfilerAgent.cpp
r244158 r244191 78 78 m_tracking = false; 79 79 80 m_frontendDispatcher->trackingComplete( m_environment.executionStopwatch()->elapsedTime().seconds());80 m_frontendDispatcher->trackingComplete(); 81 81 } 82 82 -
trunk/Source/WebCore/inspector/agents/InspectorMemoryAgent.cpp
r244158 r244191 93 93 m_tracking = false; 94 94 95 m_frontendDispatcher->trackingComplete( m_environment.executionStopwatch()->elapsedTime().seconds());95 m_frontendDispatcher->trackingComplete(); 96 96 } 97 97 -
trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp
r244158 r244191 478 478 m_programmaticCaptureRestoreBreakpointActiveValue = false; 479 479 480 m_frontendDispatcher->programmaticCaptureStarted(); 481 480 482 toggleScriptProfilerInstrument(InstrumentState::Start); // Ensure JavaScript samping data. 481 483 toggleTimelineInstrument(InstrumentState::Start); // Ensure Console Profile event records. … … 499 501 } 500 502 } 503 504 m_frontendDispatcher->programmaticCaptureStopped(); 501 505 } 502 506 -
trunk/Source/WebInspectorUI/ChangeLog
r244180 r244191 1 2019-04-11 Truitt Savell <tsavell@apple.com> 2 3 Unreviewed, rolling out r244158. 4 5 Casued 8 inspector/timeline/ test failures. 6 7 Reverted changeset: 8 9 "Web Inspector: Timelines: can't reliably stop/start a 10 recording" 11 https://bugs.webkit.org/show_bug.cgi?id=196778 12 https://trac.webkit.org/changeset/244158 13 1 14 2019-04-10 Devin Rousso <drousso@apple.com> 2 15 -
trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js
r244158 r244191 39 39 WI.Breakpoint.addEventListener(WI.Breakpoint.Event.ActionsDidChange, this._handleBreakpointActionsDidChange, this); 40 40 41 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this); 41 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingWillStart, this._timelineCapturingWillStart, this); 42 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._timelineCapturingStopped, this); 42 43 43 44 WI.auditManager.addEventListener(WI.AuditManager.Event.TestScheduled, this._handleAuditManagerTestScheduled, this); … … 1137 1138 } 1138 1139 1139 _handleTimelineCapturingStateChanged(event) 1140 { 1141 switch (WI.timelineManager.capturingState) { 1142 case WI.TimelineManager.CapturingState.Starting: 1143 this._startDisablingBreakpointsTemporarily(); 1144 if (this.paused) 1145 this.resume(); 1146 break; 1147 1148 case WI.TimelineManager.CapturingState.Inactive: 1149 this._stopDisablingBreakpointsTemporarily(); 1150 break; 1151 } 1140 _timelineCapturingWillStart(event) 1141 { 1142 this._startDisablingBreakpointsTemporarily(); 1143 1144 if (this.paused) 1145 this.resume(); 1146 } 1147 1148 _timelineCapturingStopped(event) 1149 { 1150 this._stopDisablingBreakpointsTemporarily(); 1152 1151 } 1153 1152 -
trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js
r244158 r244191 34 34 WI.Frame.addEventListener(WI.Frame.Event.ProvisionalLoadStarted, this._provisionalLoadStarted, this); 35 35 WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this); 36 WI.Frame.addEventListener(WI.Frame.Event.ResourceWasAdded, this._resourceWasAdded, this); 37 WI.Target.addEventListener(WI.Target.Event.ResourceAdded, this._resourceWasAdded, this); 38 39 WI.heapManager.addEventListener(WI.HeapManager.Event.GarbageCollected, this._garbageCollected, this); 40 WI.memoryManager.addEventListener(WI.MemoryManager.Event.MemoryPressure, this._memoryPressure, this); 41 42 WI.settings.timelinesAutoStop.addEventListener(WI.Setting.Event.Changed, this._handleTimelinesAutoStopSettingChanged, this); 36 43 37 44 this._enabledTimelineTypesSetting = new WI.Setting("enabled-instrument-types", WI.TimelineManager.defaultTimelineTypes()); 38 45 39 this._capturingState = TimelineManager.CapturingState.Inactive; 40 this._capturingInstrumentCount = 0; 41 this._capturingStartTime = NaN; 42 this._capturingEndTime = NaN; 43 46 this._isCapturing = false; 44 47 this._initiatedByBackendStart = false; 45 48 this._initiatedByBackendStop = false; 46 49 this._waitingForCapturingStartedEvent = false; 47 50 this._isCapturingPageReload = false; 48 51 this._autoCaptureOnPageLoad = false; … … 50 53 this._shouldSetAutoCapturingMainResource = false; 51 54 this._transitioningPageTarget = false; 55 this._boundStopCapturing = this.stopCapturing.bind(this); 52 56 53 57 this._webTimelineScriptRecordsExpectingScriptProfilerEvents = null; 54 58 this._scriptProfilerRecords = null; 55 59 56 this._boundStopCapturing = this.stopCapturing.bind(this);57 60 this._stopCapturingTimeout = undefined; 58 61 this._deadTimeTimeout = undefined; … … 151 154 // Public 152 155 153 get capturingState() { return this._capturingState; }154 155 156 reset() 156 157 { 157 if (this. isCapturing())158 if (this._isCapturing) 158 159 this.stopCapturing(); 159 160 … … 168 169 get activeRecording() 169 170 { 170 console.assert(this._activeRecording || !this. isCapturing());171 console.assert(this._activeRecording || !this._isCapturing); 171 172 return this._activeRecording; 172 173 } … … 191 192 this._autoCaptureOnPageLoad = autoCapture; 192 193 193 for (let target of WI.targets) { 194 if (target.TimelineAgent) 195 target.TimelineAgent.setAutoCaptureEnabled(this._autoCaptureOnPageLoad); 196 } 194 if (window.TimelineAgent && TimelineAgent.setAutoCaptureEnabled) 195 TimelineAgent.setAutoCaptureEnabled(this._autoCaptureOnPageLoad); 197 196 } 198 197 … … 212 211 isCapturing() 213 212 { 214 return this._ capturingState !== TimelineManager.CapturingState.Inactive;213 return this._isCapturing; 215 214 } 216 215 … … 240 239 startCapturing(shouldCreateRecording) 241 240 { 242 console.assert(this._capturingState === TimelineManager.CapturingState.Stopping || this._capturingState === TimelineManager.CapturingState.Inactive, "TimelineManager is already capturing."); 243 if (this._capturingState !== TimelineManager.CapturingState.Stopping && this._capturingState !== TimelineManager.CapturingState.Inactive) 244 return; 241 console.assert(!this._isCapturing, "TimelineManager is already capturing."); 245 242 246 243 if (!this._activeRecording || shouldCreateRecording) 247 244 this._loadNewRecording(); 248 245 249 this._updateCapturingState(TimelineManager.CapturingState.Starting); 250 251 this._capturingStartTime = NaN; 246 this._waitingForCapturingStartedEvent = true; 247 248 this.dispatchEventToListeners(WI.TimelineManager.Event.CapturingWillStart); 249 252 250 this._activeRecording.start(this._initiatedByBackendStart); 253 251 } … … 255 253 stopCapturing() 256 254 { 257 console.assert(this._capturingState === TimelineManager.CapturingState.Starting || this._capturingState === TimelineManager.CapturingState.Active, "TimelineManager is not capturing."); 258 if (this._capturingState !== TimelineManager.CapturingState.Starting && this._capturingState !== TimelineManager.CapturingState.Active) 259 return; 260 261 this._updateCapturingState(TimelineManager.CapturingState.Stopping); 262 263 this._capturingEndTime = NaN; 255 console.assert(this._isCapturing, "TimelineManager is not capturing."); 256 264 257 this._activeRecording.stop(this._initiatedByBackendStop); 258 259 // NOTE: Always stop immediately instead of waiting for a Timeline.recordingStopped event. 260 // This way the UI feels as responsive to a stop as possible. 261 // FIXME: <https://webkit.org/b/152904> Web Inspector: Timeline UI should keep up with processing all incoming records 262 this.capturingStopped(); 263 } 264 265 unloadRecording() 266 { 267 if (!this._activeRecording) 268 return; 269 270 if (this._isCapturing) 271 this.stopCapturing(); 272 273 this._activeRecording.unloaded(); 274 this._activeRecording = null; 265 275 } 266 276 … … 296 306 this.dispatchEventToListeners(WI.TimelineManager.Event.RecordingCreated, {recording: newRecording}); 297 307 298 if (this. isCapturing())308 if (this._isCapturing) 299 309 this.stopCapturing(); 300 310 … … 330 340 // Called from WI.TimelineObserver. 331 341 332 // The frontend didn't start capturing, so this was a programmatic start. 333 if (this._capturingState === TimelineManager.CapturingState.Inactive) { 334 this._initiatedByBackendStart = true; 335 this._activeRecording.addScriptInstrumentForProgrammaticCapture(); 336 this.startCapturing(); 337 } 338 339 if (!isNaN(startTime)) { 340 if (isNaN(this._capturingStartTime) || startTime < this._capturingStartTime) 341 this._capturingStartTime = startTime; 342 343 this._activeRecording.initializeTimeBoundsIfNecessary(startTime); 344 } 345 346 this._capturingInstrumentCount++; 347 console.assert(this._capturingInstrumentCount); 348 if (this._capturingInstrumentCount > 1) 349 return; 350 351 if (this._capturingState === TimelineManager.CapturingState.Active) 352 return; 342 if (this._isCapturing) 343 return; 344 345 this._waitingForCapturingStartedEvent = false; 346 this._isCapturing = true; 353 347 354 348 this._lastDeadTimeTickle = 0; 355 349 350 if (startTime) 351 this.activeRecording.initializeTimeBoundsIfNecessary(startTime); 352 356 353 this._webTimelineScriptRecordsExpectingScriptProfilerEvents = []; 357 358 WI.settings.timelinesAutoStop.addEventListener(WI.Setting.Event.Changed, this._handleTimelinesAutoStopSettingChanged, this);359 360 WI.Frame.addEventListener(WI.Frame.Event.ResourceWasAdded, this._resourceWasAdded, this);361 WI.Target.addEventListener(WI.Target.Event.ResourceAdded, this._resourceWasAdded, this);362 363 WI.heapManager.addEventListener(WI.HeapManager.Event.GarbageCollected, this._garbageCollected, this);364 365 WI.memoryManager.addEventListener(WI.MemoryManager.Event.MemoryPressure, this._memoryPressure, this);366 354 367 355 WI.DOMNode.addEventListener(WI.DOMNode.Event.DidFireEvent, this._handleDOMNodeDidFireEvent, this); 368 356 WI.DOMNode.addEventListener(WI.DOMNode.Event.LowPowerChanged, this._handleDOMNodeLowPowerChanged, this); 369 357 370 this. _updateCapturingState(TimelineManager.CapturingState.Active, {startTime: this._capturingStartTime});358 this.dispatchEventToListeners(WI.TimelineManager.Event.CapturingStarted, {startTime}); 371 359 } 372 360 … … 375 363 // Called from WI.TimelineObserver. 376 364 377 // The frontend didn't stop capturing, so this was a programmatic stop. 378 if (this._capturingState === TimelineManager.CapturingState.Active) { 379 this._initiatedByBackendStop = true; 380 this.stopCapturing(); 381 } 382 383 if (!isNaN(endTime)) { 384 if (isNaN(this._capturingEndTime) || endTime > this._capturingEndTime) 385 this._capturingEndTime = endTime; 386 } 387 388 this._capturingInstrumentCount--; 389 console.assert(this._capturingInstrumentCount >= 0); 390 if (this._capturingInstrumentCount) 391 return; 392 393 if (this._capturingState === TimelineManager.CapturingState.Inactive) 365 if (!this._isCapturing) 394 366 return; 395 367 396 368 WI.DOMNode.removeEventListener(null, null, this); 397 WI.memoryManager.removeEventListener(null, null, this);398 WI.heapManager.removeEventListener(null, null, this);399 WI.Target.removeEventListener(WI.Target.Event.ResourceAdded, this._resourceWasAdded, this);400 WI.Frame.removeEventListener(WI.Frame.Event.ResourceWasAdded, this._resourceWasAdded, this);401 WI.settings.timelinesAutoStop.removeEventListener(null, null, this);402 369 403 370 this.relaxAutoStop(); 404 371 372 this._isCapturing = false; 405 373 this._isCapturingPageReload = false; 406 374 this._shouldSetAutoCapturingMainResource = false; … … 409 377 this._initiatedByBackendStop = false; 410 378 411 this. _updateCapturingState(TimelineManager.CapturingState.Inactive, {endTime: this._capturingEndTime});379 this.dispatchEventToListeners(WI.TimelineManager.Event.CapturingStopped, {endTime}); 412 380 } 413 381 … … 416 384 // Called from WI.TimelineObserver. 417 385 418 let waitingForCapturingStartedEvent = this._capturingState === TimelineManager.CapturingState.Starting; 419 420 if (this.isCapturing()) 386 if (this._isCapturing) 421 387 this.stopCapturing(); 422 388 … … 426 392 // between sending the Timeline.start command and receiving Timeline.capturingStarted event. 427 393 // In that case, there is no need to call startCapturing again. Reuse the fresh recording. 428 if (! waitingForCapturingStartedEvent) {394 if (!this._waitingForCapturingStartedEvent) { 429 395 const createNewRecording = true; 430 396 this.startCapturing(createNewRecording); … … 434 400 } 435 401 402 programmaticCaptureStarted() 403 { 404 // Called from WI.TimelineObserver. 405 406 this._initiatedByBackendStart = true; 407 408 this._activeRecording.addScriptInstrumentForProgrammaticCapture(); 409 410 const createNewRecording = false; 411 this.startCapturing(createNewRecording); 412 } 413 414 programmaticCaptureStopped() 415 { 416 // Called from WI.TimelineObserver. 417 418 this._initiatedByBackendStop = true; 419 420 // FIXME: This is purely to avoid a noisy assert. Previously 421 // it was impossible to stop without stopping from the UI. 422 console.assert(!this._isCapturing); 423 this._isCapturing = true; 424 425 this.stopCapturing(); 426 } 427 436 428 eventRecorded(recordPayload) 437 429 { 438 430 // Called from WI.TimelineObserver. 439 431 440 console.assert(this.isCapturing()); 441 if (!this.isCapturing()) 432 if (!this._isCapturing) 442 433 return; 443 434 … … 479 470 } 480 471 472 // Protected 473 481 474 pageDOMContentLoadedEventFired(timestamp) 482 475 { … … 486 479 console.assert(isNaN(WI.networkManager.mainFrame.domContentReadyEventTimestamp)); 487 480 488 let computedTimestamp = this. _activeRecording.computeElapsedTime(timestamp);481 let computedTimestamp = this.activeRecording.computeElapsedTime(timestamp); 489 482 490 483 WI.networkManager.mainFrame.markDOMContentReadyEvent(computedTimestamp); … … 501 494 console.assert(isNaN(WI.networkManager.mainFrame.loadEventTimestamp)); 502 495 503 let computedTimestamp = this. _activeRecording.computeElapsedTime(timestamp);496 let computedTimestamp = this.activeRecording.computeElapsedTime(timestamp); 504 497 505 498 WI.networkManager.mainFrame.markLoadEvent(computedTimestamp); … … 522 515 // Called from WI.CPUProfilerObserver. 523 516 524 console.assert(this.isCapturing()); 525 if (!this.isCapturing()) 517 if (!this._isCapturing) 526 518 return; 527 519 … … 529 521 } 530 522 531 cpuProfilerTrackingCompleted( timestamp)523 cpuProfilerTrackingCompleted() 532 524 { 533 525 // Called from WI.CPUProfilerObserver. 534 535 this.capturingStopped(timestamp);536 526 } 537 527 … … 547 537 // Called from WI.MemoryObserver. 548 538 549 console.assert(this.isCapturing()); 550 if (!this.isCapturing()) 539 if (!this._isCapturing) 551 540 return; 552 541 … … 554 543 } 555 544 556 memoryTrackingCompleted( timestamp)545 memoryTrackingCompleted() 557 546 { 558 547 // Called from WI.MemoryObserver. 559 560 this.capturingStopped(timestamp);561 548 } 562 549 … … 565 552 // Called from WI.HeapObserver. 566 553 554 this._addRecord(new WI.HeapAllocationsTimelineRecord(timestamp, snapshot)); 555 567 556 this.capturingStarted(timestamp); 557 } 558 559 heapTrackingCompleted(timestamp, snapshot) 560 { 561 // Called from WI.HeapObserver. 568 562 569 563 this._addRecord(new WI.HeapAllocationsTimelineRecord(timestamp, snapshot)); 570 564 } 571 565 572 heap TrackingCompleted(timestamp, snapshot)573 { 574 // Called from WI.Heap Observer.566 heapSnapshotAdded(timestamp, snapshot) 567 { 568 // Called from WI.HeapAllocationsInstrument. 575 569 576 570 this._addRecord(new WI.HeapAllocationsTimelineRecord(timestamp, snapshot)); 577 578 this.capturingStopped();579 }580 581 heapSnapshotAdded(timestamp, snapshot)582 {583 // Called from WI.HeapAllocationsInstrument.584 585 console.assert(this.isCapturing());586 if (!this.isCapturing())587 return;588 589 this._addRecord(new WI.HeapAllocationsTimelineRecord(timestamp, snapshot));590 571 } 591 572 592 573 // Private 593 574 594 _updateCapturingState(state, data = {})595 {596 if (this._capturingState === state)597 return;598 599 this._capturingState = state;600 601 this.dispatchEventToListeners(TimelineManager.Event.CapturingStateChanged, data);602 }603 604 575 _processRecord(recordPayload, parentRecordPayload) 605 576 { 606 console.assert(this.isCapturing()); 607 608 var startTime = this._activeRecording.computeElapsedTime(recordPayload.startTime); 609 var endTime = this._activeRecording.computeElapsedTime(recordPayload.endTime); 577 var startTime = this.activeRecording.computeElapsedTime(recordPayload.startTime); 578 var endTime = this.activeRecording.computeElapsedTime(recordPayload.endTime); 610 579 var callFrames = this._callFramesFromPayload(recordPayload.stackTrace); 611 580 … … 794 763 _processEvent(recordPayload, parentRecordPayload) 795 764 { 796 console.assert(this.isCapturing());797 798 765 switch (recordPayload.type) { 799 766 case TimelineAgent.EventType.TimeStamp: 800 var timestamp = this. _activeRecording.computeElapsedTime(recordPayload.startTime);767 var timestamp = this.activeRecording.computeElapsedTime(recordPayload.startTime); 801 768 var eventMarker = new WI.TimelineMarker(timestamp, WI.TimelineMarker.Type.TimeStamp, recordPayload.data.message); 802 769 this._activeRecording.addEventMarker(eventMarker); … … 828 795 this.dispatchEventToListeners(WI.TimelineManager.Event.RecordingCreated, {recording: newRecording}); 829 796 830 if (this. isCapturing())797 if (this._isCapturing) 831 798 this.stopCapturing(); 832 799 … … 861 828 _addRecord(record) 862 829 { 863 console.assert(this.isCapturing());864 865 830 this._activeRecording.addRecord(record); 866 831 … … 880 845 // COMPATIBILITY (iOS 9): Timeline.setAutoCaptureEnabled did not exist. 881 846 // Perform auto capture in the frontend. 882 if (! InspectorBackend.domains.Timeline)847 if (!window.TimelineAgent) 883 848 return false; 884 if (! InspectorBackend.domains.Timeline.setAutoCaptureEnabled)849 if (!TimelineAgent.setAutoCaptureEnabled) 885 850 return this._legacyAttemptStartAutoCapturingForFrame(frame); 886 851 … … 888 853 return false; 889 854 890 console.assert(this. isCapturing(), "We saw autoCaptureStarted so we should already be capturing");855 console.assert(this._isCapturing, "We saw autoCaptureStarted so we should already be capturing"); 891 856 892 857 let mainResource = frame.provisionalMainResource || frame.mainResource; … … 910 875 _legacyAttemptStartAutoCapturingForFrame(frame) 911 876 { 912 if (this. isCapturing()&& !this._mainResourceForAutoCapturing)877 if (this._isCapturing && !this._mainResourceForAutoCapturing) 913 878 return false; 914 879 … … 920 885 this._isCapturingPageReload = oldMainResource !== null && oldMainResource.url === mainResource.url; 921 886 922 if (this. isCapturing())887 if (this._isCapturing) 923 888 this.stopCapturing(); 924 889 … … 942 907 943 908 // Only auto stop when auto capturing. 944 if (!this. isCapturing()|| !this._mainResourceForAutoCapturing)909 if (!this._isCapturing || !this._mainResourceForAutoCapturing) 945 910 return; 946 911 … … 966 931 967 932 // Only monitor dead time when auto capturing. 968 if (!this. isCapturing()|| !this._mainResourceForAutoCapturing)933 if (!this._isCapturing || !this._mainResourceForAutoCapturing) 969 934 return; 970 935 … … 1007 972 return; 1008 973 1009 console.assert(this.isCapturing()); 1010 if (!this.isCapturing()) 974 if (!this._isCapturing) 1011 975 return; 1012 976 … … 1020 984 _resourceWasAdded(event) 1021 985 { 986 1022 987 // Ignore resource events when there isn't a main frame yet. Those events are triggered by 1023 988 // loading the cached resources when the inspector opens, and they do not have timing information. … … 1025 990 return; 1026 991 992 if (!this._isCapturing) 993 return; 994 1027 995 this._addRecord(new WI.ResourceTimelineRecord(event.data.resource)); 1028 996 } … … 1030 998 _garbageCollected(event) 1031 999 { 1032 let {collection} = event.data; 1000 if (!this._isCapturing) 1001 return; 1002 1003 let collection = event.data.collection; 1033 1004 this._addRecord(new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.GarbageCollected, collection.startTime, collection.endTime, null, null, collection)); 1034 1005 } … … 1036 1007 _memoryPressure(event) 1037 1008 { 1038 this._activeRecording.addMemoryPressureEvent(event.data.memoryPressureEvent); 1009 if (!this._isCapturing) 1010 return; 1011 1012 this.activeRecording.addMemoryPressureEvent(event.data.memoryPressureEvent); 1039 1013 } 1040 1014 1041 1015 _handleTimelinesAutoStopSettingChanged(event) 1042 1016 { 1017 if (!this._isCapturing) 1018 return; 1019 1043 1020 if (WI.settings.timelinesAutoStop.value) { 1044 1021 if (this._mainResourceForAutoCapturing && !isNaN(this._mainResourceForAutoCapturing.parentFrame.loadEventTimestamp)) … … 1063 1040 } 1064 1041 1042 scriptProfilerProgrammaticCaptureStarted() 1043 { 1044 // FIXME: <https://webkit.org/b/158753> Generalize the concept of Instruments on the backend to work equally for JSContext and Web inspection 1045 console.assert(WI.sharedApp.debuggableType === WI.DebuggableType.JavaScript); 1046 console.assert(!this._isCapturing); 1047 1048 this.programmaticCaptureStarted(); 1049 } 1050 1051 scriptProfilerProgrammaticCaptureStopped() 1052 { 1053 // FIXME: <https://webkit.org/b/158753> Generalize the concept of Instruments on the backend to work equally for JSContext and Web inspection 1054 console.assert(WI.sharedApp.debuggableType === WI.DebuggableType.JavaScript); 1055 console.assert(this._isCapturing); 1056 1057 this.programmaticCaptureStopped(); 1058 } 1059 1065 1060 scriptProfilerTrackingStarted(timestamp) 1066 1061 { … … 1086 1081 } 1087 1082 1088 scriptProfilerTrackingCompleted( timestamp,samples)1083 scriptProfilerTrackingCompleted(samples) 1089 1084 { 1090 1085 console.assert(!this._webTimelineScriptRecordsExpectingScriptProfilerEvents || this._scriptProfilerRecords.length >= this._webTimelineScriptRecordsExpectingScriptProfilerEvents.length); … … 1092 1087 if (samples) { 1093 1088 let {stackTraces} = samples; 1094 let topDownCallingContextTree = this. _activeRecording.topDownCallingContextTree;1089 let topDownCallingContextTree = this.activeRecording.topDownCallingContextTree; 1095 1090 1096 1091 // Calculate a per-sample duration. … … 1126 1121 sampleDurations.fill(defaultDuration, sampleDurationIndex); 1127 1122 1128 this. _activeRecording.initializeCallingContextTrees(stackTraces, sampleDurations);1123 this.activeRecording.initializeCallingContextTrees(stackTraces, sampleDurations); 1129 1124 1130 1125 // FIXME: This transformation should not be needed after introducing ProfileView. … … 1146 1141 this._scriptProfilerRecords = null; 1147 1142 1148 let timeline = this. _activeRecording.timelineForRecordType(WI.TimelineRecord.Type.Script);1143 let timeline = this.activeRecording.timelineForRecordType(WI.TimelineRecord.Type.Script); 1149 1144 timeline.refresh(); 1150 1151 this.capturingStopped(timestamp);1152 1145 } 1153 1146 … … 1248 1241 _handleDOMNodeDidFireEvent(event) 1249 1242 { 1243 console.assert(this._isCapturing); 1244 1250 1245 let {domEvent} = event.data; 1251 1246 … … 1258 1253 _handleDOMNodeLowPowerChanged(event) 1259 1254 { 1255 console.assert(this._isCapturing); 1256 1260 1257 let {timestamp, isLowPower} = event.data; 1261 1258 … … 1267 1264 }; 1268 1265 1269 WI.TimelineManager.CapturingState = {1270 Inactive: "inactive",1271 Starting: "starting",1272 Active: "active",1273 Stopping: "stopping",1274 };1275 1276 1266 WI.TimelineManager.Event = { 1277 CapturingStateChanged: "timeline-manager-capturing-started",1278 1267 RecordingCreated: "timeline-manager-recording-created", 1279 1268 RecordingLoaded: "timeline-manager-recording-loaded", 1280 1269 RecordingImported: "timeline-manager-recording-imported", 1270 CapturingWillStart: "timeline-manager-capturing-will-start", 1271 CapturingStarted: "timeline-manager-capturing-started", 1272 CapturingStopped: "timeline-manager-capturing-stopped" 1281 1273 }; 1282 1274 -
trunk/Source/WebInspectorUI/UserInterface/Models/DefaultDashboard.js
r244158 r244191 34 34 // Necessary event required to track page load time and resource sizes. 35 35 WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this); 36 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingSt ateChanged, this._handleTimelineCapturingStateChanged, this);36 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._capturingStopped, this); 37 37 38 38 // Necessary events required to track load of resources. … … 164 164 } 165 165 166 _handleTimelineCapturingStateChanged(event) 167 { 168 if (WI.timelineManager.isCapturing()) 169 return; 170 166 _capturingStopped(event) 167 { 171 168 // If recording stops, we should stop the timer if it hasn't stopped already. 172 169 this._stopUpdatingTime(); -
trunk/Source/WebInspectorUI/UserInterface/Protocol/CPUProfilerObserver.js
r244158 r244191 38 38 } 39 39 40 trackingComplete( timestamp)40 trackingComplete(samples) 41 41 { 42 WI.timelineManager.cpuProfilerTrackingCompleted( timestamp);42 WI.timelineManager.cpuProfilerTrackingCompleted(samples); 43 43 } 44 44 }; -
trunk/Source/WebInspectorUI/UserInterface/Protocol/MemoryObserver.js
r244158 r244191 43 43 } 44 44 45 trackingComplete( timestamp)45 trackingComplete() 46 46 { 47 WI.timelineManager.memoryTrackingCompleted( timestamp);47 WI.timelineManager.memoryTrackingCompleted(); 48 48 } 49 49 }; -
trunk/Source/WebInspectorUI/UserInterface/Protocol/ScriptProfilerObserver.js
r244158 r244191 38 38 } 39 39 40 trackingComplete( timestamp,samples)40 trackingComplete(samples) 41 41 { 42 WI.timelineManager.scriptProfilerTrackingCompleted( timestamp,samples);42 WI.timelineManager.scriptProfilerTrackingCompleted(samples); 43 43 } 44 44 45 45 programmaticCaptureStarted() 46 46 { 47 // COMPATIBILITY (iOS 12.2): ScriptProfiler.programmaticCaptureStarted was removed after iOS 12.2.47 WI.timelineManager.scriptProfilerProgrammaticCaptureStarted(); 48 48 } 49 49 50 50 programmaticCaptureStopped() 51 51 { 52 // COMPATIBILITY (iOS 12.2): ScriptProfiler.programmaticCaptureStopped was removed after iOS 12.2.52 WI.timelineManager.scriptProfilerProgrammaticCaptureStopped(); 53 53 } 54 54 }; -
trunk/Source/WebInspectorUI/UserInterface/Protocol/TimelineObserver.js
r244158 r244191 50 50 programmaticCaptureStarted() 51 51 { 52 // COMPATIBILITY (iOS 12.2): Timeline.programmaticCaptureStarted was removed after iOS 12.2.52 WI.timelineManager.programmaticCaptureStarted(); 53 53 } 54 54 55 55 programmaticCaptureStopped() 56 56 { 57 // COMPATIBILITY (iOS 12.2): Timeline.programmaticCaptureStopped was removed after iOS 12.2.57 WI.timelineManager.programmaticCaptureStopped(); 58 58 } 59 59 }; -
trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js
r244158 r244191 56 56 WI.DOMBreakpoint.addEventListener(WI.DOMBreakpoint.Event.DOMNodeChanged, this._handleDOMBreakpointDOMNodeChanged, this); 57 57 58 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this); 58 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingWillStart, this._timelineCapturingWillStart, this); 59 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._timelineCapturingStopped, this); 59 60 60 61 WI.auditManager.addEventListener(WI.AuditManager.Event.TestScheduled, this._handleAuditManagerTestScheduled, this); … … 251 252 252 253 if (WI.debuggerManager.breakpointsDisabledTemporarily) { 253 this._handleTimelineCapturingStateChanged(); 254 if (WI.timelineManager.isCapturing()) 255 this._timelineCapturingWillStart(); 254 256 255 257 if (WI.auditManager.runningState === WI.AuditManager.RunningState.Active || WI.auditManager.runningState === WI.AuditManager.RunningState.Stopping) … … 647 649 } 648 650 649 _ handleTimelineCapturingStateChanged(event)651 _timelineCapturingWillStart(event) 650 652 { 651 653 this._updateTemporarilyDisabledBreakpointsButtons(); 652 654 653 switch (WI.timelineManager.capturingState) { 654 case WI.TimelineManager.CapturingState.Starting: 655 this.contentView.element.insertBefore(this._timelineRecordingWarningElement, this.contentView.element.firstChild); 656 break; 657 658 case WI.TimelineManager.CapturingState.Inactive: 659 this._timelineRecordingWarningElement.remove(); 660 break; 661 } 662 655 this.contentView.element.insertBefore(this._timelineRecordingWarningElement, this.contentView.element.firstChild); 656 this._updateBreakpointsDisabledBanner(); 657 } 658 659 _timelineCapturingStopped(event) 660 { 661 this._updateTemporarilyDisabledBreakpointsButtons(); 662 663 this._timelineRecordingWarningElement.remove(); 663 664 this._updateBreakpointsDisabledBanner(); 664 665 } -
trunk/Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js
r244158 r244191 283 283 WI.consoleManager.addEventListener(WI.ConsoleManager.Event.Cleared, this._handleConsoleCleared, this); 284 284 285 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this); 285 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingWillStart, this._handleTimelineCapturingWillStart, this); 286 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._handleTimelineCapturingStopped, this); 286 287 287 288 WI.auditManager.addEventListener(WI.AuditManager.Event.TestScheduled, this._handleAuditManagerTestScheduled, this); … … 337 338 338 339 if (WI.debuggerManager.breakpointsDisabledTemporarily) { 339 this._handleTimelineCapturingStateChanged(); 340 if (WI.timelineManager.isCapturing()) 341 this._handleTimelineCapturingWillStart(); 340 342 341 343 if (WI.auditManager.runningState === WI.AuditManager.RunningState.Active || WI.auditManager.runningState === WI.AuditManager.RunningState.Stopping) … … 1819 1821 } 1820 1822 1821 _handleTimelineCapturing StateChanged(event)1823 _handleTimelineCapturingWillStart(event) 1822 1824 { 1823 1825 this._updateTemporarilyDisabledBreakpointsButtons(); 1824 1826 1825 switch (WI.timelineManager.capturingState) { 1826 case WI.TimelineManager.CapturingState.Starting: 1827 if (!this._timelineRecordingWarningElement) { 1828 let stopRecordingButton = document.createElement("button"); 1829 stopRecordingButton.textContent = WI.UIString("Stop recording"); 1830 stopRecordingButton.addEventListener("click", () => { 1831 WI.timelineManager.stopCapturing(); 1832 }); 1833 1834 this._timelineRecordingWarningElement = document.createElement("div"); 1835 this._timelineRecordingWarningElement.classList.add("warning-banner"); 1836 this._timelineRecordingWarningElement.append(WI.UIString("Debugger disabled during Timeline recording"), document.createElement("br"), stopRecordingButton); 1837 } 1838 1839 this.contentView.element.insertBefore(this._timelineRecordingWarningElement, this.contentView.element.firstChild); 1840 break; 1841 1842 case WI.TimelineManager.CapturingState.Inactive: 1843 if (this._timelineRecordingWarningElement) { 1844 this._timelineRecordingWarningElement.remove(); 1845 this._timelineRecordingWarningElement = null; 1846 } 1847 break; 1827 if (!this._timelineRecordingWarningElement) { 1828 let stopRecordingButton = document.createElement("button"); 1829 stopRecordingButton.textContent = WI.UIString("Stop recording"); 1830 stopRecordingButton.addEventListener("click", () => { 1831 WI.timelineManager.stopCapturing(); 1832 }); 1833 1834 this._timelineRecordingWarningElement = document.createElement("div"); 1835 this._timelineRecordingWarningElement.classList.add("warning-banner"); 1836 this._timelineRecordingWarningElement.append(WI.UIString("Debugger disabled during Timeline recording"), document.createElement("br"), stopRecordingButton); 1837 } 1838 1839 this.contentView.element.insertBefore(this._timelineRecordingWarningElement, this.contentView.element.firstChild); 1840 1841 this._updateBreakpointsDisabledBanner(); 1842 } 1843 1844 _handleTimelineCapturingStopped(event) 1845 { 1846 this._updateTemporarilyDisabledBreakpointsButtons(); 1847 1848 if (this._timelineRecordingWarningElement) { 1849 this._timelineRecordingWarningElement.remove(); 1850 this._timelineRecordingWarningElement = null; 1848 1851 } 1849 1852 -
trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js
r244158 r244191 117 117 this._viewModeDidChange(); 118 118 119 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);120 119 WI.timelineManager.addEventListener(WI.TimelineManager.Event.RecordingImported, this._recordingImported, this); 120 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStarted, this._capturingStarted, this); 121 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._capturingStopped, this); 121 122 } 122 123 … … 1032 1033 } 1033 1034 1034 _handleTimelineCapturingStateChanged(event)1035 {1036 switch (WI.timelineManager.capturingState) {1037 case WI.TimelineManager.CapturingState.Active:1038 this._editInstrumentsButton.enabled = false;1039 this._stopEditingInstruments();1040 break;1041 1042 case WI.TimelineManager.CapturingState.Inactive:1043 this._editInstrumentsButton.enabled = true;1044 break;1045 }1046 }1047 1048 1035 _recordingImported(event) 1049 1036 { … … 1069 1056 } 1070 1057 1058 _capturingStarted(event) 1059 { 1060 this._editInstrumentsButton.enabled = false; 1061 this._stopEditingInstruments(); 1062 } 1063 1064 _capturingStopped(event) 1065 { 1066 this._editInstrumentsButton.enabled = true; 1067 } 1068 1071 1069 _compareTimelineTreeElements(a, b) 1072 1070 { -
trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js
r244158 r244191 103 103 this._recording.addEventListener(WI.TimelineRecording.Event.Unloaded, this._recordingUnloaded, this); 104 104 105 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this); 105 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStarted, this._capturingStarted, this); 106 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._capturingStopped, this); 106 107 107 108 WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, this._debuggerPaused, this); … … 510 511 } 511 512 512 _handleTimelineCapturingStateChanged(event) 513 { 514 let {startTime, endTime} = event.data; 515 513 _capturingStarted(event) 514 { 516 515 this._updateProgressView(); 517 516 518 switch (WI.timelineManager.capturingState) { 519 case WI.TimelineManager.CapturingState.Active: 520 if (!this._updating) 521 this._startUpdatingCurrentTime(startTime); 522 523 this._clearTimelineNavigationItem.enabled = !this._recording.readonly; 524 this._exportButtonNavigationItem.enabled = false; 525 526 // A discontinuity occurs when the recording is stopped and resumed at 527 // a future time. Capturing started signals the end of the current 528 // discontinuity, if one exists. 529 if (!isNaN(this._discontinuityStartTime)) { 530 this._recording.addDiscontinuity(this._discontinuityStartTime, startTime); 531 this._discontinuityStartTime = NaN; 532 } 533 break; 534 535 case WI.TimelineManager.CapturingState.Inactive: 536 if (this._updating) 537 this._stopUpdatingCurrentTime(); 538 539 if (this.currentTimelineView) 540 this._updateTimelineViewTimes(this.currentTimelineView); 541 542 this._discontinuityStartTime = endTime || this._currentTime; 543 544 this._exportButtonNavigationItem.enabled = this._recording.canExport(); 545 break; 546 } 517 let startTime = event.data.startTime; 518 if (!this._updating) 519 this._startUpdatingCurrentTime(startTime); 520 this._clearTimelineNavigationItem.enabled = !this._recording.readonly; 521 this._exportButtonNavigationItem.enabled = false; 522 523 // A discontinuity occurs when the recording is stopped and resumed at 524 // a future time. Capturing started signals the end of the current 525 // discontinuity, if one exists. 526 if (!isNaN(this._discontinuityStartTime)) { 527 this._recording.addDiscontinuity(this._discontinuityStartTime, startTime); 528 this._discontinuityStartTime = NaN; 529 } 530 } 531 532 _capturingStopped(event) 533 { 534 this._updateProgressView(); 535 536 if (this._updating) 537 this._stopUpdatingCurrentTime(); 538 539 if (this.currentTimelineView) 540 this._updateTimelineViewTimes(this.currentTimelineView); 541 542 this._discontinuityStartTime = event.data.endTime || this._currentTime; 543 544 this._exportButtonNavigationItem.enabled = this._recording.canExport(); 547 545 } 548 546 … … 734 732 console.assert(!this._updating); 735 733 736 WI.timelineManager.removeEventListener(null, null, this); 734 WI.timelineManager.removeEventListener(WI.TimelineManager.Event.CapturingStarted, this._capturingStarted, this); 735 WI.timelineManager.removeEventListener(WI.TimelineManager.Event.CapturingStopped, this._capturingStopped, this); 737 736 } 738 737 -
trunk/Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js
r244158 r244191 72 72 } 73 73 74 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);75 74 WI.timelineManager.addEventListener(WI.TimelineManager.Event.RecordingCreated, this._recordingCreated, this); 76 75 WI.timelineManager.addEventListener(WI.TimelineManager.Event.RecordingLoaded, this._recordingLoaded, this); 76 77 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStarted, this._capturingStartedOrStopped, this); 78 WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._capturingStartedOrStopped, this); 77 79 78 80 WI.notifications.addEventListener(WI.Notification.VisibilityStateDidChange, this._inspectorVisibilityChanged, this); … … 424 426 } 425 427 426 _handleTimelineCapturingStateChanged(event) 427 { 428 let enabled = WI.timelineManager.capturingState === WI.TimelineManager.CapturingState.Active || WI.timelineManager.capturingState === WI.TimelineManager.CapturingState.Inactive; 429 430 this._toggleRecordingShortcut.disabled = !enabled; 431 this._toggleNewRecordingShortcut.disabled = !enabled; 432 433 this._recordButton.toggled = WI.timelineManager.isCapturing(); 434 this._recordButton.enabled = enabled; 428 _capturingStartedOrStopped(event) 429 { 430 let isCapturing = WI.timelineManager.isCapturing(); 431 this._recordButton.toggled = isCapturing; 435 432 436 433 this._updateNavigationBarButtons();
Note: See TracChangeset
for help on using the changeset viewer.