• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1-- Copyright 2023 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 chrome.event_latency;
6INCLUDE PERFETTO MODULE chrome.graphics_pipeline;
7INCLUDE PERFETTO MODULE chrome.input;
8INCLUDE PERFETTO MODULE chrome.scroll_jank.utils;
9
10-- Ties together input (`LatencyInfo.Flow`) and frame (`Graphics.Pipeline`)
11-- trace events. Only covers input events of the `GESTURE_SCROLL_UPDATE_EVENT`
12-- type.
13CREATE PERFETTO TABLE _chrome_scroll_update_refs(
14  -- Id of the Chrome input pipeline (`LatencyInfo.Flow`).
15  scroll_update_latency_id LONG,
16  -- Id of the touch move input corresponding to this scroll update.
17  touch_move_latency_id LONG,
18  -- Id of the frame pipeline (`Graphics.Pipeline`), pre-surface aggregation.
19  surface_frame_id LONG,
20  -- Id of the frame pipeline (`Graphics.Pipeline`), post-surface aggregation.
21  display_trace_id LONG)
22AS
23SELECT
24  scroll_update.latency_id AS scroll_update_latency_id,
25  chrome_touch_move_to_scroll_update.touch_move_latency_id,
26  chrome_graphics_pipeline_inputs_to_surface_frames.surface_frame_trace_id
27    AS surface_frame_id,
28  chrome_graphics_pipeline_aggregated_frames.display_trace_id
29FROM
30  chrome_inputs scroll_update
31LEFT JOIN chrome_graphics_pipeline_inputs_to_surface_frames
32  USING (latency_id)
33LEFT JOIN chrome_graphics_pipeline_aggregated_frames
34  ON
35    chrome_graphics_pipeline_aggregated_frames.surface_frame_trace_id
36    = chrome_graphics_pipeline_inputs_to_surface_frames.surface_frame_trace_id
37LEFT JOIN chrome_touch_move_to_scroll_update
38  ON
39    chrome_touch_move_to_scroll_update.scroll_update_latency_id
40    = scroll_update.latency_id
41WHERE scroll_update.input_type = 'GESTURE_SCROLL_UPDATE_EVENT';
42
43-- Timestamps and other related information for events during the critical path
44-- for scrolling.
45CREATE PERFETTO TABLE _scroll_update_timestamps_and_metadata
46AS
47SELECT
48  refs.scroll_update_latency_id AS id,
49  chrome_coalesced_input.presented_latency_id AS coalesced_into,
50  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
51  chrome_event_latency.vsync_interval_ms AS vsync_interval_ms,
52  chrome_event_latency.is_presented AS is_presented,
53  chrome_event_latency.is_janky_scrolled_frame AS is_janky,
54  chrome_event_latency.event_type
55    = 'INERTIAL_GESTURE_SCROLL_UPDATE' AS is_inertial,
56  chrome_event_latency.ts AS generation_ts,
57  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
58  touch_move_received_step.slice_id AS touch_move_received_slice_id,
59  touch_move_received_step.ts AS touch_move_received_ts,
60  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
61  touch_move_processed_step.slice_id AS touch_move_processed_slice_id,
62  touch_move_processed_step.ts AS touch_move_processed_ts,
63  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
64  scroll_update_created_step.slice_id AS scroll_update_created_slice_id,
65  scroll_update_created_step.utid AS browser_utid,
66  scroll_update_created_step.ts AS scroll_update_created_ts,
67  scroll_update_created_step.ts + scroll_update_created_step.dur
68    AS scroll_update_created_end_ts,
69  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70  compositor_dispatch_step.slice_id AS compositor_dispatch_slice_id,
71  compositor_dispatch_step.task_start_time_ts
72    AS compositor_dispatch_task_ts,
73  compositor_dispatch_step.ts AS compositor_dispatch_ts,
74  compositor_dispatch_step.ts + compositor_dispatch_step.dur
75    AS compositor_dispatch_end_ts,
76  compositor_dispatch_step.utid AS compositor_utid,
77  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
78  compositor_resample_step.slice_id AS compositor_resample_slice_id,
79  compositor_resample_step.task_start_time_ts
80    AS compositor_resample_task_ts,
81  compositor_resample_step.ts AS compositor_resample_ts,
82  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
83  compositor_coalesced_input_handled_step.slice_id
84    AS compositor_coalesced_input_handled_slice_id,
85  compositor_coalesced_input_handled_step.ts
86    AS compositor_coalesced_input_handled_ts,
87  compositor_coalesced_input_handled_step.ts
88    + compositor_coalesced_input_handled_step.dur
89    AS compositor_coalesced_input_handled_end_ts,
90  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
91  compositor_generate_compositor_frame_step.id
92    AS compositor_generate_compositor_frame_slice_id,
93  compositor_generate_compositor_frame_step.task_start_time_ts
94    AS compositor_generate_compositor_frame_task_ts,
95  compositor_generate_compositor_frame_step.ts
96    AS compositor_generate_compositor_frame_ts,
97  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
98  compositor_submit_compositor_frame_step.id
99    AS compositor_submit_compositor_frame_slice_id,
100  compositor_submit_compositor_frame_step.ts
101    AS compositor_submit_compositor_frame_ts,
102  compositor_submit_compositor_frame_step.ts
103    + compositor_submit_compositor_frame_step.dur
104    AS compositor_submit_compositor_frame_end_ts,
105  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
106  viz_receive_compositor_frame_step.id
107    AS viz_receive_compositor_frame_slice_id,
108  viz_receive_compositor_frame_step.task_start_time_ts
109    AS viz_receive_compositor_frame_task_ts,
110  viz_receive_compositor_frame_step.ts AS viz_receive_compositor_frame_ts,
111  viz_receive_compositor_frame_step.ts
112    + viz_receive_compositor_frame_step.dur
113    AS viz_receive_compositor_frame_end_ts,
114  viz_receive_compositor_frame_step.utid AS viz_compositor_utid,
115  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
116  viz_draw_and_swap_step.id AS viz_draw_and_swap_slice_id,
117  viz_draw_and_swap_step.task_start_time_ts
118    AS viz_draw_and_swap_task_ts,
119  viz_draw_and_swap_step.ts AS viz_draw_and_swap_ts,
120  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
121  viz_send_buffer_swap_step.id AS viz_send_buffer_swap_slice_id,
122  viz_send_buffer_swap_step.ts + viz_send_buffer_swap_step.dur
123    AS viz_send_buffer_swap_end_ts,
124  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
125  viz_swap_buffers_step.id AS viz_swap_buffers_slice_id,
126  viz_swap_buffers_step.task_start_time_ts AS viz_swap_buffers_task_ts,
127  viz_swap_buffers_step.ts AS viz_swap_buffers_ts,
128  viz_swap_buffers_step.ts + viz_swap_buffers_step.dur
129    AS viz_swap_buffers_end_ts,
130  viz_swap_buffers_step.utid AS viz_gpu_thread_utid,
131  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
132  chrome_event_latency.buffer_available_timestamp,
133  chrome_event_latency.buffer_ready_timestamp,
134  chrome_event_latency.latch_timestamp,
135  chrome_event_latency.swap_end_timestamp,
136  chrome_event_latency.presentation_timestamp
137FROM _chrome_scroll_update_refs refs
138LEFT JOIN chrome_coalesced_inputs chrome_coalesced_input
139  ON chrome_coalesced_input.coalesced_latency_id = refs.scroll_update_latency_id
140-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
141LEFT JOIN chrome_event_latencies chrome_event_latency
142  ON chrome_event_latency.scroll_update_id = refs.scroll_update_latency_id
143-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
144LEFT JOIN chrome_input_pipeline_steps touch_move_received_step
145  ON
146    refs.touch_move_latency_id = touch_move_received_step.latency_id
147    AND touch_move_received_step.step = 'STEP_SEND_INPUT_EVENT_UI'
148    AND touch_move_received_step.input_type = 'TOUCH_MOVE_EVENT'
149-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
150LEFT JOIN chrome_input_pipeline_steps touch_move_processed_step
151  ON
152    touch_move_processed_step.latency_id = refs.touch_move_latency_id
153    AND touch_move_processed_step.step = 'STEP_TOUCH_EVENT_HANDLED'
154    AND touch_move_processed_step.input_type = 'TOUCH_MOVE_EVENT'
155-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
156LEFT JOIN chrome_input_pipeline_steps scroll_update_created_step
157  ON
158    scroll_update_created_step.latency_id = refs.scroll_update_latency_id
159    AND scroll_update_created_step.step = 'STEP_SEND_INPUT_EVENT_UI'
160    AND scroll_update_created_step.input_type
161      = 'GESTURE_SCROLL_UPDATE_EVENT'
162-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
163LEFT JOIN chrome_input_pipeline_steps compositor_dispatch_step
164  ON
165    compositor_dispatch_step.latency_id = refs.scroll_update_latency_id
166    AND compositor_dispatch_step.step = 'STEP_HANDLE_INPUT_EVENT_IMPL'
167    AND compositor_dispatch_step.input_type
168      = 'GESTURE_SCROLL_UPDATE_EVENT'
169-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
170LEFT JOIN chrome_input_pipeline_steps compositor_resample_step
171  ON
172    compositor_resample_step.latency_id = refs.scroll_update_latency_id
173    AND compositor_resample_step.step = 'STEP_RESAMPLE_SCROLL_EVENTS'
174    AND compositor_resample_step.input_type
175      = 'GESTURE_SCROLL_UPDATE_EVENT'
176-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
177LEFT JOIN chrome_input_pipeline_steps compositor_coalesced_input_handled_step
178  ON
179    compositor_coalesced_input_handled_step.latency_id
180      = refs.scroll_update_latency_id
181    AND compositor_coalesced_input_handled_step.step
182      = 'STEP_DID_HANDLE_INPUT_AND_OVERSCROLL'
183    AND compositor_coalesced_input_handled_step.input_type
184      = 'GESTURE_SCROLL_UPDATE_EVENT'
185-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
186LEFT JOIN
187  chrome_graphics_pipeline_surface_frame_steps
188    compositor_generate_compositor_frame_step
189  ON
190    compositor_generate_compositor_frame_step.surface_frame_trace_id
191      = refs.surface_frame_id
192    AND compositor_generate_compositor_frame_step.step
193      = 'STEP_GENERATE_COMPOSITOR_FRAME'
194-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
195LEFT JOIN
196  chrome_graphics_pipeline_surface_frame_steps
197    compositor_submit_compositor_frame_step
198  ON
199    compositor_submit_compositor_frame_step.surface_frame_trace_id
200      = refs.surface_frame_id
201    AND compositor_submit_compositor_frame_step.step
202      = 'STEP_SUBMIT_COMPOSITOR_FRAME'
203-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
204LEFT JOIN
205  chrome_graphics_pipeline_surface_frame_steps
206    viz_receive_compositor_frame_step
207  ON
208    viz_receive_compositor_frame_step.surface_frame_trace_id
209      = refs.surface_frame_id
210    AND viz_receive_compositor_frame_step.step
211      = 'STEP_RECEIVE_COMPOSITOR_FRAME'
212-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
213LEFT JOIN
214  chrome_graphics_pipeline_display_frame_steps viz_draw_and_swap_step
215  ON
216    viz_draw_and_swap_step.display_trace_id = refs.display_trace_id
217    AND viz_draw_and_swap_step.step = 'STEP_DRAW_AND_SWAP'
218-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
219LEFT JOIN
220  chrome_graphics_pipeline_display_frame_steps viz_send_buffer_swap_step
221  ON
222    viz_send_buffer_swap_step.display_trace_id = refs.display_trace_id
223    AND viz_send_buffer_swap_step.step = 'STEP_SEND_BUFFER_SWAP'
224-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
225LEFT JOIN chrome_graphics_pipeline_display_frame_steps viz_swap_buffers_step
226  ON
227    viz_swap_buffers_step.display_trace_id = refs.display_trace_id
228    AND viz_swap_buffers_step.step = 'STEP_BUFFER_SWAP_POST_SUBMIT';
229
230-- Intermediate helper table with timestamps and slice ids for the critical path
231-- stages during scrolling.
232CREATE PERFETTO TABLE _scroll_update_durations_and_metadata
233AS
234SELECT
235  id,
236  vsync_interval_ms,
237  is_presented,
238  is_janky,
239  is_inertial,
240  coalesced_into IS NOT NULL AS is_coalesced,
241  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
242  -- Ids
243  browser_utid,
244  touch_move_received_slice_id,
245  -- Timestamps
246  generation_ts,
247  touch_move_received_ts,
248  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
249  -- Ids
250  scroll_update_created_slice_id,
251  -- Timestamps
252  scroll_update_created_ts,
253  scroll_update_created_end_ts,
254  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
255  -- Ids
256  compositor_utid,
257  compositor_dispatch_slice_id,
258  -- Timestamps
259  COALESCE(compositor_dispatch_task_ts, compositor_dispatch_ts)
260    AS compositor_dispatch_ts,
261  compositor_dispatch_end_ts,
262  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
263  -- Ids
264  compositor_resample_slice_id,
265  compositor_coalesced_input_handled_slice_id,
266  -- Timestamps
267  COALESCE(
268    compositor_resample_task_ts,
269    compositor_resample_ts,
270    compositor_coalesced_input_handled_ts) AS compositor_on_begin_frame_ts,
271  compositor_coalesced_input_handled_end_ts AS compositor_on_begin_frame_end_ts,
272  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
273  -- Ids
274  compositor_generate_compositor_frame_slice_id,
275  -- Timestamps
276  COALESCE(
277    compositor_generate_compositor_frame_task_ts,
278    compositor_generate_compositor_frame_ts)
279    AS compositor_generate_compositor_frame_ts,
280  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
281  -- Ids
282  compositor_submit_compositor_frame_slice_id,
283  -- Timestamps
284  compositor_submit_compositor_frame_ts,
285  compositor_submit_compositor_frame_end_ts,
286  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
287  -- Ids
288  viz_compositor_utid,
289  viz_receive_compositor_frame_slice_id,
290  -- Timestamps
291  COALESCE(
292    viz_receive_compositor_frame_task_ts, viz_receive_compositor_frame_ts)
293    AS viz_receive_compositor_frame_ts,
294  viz_receive_compositor_frame_end_ts,
295  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
296  -- Ids
297  viz_draw_and_swap_slice_id,
298  -- Timestamps
299  COALESCE(viz_draw_and_swap_task_ts, viz_draw_and_swap_ts)
300    AS viz_draw_and_swap_ts,
301  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
302  -- Ids
303  viz_send_buffer_swap_slice_id,
304  -- Timestamps
305  viz_send_buffer_swap_end_ts,
306  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
307  -- Ids
308  viz_gpu_thread_utid,
309  viz_swap_buffers_slice_id,
310  -- Timestamps
311  COALESCE(viz_swap_buffers_task_ts, viz_swap_buffers_ts)
312    AS viz_swap_buffers_ts,
313  viz_swap_buffers_end_ts,
314  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
315  -- Timestamps
316  latch_timestamp,
317  swap_end_timestamp,
318  presentation_timestamp
319FROM _scroll_update_timestamps_and_metadata;
320
321-- Defines slices for all of the individual scrolls in a trace based on the
322-- LatencyInfo-based scroll definition.
323--
324-- NOTE: this view of top level scrolls is based on the LatencyInfo definition
325-- of a scroll, which differs subtly from the definition based on
326-- EventLatencies.
327-- TODO(b/278684408): add support for tracking scrolls across multiple Chrome/
328-- WebView instances. Currently gesture_scroll_id unique within an instance, but
329-- is not unique across multiple instances. Switching to an EventLatency based
330-- definition of scrolls should resolve this.
331CREATE PERFETTO TABLE chrome_scrolls(
332  -- The unique identifier of the scroll.
333  id LONG,
334  -- The start timestamp of the scroll.
335  ts TIMESTAMP,
336  -- The duration of the scroll.
337  dur DURATION,
338  -- The earliest timestamp of the EventLatency slice of the GESTURE_SCROLL_BEGIN type for the
339  -- corresponding scroll id.
340  gesture_scroll_begin_ts TIMESTAMP,
341  -- The earliest timestamp of the EventLatency slice of the GESTURE_SCROLL_END type /
342  -- the latest timestamp of the EventLatency slice of the GESTURE_SCROLL_UPDATE type for the
343  -- corresponding scroll id.
344  gesture_scroll_end_ts TIMESTAMP
345) AS
346WITH all_scrolls AS (
347  SELECT
348    event_type AS name,
349    ts,
350    dur,
351    scroll_id
352  FROM chrome_gesture_scroll_events
353),
354scroll_starts AS (
355  SELECT
356    scroll_id,
357    MIN(ts) AS gesture_scroll_begin_ts
358  FROM all_scrolls
359  WHERE name = 'GESTURE_SCROLL_BEGIN'
360  GROUP BY scroll_id
361),
362scroll_ends AS (
363  SELECT
364    scroll_id,
365    MAX(ts) AS gesture_scroll_end_ts
366  FROM all_scrolls
367  WHERE name IN (
368    'GESTURE_SCROLL_UPDATE',
369    'FIRST_GESTURE_SCROLL_UPDATE',
370    'INERTIAL_GESTURE_SCROLL_UPDATE',
371    'GESTURE_SCROLL_END'
372  )
373  GROUP BY scroll_id
374)
375SELECT
376  sa.scroll_id AS id,
377  MIN(ts) AS ts,
378  cast_int!(MAX(ts + dur) - MIN(ts)) AS dur,
379  ss.gesture_scroll_begin_ts AS gesture_scroll_begin_ts,
380  se.gesture_scroll_end_ts AS gesture_scroll_end_ts
381FROM all_scrolls sa
382  LEFT JOIN scroll_starts ss ON
383    sa.scroll_id = ss.scroll_id
384  LEFT JOIN scroll_ends se ON
385    sa.scroll_id = se.scroll_id
386GROUP BY sa.scroll_id;
387
388-- Timestamps and durations for the critical path stages during scrolling.
389CREATE PERFETTO TABLE chrome_scroll_update_info(
390  -- Id of the `LatencyInfo.Flow` slices corresponding to this scroll event.
391  id LONG,
392  -- Vsync interval (in milliseconds).
393  vsync_interval_ms DOUBLE,
394  -- Whether this input event was presented.
395  is_presented BOOL,
396  -- Whether the corresponding frame is janky. This comes directly from
397  -- `perfetto.protos.EventLatency`.
398  is_janky BOOL,
399  -- Whether the corresponding scroll is inertial (fling).
400  -- If this is `true`, "generation" and "touch_move" related timestamps and
401  -- durations will be null.
402  is_inertial BOOL,
403  -- Whether the corresponding input event was coalesced into another.
404  is_coalesced BOOL,
405  -- Input generation timestamp (from the Android system).
406  generation_ts TIMESTAMP,
407  -- Duration from input generation to when the browser received the input.
408  generation_to_browser_main_dur DURATION,
409  -- Utid for the browser main thread.
410  browser_utid LONG,
411  -- Slice id for the `STEP_SEND_INPUT_EVENT_UI` slice for the touch move.
412  touch_move_received_slice_id LONG,
413  -- Timestamp for the `STEP_SEND_INPUT_EVENT_UI` slice for the touch move.
414  touch_move_received_ts TIMESTAMP,
415  -- Duration for processing  a `TouchMove` event.
416  touch_move_processing_dur DURATION,
417  -- Slice id for the `STEP_SEND_INPUT_EVENT_UI` slice for the gesture scroll.
418  scroll_update_created_slice_id LONG,
419  -- Timestamp for the `STEP_SEND_INPUT_EVENT_UI` slice for the gesture scroll.
420  scroll_update_created_ts TIMESTAMP,
421  -- Duration for creating a `GestureScrollUpdate` from a `TouchMove` event.
422  scroll_update_processing_dur DURATION,
423  -- End timestamp for the `STEP_SEND_INPUT_EVENT_UI` slice for the above.
424  scroll_update_created_end_ts TIMESTAMP,
425  -- Duration between the browser and compositor dispatch.
426  browser_to_compositor_delay_dur DURATION,
427  -- Utid for the renderer compositor thread.
428  compositor_utid LONG,
429  -- Slice id for the `STEP_HANDLE_INPUT_EVENT_IMPL` slice.
430  compositor_dispatch_slice_id LONG,
431  -- Timestamp for the `STEP_HANDLE_INPUT_EVENT_IMPL` slice or the
432  -- containing task (if available).
433  compositor_dispatch_ts TIMESTAMP,
434  -- Duration for the compositor dispatch itself.
435  compositor_dispatch_dur DURATION,
436  -- End timestamp for the `STEP_HANDLE_INPUT_EVENT_IMPL` slice.
437  compositor_dispatch_end_ts TIMESTAMP,
438  -- Duration between compositor dispatch and input resampling work.
439  compositor_dispatch_to_on_begin_frame_delay_dur DURATION,
440  -- Slice id for the `STEP_RESAMPLE_SCROLL_EVENTS` slice.
441  compositor_resample_slice_id LONG,
442  -- Slice id for the `STEP_DID_HANDLE_INPUT_AND_OVERSCROLL` slice.
443  compositor_coalesced_input_handled_slice_id LONG,
444  -- Start timestamp for work done on the input during "OnBeginFrame".
445  compositor_on_begin_frame_ts TIMESTAMP,
446  -- Duration of the "OnBeginFrame" work for this input.
447  compositor_on_begin_frame_dur DURATION,
448  -- End timestamp for work done on the input during "OnBeginFrame".
449  compositor_on_begin_frame_end_ts TIMESTAMP,
450  -- Delay until the compositor work for generating the frame begins.
451  compositor_on_begin_frame_to_generation_delay_dur DURATION,
452  -- Slice id for the `STEP_GENERATE_COMPOSITOR_FRAME` slice.
453  compositor_generate_compositor_frame_slice_id LONG,
454  -- Timestamp for the `STEP_GENERATE_COMPOSITOR_FRAME` slice or the
455  -- containing task (if available).
456  compositor_generate_compositor_frame_ts TIMESTAMP,
457  -- Duration between generating and submitting the compositor frame.
458  compositor_generate_frame_to_submit_frame_dur DURATION,
459  -- Slice id for the `STEP_SUBMIT_COMPOSITOR_FRAME` slice.
460  compositor_submit_compositor_frame_slice_id LONG,
461  -- Timestamp for the `STEP_SUBMIT_COMPOSITOR_FRAME` slice.
462  compositor_submit_compositor_frame_ts TIMESTAMP,
463  -- Duration for submitting the compositor frame (to viz).
464  compositor_submit_frame_dur DURATION,
465  -- End timestamp for the `STEP_SUBMIT_COMPOSITOR_FRAME` slice.
466  compositor_submit_compositor_frame_end_ts TIMESTAMP,
467  -- Delay when a compositor frame is sent from the renderer to viz.
468  compositor_to_viz_delay_dur DURATION,
469  -- Utid for the viz compositor thread.
470  viz_compositor_utid LONG,
471  -- Slice id for the `STEP_RECEIVE_COMPOSITOR_FRAME` slice.
472  viz_receive_compositor_frame_slice_id LONG,
473  -- Timestamp for the `STEP_RECEIVE_COMPOSITOR_FRAME` slice or the
474  -- containing task (if available).
475  viz_receive_compositor_frame_ts TIMESTAMP,
476  -- Duration of the viz work done on receiving the compositor frame.
477  viz_receive_compositor_frame_dur DURATION,
478  -- End timestamp for the `STEP_RECEIVE_COMPOSITOR_FRAME` slice.
479  viz_receive_compositor_frame_end_ts TIMESTAMP,
480  -- Duration between viz receiving the compositor frame to frame draw.
481  viz_wait_for_draw_dur DURATION,
482  -- Slice id for the `STEP_DRAW_AND_SWAP` slice.
483  viz_draw_and_swap_slice_id LONG,
484  -- Timestamp for the `STEP_DRAW_AND_SWAP` slice or the
485  -- containing task (if available).
486  viz_draw_and_swap_ts TIMESTAMP,
487  -- Duration for the viz drawing/swapping work for this frame.
488  viz_draw_and_swap_dur DURATION,
489  -- Slice id for the `STEP_SEND_BUFFER_SWAP` slice.
490  viz_send_buffer_swap_slice_id LONG,
491  -- End timestamp for the `STEP_SEND_BUFFER_SWAP` slice.
492  viz_send_buffer_swap_end_ts TIMESTAMP,
493  -- Delay between viz work on compositor thread and `CompositorGpuThread`.
494  viz_to_gpu_delay_dur DURATION,
495  -- Utid for the viz `CompositorGpuThread`.
496  viz_gpu_thread_utid LONG,
497  -- Slice id for the `STEP_BUFFER_SWAP_POST_SUBMIT` slice.
498  viz_swap_buffers_slice_id LONG,
499  -- Timestamp for the `STEP_BUFFER_SWAP_POST_SUBMIT` slice or the
500  -- containing task (if available).
501  viz_swap_buffers_ts TIMESTAMP,
502  -- Duration of frame buffer swapping work on viz.
503  viz_swap_buffers_dur DURATION,
504  -- End timestamp for the `STEP_BUFFER_SWAP_POST_SUBMIT` slice.
505  viz_swap_buffers_end_ts TIMESTAMP,
506  -- Duration of `EventLatency`'s `BufferReadyToLatch` step.
507  viz_swap_buffers_to_latch_dur DURATION,
508  -- Timestamp for `EventLatency`'s `LatchToSwapEnd` step.
509  latch_timestamp TIMESTAMP,
510  -- Duration of `EventLatency`'s `LatchToSwapEnd` step.
511  viz_latch_to_swap_end_dur DURATION,
512  -- Timestamp for `EventLatency`'s `SwapEndToPresentationCompositorFrame` step.
513  swap_end_timestamp TIMESTAMP,
514  -- Duration of `EventLatency`'s `SwapEndToPresentationCompositorFrame` step.
515  swap_end_to_presentation_dur DURATION,
516  -- Presentation timestamp for the frame.
517  presentation_timestamp TIMESTAMP)
518AS
519SELECT
520  id,
521  -- TODO(b:380868337): This is sometimes unexpectedly 0; check/fix this.
522  vsync_interval_ms,
523  is_presented,
524  is_janky,
525  is_inertial,
526  -- TODO(b:380868337): Check/fix this for flings.
527  is_coalesced,
528  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
529  -- No applicable utid (duration between two threads).
530  -- No applicable slice id (duration between two threads).
531  generation_ts,
532  touch_move_received_ts - generation_ts AS generation_to_browser_main_dur,
533  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
534  browser_utid,
535  touch_move_received_slice_id,
536  touch_move_received_ts,
537  scroll_update_created_ts - touch_move_received_ts
538    AS touch_move_processing_dur,
539  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
540  -- On `browser_utid`.
541  scroll_update_created_slice_id,
542  scroll_update_created_ts,
543  scroll_update_created_end_ts - scroll_update_created_ts
544    AS scroll_update_processing_dur,
545  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
546  -- No applicable utid (duration between two threads).
547  -- No applicable slice id (duration between two threads).
548  scroll_update_created_end_ts,
549  -- TODO(b:380868337): This is sometimes negative; check/fix this.
550  compositor_dispatch_ts - scroll_update_created_end_ts
551    AS browser_to_compositor_delay_dur,
552  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
553  compositor_utid,
554  compositor_dispatch_slice_id,
555  compositor_dispatch_ts,
556  compositor_dispatch_end_ts - compositor_dispatch_ts
557    AS compositor_dispatch_dur,
558  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
559  -- On `compositor_utid`.
560  -- No applicable slice id (duration between two slices).
561  compositor_dispatch_end_ts,
562  -- TODO(b:380868337): This is sometimes negative; check/fix this.
563  compositor_on_begin_frame_ts - compositor_dispatch_end_ts
564    AS compositor_dispatch_to_on_begin_frame_delay_dur,
565  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
566  -- On `compositor_utid`.
567  -- `compositor_on_begin_frame_dur` can depend on two slices.
568  compositor_resample_slice_id,
569  compositor_coalesced_input_handled_slice_id,
570  compositor_on_begin_frame_ts,
571  compositor_on_begin_frame_end_ts - compositor_on_begin_frame_ts
572    AS compositor_on_begin_frame_dur,
573  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
574  -- On `compositor_utid`.
575  -- No applicable slice id (duration between two slices).
576  compositor_on_begin_frame_end_ts,
577  compositor_generate_compositor_frame_ts - compositor_on_begin_frame_end_ts
578    AS compositor_on_begin_frame_to_generation_delay_dur,
579  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
580  -- On `compositor_utid`.
581  compositor_generate_compositor_frame_slice_id,
582  -- TODO(b:380868337): This is sometimes unexpectedly null; check/fix this.
583  compositor_generate_compositor_frame_ts,
584  compositor_submit_compositor_frame_ts
585    - compositor_generate_compositor_frame_ts
586    AS compositor_generate_frame_to_submit_frame_dur,
587  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
588  -- On `compositor_utid`.
589  compositor_submit_compositor_frame_slice_id,
590  compositor_submit_compositor_frame_ts,
591  compositor_submit_compositor_frame_end_ts
592    - compositor_submit_compositor_frame_ts AS compositor_submit_frame_dur,
593  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
594  -- No applicable utid (duration between two threads).
595  -- No applicable slice id (duration between two threads).
596  compositor_submit_compositor_frame_end_ts,
597  -- TODO(b:380868337): This is sometimes negative; check/fix this.
598  viz_receive_compositor_frame_ts - compositor_submit_compositor_frame_end_ts
599    AS compositor_to_viz_delay_dur,
600  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
601  viz_compositor_utid,
602  viz_receive_compositor_frame_slice_id,
603  viz_receive_compositor_frame_ts,
604  viz_receive_compositor_frame_end_ts - viz_receive_compositor_frame_ts
605    AS viz_receive_compositor_frame_dur,
606  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
607  -- On `viz_compositor_utid`.
608  -- No applicable slice id (duration between two slices).
609  viz_receive_compositor_frame_end_ts,
610  viz_draw_and_swap_ts - viz_receive_compositor_frame_end_ts
611    AS viz_wait_for_draw_dur,
612  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
613  -- On `viz_compositor_utid`.
614  viz_draw_and_swap_slice_id,
615  viz_draw_and_swap_ts,
616  viz_send_buffer_swap_end_ts - viz_draw_and_swap_ts AS viz_draw_and_swap_dur,
617  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
618  -- No applicable utid (duration between two threads).
619  viz_send_buffer_swap_slice_id,
620  viz_send_buffer_swap_end_ts,
621  viz_swap_buffers_ts - viz_send_buffer_swap_end_ts AS viz_to_gpu_delay_dur,
622  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
623  viz_gpu_thread_utid,
624  viz_swap_buffers_slice_id,
625  viz_swap_buffers_ts,
626  viz_swap_buffers_end_ts - viz_swap_buffers_ts AS viz_swap_buffers_dur,
627  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
628  viz_swap_buffers_end_ts,
629  latch_timestamp - viz_swap_buffers_end_ts AS viz_swap_buffers_to_latch_dur,
630  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
631  latch_timestamp,
632  swap_end_timestamp - latch_timestamp AS viz_latch_to_swap_end_dur,
633  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
634  swap_end_timestamp,
635  presentation_timestamp - swap_end_timestamp AS swap_end_to_presentation_dur,
636  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
637  presentation_timestamp
638FROM _scroll_update_durations_and_metadata;
639