From e953a429614de8076033aef344b53e19e36e6506 Mon Sep 17 00:00:00 2001 From: Steve Golton Date: Fri, 1 Mar 2024 14:15:14 +0000 Subject: [PATCH] ui: Avoid moving initial visible window start time past its end - As of aosp/2649039, upon loading a trace, we move the start of the initial visible window to the first ftrace event. - In some traces, the first ftrace event is after the end of the initial visible window calculated from the tracing metadata. - On loading these traces, the UI would immediately crash as time spans of negative duration are not allowed. - This CL limits how far back we can move the start of the visible window, avoiding negative time spans. Bug: 325015524 Change-Id: I087318ed3fba51353d47afae106d7c9c51a77f00 --- ui/src/controller/trace_controller.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/src/controller/trace_controller.ts b/ui/src/controller/trace_controller.ts index 40a8f09595..b911a45885 100644 --- a/ui/src/controller/trace_controller.ts +++ b/ui/src/controller/trace_controller.ts @@ -1159,9 +1159,11 @@ async function computeVisibleTime( visibleStart = Time.max(visibleStart, reliableRangeStart); } + // Move start of visible window to the first ftrace event const ftraceBounds = await computeFtraceBounds(engine); if (ftraceBounds !== null) { - visibleStart = ftraceBounds.start; + // Avoid moving start of visible window past its end! + visibleStart = Time.min(ftraceBounds.start, visibleEnd); } return HighPrecisionTimeSpan.fromTime(visibleStart, visibleEnd); }