• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1-- Copyright 2023 The Android Open Source Project
2--
3-- Licensed under the Apache License, Version 2.0 (the "License");
4-- you may not use this file except in compliance with the License.
5-- You may obtain a copy of the License at
6--
7--     https://www.apache.org/licenses/LICENSE-2.0
8--
9-- Unless required by applicable law or agreed to in writing, software
10-- distributed under the License is distributed on an "AS IS" BASIS,
11-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-- See the License for the specific language governing permissions and
13-- limitations under the License.
14
15DROP VIEW IF EXISTS chrome_scrolls;
16
17-- Defines slices for all of the individual scrolls in a trace based on the
18-- LatencyInfo-based scroll definition.
19--
20-- @column id            The unique identifier of the scroll.
21-- @column ts            The start timestamp of the scroll.
22-- @column dur           The duration of the scroll.
23--
24-- NOTE: this view of top level scrolls is based on the LatencyInfo definition
25-- of a scroll, which differs subtly from the definition based on
26-- EventLatencies.
27-- TODO(b/278684408): add support for tracking scrolls across multiple Chrome/
28-- WebView instances. Currently gesture_scroll_id unique within an instance, but
29-- is not unique across multiple instances. Switching to an EventLatency based
30-- definition of scrolls should resolve this.
31CREATE VIEW chrome_scrolls AS
32WITH all_scrolls AS (
33  SELECT
34    name,
35    ts,
36    dur,
37    extract_arg(arg_set_id, 'chrome_latency_info.gesture_scroll_id') AS scroll_id
38  FROM slice
39  WHERE name GLOB 'InputLatency::GestureScroll*'
40  AND extract_arg(arg_set_id, 'chrome_latency_info.gesture_scroll_id') IS NOT NULL
41),
42scroll_starts AS (
43  SELECT
44    scroll_id,
45    MIN(ts) AS scroll_start_ts
46  FROM all_scrolls
47  WHERE name = 'InputLatency::GestureScrollBegin'
48  GROUP BY scroll_id
49), scroll_ends AS (
50  SELECT
51    scroll_id,
52    MIN(ts) AS scroll_end_ts
53  FROM all_scrolls
54  WHERE name = 'InputLatency::GestureScrollEnd'
55  GROUP BY scroll_id
56)
57SELECT
58  sa.scroll_id AS id,
59  MIN(ts) AS ts,
60  CAST(MAX(ts + dur) - MIN(ts) AS INT) AS dur,
61  IFNULL(ss.scroll_start_ts, -1) AS scroll_start_ts,
62  IFNULL(se.scroll_end_ts, -1) AS scroll_end_ts
63FROM all_scrolls sa
64  LEFT JOIN scroll_starts ss ON
65    sa.scroll_id = ss.scroll_id
66  LEFT JOIN scroll_ends se ON
67    sa.scroll_id = se.scroll_id
68GROUP BY sa.scroll_id;