1-- 2-- Copyright 2021 The Android Open Source Project 3-- 4-- Licensed under the Apache License, Version 2.0 (the "License"); 5-- you may not use this file except in compliance with the License. 6-- You may obtain a copy of the License at 7-- 8-- https://www.apache.org/licenses/LICENSE-2.0 9-- 10-- Unless required by applicable law or agreed to in writing, software 11-- distributed under the License is distributed on an "AS IS" BASIS, 12-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13-- See the License for the specific language governing permissions and 14-- limitations under the License. 15 16-- Find all dropped frames, i.e. all PipelineReporters slices whose 17-- state is 'STATE_DROPPED'. 18DROP VIEW IF EXISTS dropped_pipeline_reporter_slice; 19CREATE VIEW dropped_pipeline_reporter_slice AS 20SELECT slice.* FROM slice 21INNER JOIN args 22ON slice.arg_set_id = args.arg_set_id 23WHERE 24 slice.name = 'PipelineReporter' AND 25 args.string_value = 'STATE_DROPPED'; 26 27-- Find the upid of the proccesses where the dropped frames occur. 28DROP VIEW IF EXISTS dropped_frames_with_upid; 29CREATE VIEW dropped_frames_with_upid AS 30SELECT 31 dropped_pipeline_reporter_slice.ts, 32 process_track.upid 33FROM dropped_pipeline_reporter_slice 34INNER JOIN process_track 35ON dropped_pipeline_reporter_slice.track_id = process_track.id; 36 37-- Find the name and pid of the processes. 38DROP VIEW IF EXISTS dropped_frames_with_process_info; 39CREATE VIEW dropped_frames_with_process_info AS 40SELECT 41 dropped_frames_with_upid.ts, 42 process.name AS process_name, 43 process.pid AS process_id 44FROM dropped_frames_with_upid 45INNER JOIN process 46ON dropped_frames_with_upid.upid = process.upid; 47 48-- Create the derived event track for dropped frames. 49-- All tracks generated from chrome_dropped_frames_event are 50-- placed under a track group named 'Dropped Frames', whose summary 51-- track is the first track ('All Processes') in chrome_dropped_frames_event. 52-- Note that the 'All Processes' track is generated only when dropped frames 53-- come from more than one origin process. 54DROP VIEW IF EXISTS chrome_dropped_frames_event; 55CREATE VIEW chrome_dropped_frames_event AS 56SELECT 57 'slice' AS track_type, 58 'All Processes' AS track_name, 59 ts, 60 0 AS dur, 61 'Dropped Frame' AS slice_name, 62 'Dropped Frames' AS group_name 63FROM dropped_frames_with_process_info 64WHERE (SELECT COUNT(DISTINCT process_id) 65 FROM dropped_frames_with_process_info) > 1 66GROUP BY ts 67UNION ALL 68SELECT 69 'slice' AS track_type, 70 process_name || ' ' || process_id AS track_name, 71 ts, 72 0 AS dur, 73 'Dropped Frame' AS slice_name, 74 'Dropped Frames' AS group_name 75FROM dropped_frames_with_process_info 76GROUP BY process_id, ts; 77 78-- Create the dropped frames metric output. 79DROP VIEW IF EXISTS chrome_dropped_frames_output; 80CREATE VIEW chrome_dropped_frames_output AS 81SELECT ChromeDroppedFrames( 82 'dropped_frame', ( 83 SELECT RepeatedField( 84 ChromeDroppedFrames_DroppedFrame( 85 'ts', ts, 86 'process_name', process_name, 87 'pid', process_id 88 ) 89 ) 90 FROM dropped_frames_with_process_info 91 ORDER BY ts 92 ) 93);