From 3516b36c455e484731a7547dcca75745abb09bc5 Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Fri, 13 Jun 2025 21:56:16 +0100 Subject: [PATCH 1/2] Fix event skipping in the timeline viewer Ensure that we use the physical stream name rather than the Perfetto interned ID when doing stream manipulation, as the Perfetto interned ID may not be unique. --- lglpy/timeline/data/raw_trace.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lglpy/timeline/data/raw_trace.py b/lglpy/timeline/data/raw_trace.py index da0cd83..e96a367 100644 --- a/lglpy/timeline/data/raw_trace.py +++ b/lglpy/timeline/data/raw_trace.py @@ -878,6 +878,13 @@ def load_perfetto_from_file( # Sort events into time order trace_events.sort(key=lambda x: x.start_time) + # Replace all interned data cross-references to assign real stream + # names before trying to use streams because we may get more than one + # interned ID for the same physical stream and this will dedupe them + for event in trace_events: + config.replace_interned_stream(event) + config.replace_interned_stage(event) + # Replace time so first event starts at time = 0 and that queued time # waiting for earlier work does not show as running streams = {} @@ -893,7 +900,6 @@ def load_perfetto_from_file( # Later job in stream so remove any overlap with job N-1 last_event = streams[event.stream][-1] last_event_end = last_event.start_time + last_event.duration - streams[event.stream].append(event) # Remove overlap if queued while last event still running if event.start_time <= last_event_end: @@ -901,10 +907,12 @@ def load_perfetto_from_file( event.start_time += time_diff event.duration -= time_diff - # Replace all interned data cross-references - for event in trace_events: - config.replace_interned_stream(event) - config.replace_interned_stage(event) + # Ensure we don't have negative duration events + if event.duration <= 0: + event.duration = 1 + + # Add event to the stream after patching it + streams[event.stream].append(event) return (trace_events, start_time) From ce71f4145e163560f3b4ef5d9076dc26c37db57e Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Fri, 13 Jun 2025 22:07:36 +0100 Subject: [PATCH 2/2] Fix mypy typing ambiguity --- lglpy/timeline/data/processed_trace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lglpy/timeline/data/processed_trace.py b/lglpy/timeline/data/processed_trace.py index f7ac7c5..77ce3ba 100644 --- a/lglpy/timeline/data/processed_trace.py +++ b/lglpy/timeline/data/processed_trace.py @@ -77,7 +77,7 @@ def __init__( # Common data we get from the layer metadata self.submit = None self.label_stack = None - self.parsed_label_name = None + self.parsed_label_name: Optional[str] = None if metadata: self.submit = metadata.submit