RPP: track recording time in TimelineController This is part of the work to get rid of PerformanceModel - next up is the recordStartTime() method. Unfortunately I cannot remove it fully as the TimelineHistoryManager relies on it. That is what I am working on next - but this CL still progresses us by storing the recording time in the controller and then passing it through, thus ensuring that the TimelinePanel does not depend on the PerformanceModel to know the time that the recording started. Bug: 1499182 Change-Id: I863ec95f8b1e9142e468517cd4bf3c8e83a4110e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5116722 Reviewed-by: Andres Olivares <andoli@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
diff --git a/front_end/panels/timeline/TimelineController.ts b/front_end/panels/timeline/TimelineController.ts index f40e937..7c2734f 100644 --- a/front_end/panels/timeline/TimelineController.ts +++ b/front_end/panels/timeline/TimelineController.ts
@@ -27,6 +27,7 @@ private tracingManager: TraceEngine.TracingManager.TracingManager|null; private performanceModel: PerformanceModel; #collectedEvents: TraceEngine.Types.TraceEvents.TraceEventData[] = []; + #recordingStartTime: number|null = null; private readonly client: Client; private readonly tracingModel: TraceEngine.Legacy.TracingModel; // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration @@ -125,6 +126,7 @@ } this.performanceModel.setRecordStartTime(Date.now()); + this.#recordingStartTime = Date.now(); const response = await this.startRecordingWithCategories(categoriesArray.join(',')); if (response.getError()) { await this.waitForTracingToStop(false); @@ -193,7 +195,8 @@ await SDK.TargetManager.TargetManager.instance().resumeAllTargets(); this.tracingModel.tracingComplete(); await this.client.loadingComplete( - this.#collectedEvents, this.tracingModel, /* exclusiveFilter= */ null, /* isCpuProfile= */ false); + this.#collectedEvents, this.tracingModel, /* exclusiveFilter= */ null, /* isCpuProfile= */ false, + this.#recordingStartTime); this.client.loadingCompleteForTest(); } @@ -214,8 +217,8 @@ loadingComplete( collectedEvents: TraceEngine.Types.TraceEvents.TraceEventData[], tracingModel: TraceEngine.Legacy.TracingModel|null, - exclusiveFilter: TimelineModel.TimelineModelFilter.TimelineModelFilter|null, - isCpuProfile: boolean): Promise<void>; + exclusiveFilter: TimelineModel.TimelineModelFilter.TimelineModelFilter|null, isCpuProfile: boolean, + recordingStartTime: number|null): Promise<void>; loadingCompleteForTest(): void; } export interface RecordingOptions {
diff --git a/front_end/panels/timeline/TimelineLoader.ts b/front_end/panels/timeline/TimelineLoader.ts index 8df4b77..471390d 100644 --- a/front_end/panels/timeline/TimelineLoader.ts +++ b/front_end/panels/timeline/TimelineLoader.ts
@@ -180,7 +180,8 @@ this.tracingModel = null; if (this.client) { await this.client.loadingComplete( - /* collectedEvents */[], /* tracingModel= */ null, /* exclusiveFilter= */ null, /* isCpuProfile= */ false); + /* collectedEvents */[], /* tracingModel= */ null, /* exclusiveFilter= */ null, /* isCpuProfile= */ false, + /* recordingStartTime= */ null); this.client = null; } if (this.canceledCallback) { @@ -323,7 +324,8 @@ } (this.tracingModel as TraceEngine.Legacy.TracingModel).tracingComplete(); await (this.client as Client) - .loadingComplete(this.#collectedEvents, this.tracingModel, this.filter, this.isCpuProfile()); + .loadingComplete( + this.#collectedEvents, this.tracingModel, this.filter, this.isCpuProfile(), /* recordingStartTime=*/ null); this.#traceFinalizedCallbackForTest?.(); }
diff --git a/front_end/panels/timeline/TimelinePanel.ts b/front_end/panels/timeline/TimelinePanel.ts index d7595fc..1d7083f 100644 --- a/front_end/panels/timeline/TimelinePanel.ts +++ b/front_end/panels/timeline/TimelinePanel.ts
@@ -1003,7 +1003,8 @@ /* no collectedEvents */[], /* tracingModel= */ null, /* exclusiveFilter= */ null, - /* isCpuProfile= */ false); + /* isCpuProfile= */ false, + /* recordingStartTime= */ null); }); this.statusPane.showPane(this.statusPaneContainer); this.statusPane.updateStatus(i18nString(UIStrings.recordingFailed)); @@ -1316,8 +1317,8 @@ async loadingComplete( collectedEvents: TraceEngine.Types.TraceEvents.TraceEventData[], tracingModel: TraceEngine.Legacy.TracingModel|null, - exclusiveFilter: TimelineModel.TimelineModelFilter.TimelineModelFilter|null = null, - isCpuProfile: boolean): Promise<void> { + exclusiveFilter: TimelineModel.TimelineModelFilter.TimelineModelFilter|null = null, isCpuProfile: boolean, + recordingStartTime: number|null): Promise<void> { this.#traceEngineModel.resetProcessor(); SourceMapsResolver.clearResolvedNodeNames(); @@ -1346,8 +1347,7 @@ // Calling setTracingModel now and setModel so much later, leads to several problems due to addEventListener order being unexpected // TODO(paulirish): Resolve this, or just wait for the death of tracingModel. :) this.performanceModel.setTracingModel(tracingModel, recordingIsFresh), - this.#executeNewTraceEngine( - collectedEvents, recordingIsFresh, isCpuProfile, this.performanceModel.recordStartTime()), + this.#executeNewTraceEngine(collectedEvents, recordingIsFresh, isCpuProfile, recordingStartTime), ]); // This code path is only executed when a new trace is recorded/imported, @@ -1424,9 +1424,10 @@ async #executeNewTraceEngine( collectedEvents: TraceEngine.Types.TraceEvents.TraceEventData[], isFreshRecording: boolean, isCpuProfile: boolean, - recordStartTime?: number): Promise<void> { + recordStartTime: number|null): Promise<void> { const shouldGatherMetadata = isFreshRecording && !isCpuProfile; - const metadata = shouldGatherMetadata ? await TraceEngine.Extras.Metadata.forNewRecording(recordStartTime) : {}; + const metadata = + shouldGatherMetadata ? await TraceEngine.Extras.Metadata.forNewRecording(recordStartTime ?? undefined) : {}; metadata.dataOrigin = isCpuProfile ? TraceEngine.Types.File.DataOrigin.CPUProfile : TraceEngine.Types.File.DataOrigin.TraceEvents;