• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1-- Copyright 2024 The Chromium Authors
2-- Use of this source code is governed by a BSD-style license that can be
3-- found in the LICENSE file.
4
5INCLUDE PERFETTO MODULE slices.with_context;
6INCLUDE PERFETTO MODULE chrome.android_input;
7
8-- Processing steps of the Chrome input pipeline.
9CREATE PERFETTO TABLE _chrome_input_pipeline_steps_no_input_type(
10  -- Id of this Chrome input pipeline (LatencyInfo).
11  latency_id LONG,
12  -- Slice id
13  slice_id LONG,
14  -- The step timestamp.
15  ts TIMESTAMP,
16  -- Step duration.
17  dur DURATION,
18  -- Utid of the thread.
19  utid LONG,
20  -- Step name (ChromeLatencyInfo.step).
21  step STRING,
22  -- Input type.
23  input_type STRING,
24  -- Start time of the parent Chrome scheduler task (if any) of this step.
25  task_start_time_ts TIMESTAMP
26) AS
27SELECT
28  EXTRACT_ARG(thread_slice.arg_set_id, 'chrome_latency_info.trace_id') AS latency_id,
29  id AS slice_id,
30  ts,
31  dur,
32  utid,
33  EXTRACT_ARG(thread_slice.arg_set_id, 'chrome_latency_info.step') AS step,
34  EXTRACT_ARG(thread_slice.arg_set_id, 'chrome_latency_info.input_type') AS input_type,
35  ts - (EXTRACT_ARG(thread_slice.arg_set_id, 'current_task.event_offset_from_task_start_time_us') * 1000) AS task_start_time_ts
36FROM
37  thread_slice
38WHERE
39  step IS NOT NULL
40  AND latency_id != -1
41ORDER BY slice_id, ts;
42
43-- Each row represents one input pipeline.
44CREATE PERFETTO TABLE chrome_inputs(
45  -- Id of this Chrome input pipeline (LatencyInfo).
46  latency_id LONG,
47   -- Input type.
48  input_type STRING
49) AS
50SELECT
51  -- Id of this Chrome input pipeline (LatencyInfo).
52  latency_id,
53  -- MIN selects the first non-null value.
54  MIN(input_type) as input_type
55FROM _chrome_input_pipeline_steps_no_input_type
56WHERE latency_id != -1
57GROUP BY latency_id;
58
59-- Since not all steps have associated input type (but all steps
60-- for a given latency id should have the same input type),
61-- populate input type for steps where it would be NULL.
62CREATE PERFETTO TABLE chrome_input_pipeline_steps(
63  -- Id of this Chrome input pipeline (LatencyInfo).
64  latency_id LONG,
65  -- Slice id
66  slice_id LONG,
67  -- The step timestamp.
68  ts TIMESTAMP,
69  -- Step duration.
70  dur DURATION,
71  -- Utid of the thread.
72  utid LONG,
73  -- Step name (ChromeLatencyInfo.step).
74  step STRING,
75  -- Input type.
76  input_type STRING,
77  -- Start time of the parent Chrome scheduler task (if any) of this step.
78  task_start_time_ts TIMESTAMP
79) AS
80SELECT
81  latency_id,
82  slice_id,
83  ts,
84  dur,
85  utid,
86  step,
87  chrome_inputs.input_type AS input_type,
88  task_start_time_ts
89FROM
90  chrome_inputs
91LEFT JOIN
92  _chrome_input_pipeline_steps_no_input_type
93  USING (latency_id)
94WHERE chrome_inputs.input_type IS NOT NULL;
95
96-- For each input, get the latency id of the input that it was coalesced into.
97CREATE PERFETTO TABLE chrome_coalesced_inputs(
98  -- The `latency_id` of the coalesced input.
99  coalesced_latency_id LONG,
100  -- The `latency_id` of the input that the current input was coalesced into.
101  presented_latency_id LONG
102) AS
103SELECT
104  args.int_value AS coalesced_latency_id,
105  latency_id AS presented_latency_id
106FROM chrome_input_pipeline_steps step
107JOIN slice USING (slice_id)
108JOIN args USING (arg_set_id)
109WHERE step.step = 'STEP_RESAMPLE_SCROLL_EVENTS'
110  AND args.flat_key = 'chrome_latency_info.coalesced_trace_ids';
111
112-- Slices with information about non-blocking touch move inputs
113-- that were converted into gesture scroll updates.
114CREATE PERFETTO TABLE chrome_touch_move_to_scroll_update(
115  -- Latency id of the touch move input (LatencyInfo).
116  touch_move_latency_id LONG,
117  -- Latency id of the corresponding scroll update input (LatencyInfo).
118  scroll_update_latency_id LONG
119) AS
120SELECT
121  scroll_update_step.latency_id AS scroll_update_latency_id,
122  touch_move_step.latency_id AS touch_move_latency_id
123FROM chrome_input_pipeline_steps scroll_update_step
124JOIN ancestor_slice(scroll_update_step.slice_id) AS ancestor
125JOIN chrome_input_pipeline_steps touch_move_step
126  ON ancestor.id = touch_move_step.slice_id
127WHERE scroll_update_step.step = 'STEP_SEND_INPUT_EVENT_UI'
128AND scroll_update_step.input_type = 'GESTURE_SCROLL_UPDATE_EVENT'
129AND touch_move_step.step = 'STEP_TOUCH_EVENT_HANDLED';
130
131-- Matches Android input id to the corresponding touch move event.
132CREATE PERFETTO TABLE chrome_dispatch_android_input_event_to_touch_move(
133  -- Input id (assigned by the system, used by InputReader and InputDispatcher)
134  android_input_id STRING,
135  -- Latency id.
136  touch_move_latency_id LONG
137) AS
138SELECT
139  chrome_deliver_android_input_event.android_input_id,
140  latency_id AS touch_move_latency_id
141FROM
142  chrome_deliver_android_input_event
143LEFT JOIN
144  chrome_input_pipeline_steps USING (utid)
145WHERE
146  chrome_input_pipeline_steps.input_type = 'TOUCH_MOVE_EVENT'
147  AND chrome_input_pipeline_steps.step = 'STEP_SEND_INPUT_EVENT_UI'
148  AND chrome_deliver_android_input_event.ts <= chrome_input_pipeline_steps.ts
149  AND chrome_deliver_android_input_event.ts + chrome_deliver_android_input_event.dur >=
150    chrome_input_pipeline_steps.ts + chrome_input_pipeline_steps.dur;
151