1/* 2 * Copyright (C) 2019 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 * http://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 17syntax = "proto2"; 18 19import "protos/perfetto/trace/track_event/source_location.proto"; 20 21package perfetto.protos; 22 23// Describes Chrome's Compositor scheduler's current state and associated 24// variables. 25// 26// These protos and enums were adapted from the corresponding original JSON 27// trace event for the scheduler state. In contrast to the JSON, we use strongly 28// typed enum values instead of strings for many fields, and 29// microsecond-granularity timestamps. 30// 31// The original format was generated in JSON by the code at 32// https://cs.chromium.org/chromium/src/cc/scheduler/scheduler.cc?l=870&rcl=5e15eabc9c0eec8daf94fdf78e93f13b6e3b63dd 33// 34// TODO(nuskos): Update link once we've switched to writing this proto. 35// 36// All non-delta-timestamps are absolute CLOCK_MONOTONIC timestamps. 37 38enum ChromeCompositorSchedulerAction { 39 CC_SCHEDULER_ACTION_UNSPECIFIED = 0; 40 CC_SCHEDULER_ACTION_NONE = 1; 41 CC_SCHEDULER_ACTION_SEND_BEGIN_MAIN_FRAME = 2; 42 CC_SCHEDULER_ACTION_COMMIT = 3; 43 CC_SCHEDULER_ACTION_ACTIVATE_SYNC_TREE = 4; 44 CC_SCHEDULER_ACTION_DRAW_IF_POSSIBLE = 5; 45 CC_SCHEDULER_ACTION_DRAW_FORCED = 6; 46 CC_SCHEDULER_ACTION_DRAW_ABORT = 7; 47 CC_SCHEDULER_ACTION_BEGIN_LAYER_TREE_FRAME_SINK_CREATION = 8; 48 CC_SCHEDULER_ACTION_PREPARE_TILES = 9; 49 CC_SCHEDULER_ACTION_INVALIDATE_LAYER_TREE_FRAME_SINK = 10; 50 CC_SCHEDULER_ACTION_PERFORM_IMPL_SIDE_INVALIDATION = 11; 51 CC_SCHEDULER_ACTION_NOTIFY_BEGIN_MAIN_FRAME_NOT_EXPECTED_UNTIL = 12; 52 CC_SCHEDULER_ACTION_NOTIFY_BEGIN_MAIN_FRAME_NOT_EXPECTED_SOON = 13; 53} 54 55// Next id: 18 56message ChromeCompositorSchedulerState { 57 enum BeginImplFrameDeadlineMode { 58 DEADLINE_MODE_UNSPECIFIED = 0; 59 DEADLINE_MODE_NONE = 1; 60 DEADLINE_MODE_IMMEDIATE = 2; 61 DEADLINE_MODE_REGULAR = 3; 62 DEADLINE_MODE_LATE = 4; 63 DEADLINE_MODE_BLOCKED = 5; 64 } 65 optional ChromeCompositorStateMachine state_machine = 1; 66 optional bool observing_begin_frame_source = 2; 67 optional bool begin_impl_frame_deadline_task = 3; 68 optional bool pending_begin_frame_task = 4; 69 optional bool skipped_last_frame_missed_exceeded_deadline = 5; 70 optional bool skipped_last_frame_to_reduce_latency = 6; 71 optional ChromeCompositorSchedulerAction inside_action = 7; 72 optional BeginImplFrameDeadlineMode deadline_mode = 8; 73 optional int64 deadline_us = 9; 74 optional int64 deadline_scheduled_at_us = 10; 75 optional int64 now_us = 11; 76 optional int64 now_to_deadline_delta_us = 12; 77 optional int64 now_to_deadline_scheduled_at_delta_us = 13; 78 optional BeginImplFrameArgs begin_impl_frame_args = 14; 79 optional BeginFrameObserverState begin_frame_observer_state = 15; 80 optional BeginFrameSourceState begin_frame_source_state = 16; 81 optional CompositorTimingHistory compositor_timing_history = 17; 82} 83 84// Describes the current values stored in the Chrome Compositor state machine. 85// Next id: 3 86message ChromeCompositorStateMachine { 87 // Next id: 6 88 message MajorState { 89 enum BeginImplFrameState { 90 BEGIN_IMPL_FRAME_UNSPECIFIED = 0; 91 BEGIN_IMPL_FRAME_IDLE = 1; 92 BEGIN_IMPL_FRAME_INSIDE_BEGIN_FRAME = 2; 93 BEGIN_IMPL_FRAME_INSIDE_DEADLINE = 3; 94 } 95 enum BeginMainFrameState { 96 BEGIN_MAIN_FRAME_UNSPECIFIED = 0; 97 BEGIN_MAIN_FRAME_IDLE = 1; 98 BEGIN_MAIN_FRAME_SENT = 2; 99 BEGIN_MAIN_FRAME_READY_TO_COMMIT = 3; 100 } 101 enum LayerTreeFrameSinkState { 102 LAYER_TREE_FRAME_UNSPECIFIED = 0; 103 LAYER_TREE_FRAME_NONE = 1; 104 LAYER_TREE_FRAME_ACTIVE = 2; 105 LAYER_TREE_FRAME_CREATING = 3; 106 LAYER_TREE_FRAME_WAITING_FOR_FIRST_COMMIT = 4; 107 LAYER_TREE_FRAME_WAITING_FOR_FIRST_ACTIVATION = 5; 108 } 109 enum ForcedRedrawOnTimeoutState { 110 FORCED_REDRAW_UNSPECIFIED = 0; 111 FORCED_REDRAW_IDLE = 1; 112 FORCED_REDRAW_WAITING_FOR_COMMIT = 2; 113 FORCED_REDRAW_WAITING_FOR_ACTIVATION = 3; 114 FORCED_REDRAW_WAITING_FOR_DRAW = 4; 115 } 116 optional ChromeCompositorSchedulerAction next_action = 1; 117 optional BeginImplFrameState begin_impl_frame_state = 2; 118 optional BeginMainFrameState begin_main_frame_state = 3; 119 optional LayerTreeFrameSinkState layer_tree_frame_sink_state = 4; 120 optional ForcedRedrawOnTimeoutState forced_redraw_state = 5; 121 } 122 optional MajorState major_state = 1; 123 124 // Next id: 47 125 message MinorState { 126 enum TreePriority { 127 TREE_PRIORITY_UNSPECIFIED = 0; 128 TREE_PRIORITY_SAME_PRIORITY_FOR_BOTH_TREES = 1; 129 TREE_PRIORITY_SMOOTHNESS_TAKES_PRIORITY = 2; 130 TREE_PRIORITY_NEW_CONTENT_TAKES_PRIORITY = 3; 131 } 132 enum ScrollHandlerState { 133 SCROLL_HANDLER_UNSPECIFIED = 0; 134 SCROLL_AFFECTS_SCROLL_HANDLER = 1; 135 SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER = 2; 136 } 137 optional int32 commit_count = 1; 138 optional int32 current_frame_number = 2; 139 optional int32 last_frame_number_submit_performed = 3; 140 optional int32 last_frame_number_draw_performed = 4; 141 optional int32 last_frame_number_begin_main_frame_sent = 5; 142 optional bool did_draw = 6; 143 optional bool did_send_begin_main_frame_for_current_frame = 7; 144 optional bool did_notify_begin_main_frame_not_expected_until = 8; 145 optional bool did_notify_begin_main_frame_not_expected_soon = 9; 146 optional bool wants_begin_main_frame_not_expected = 10; 147 optional bool did_commit_during_frame = 11; 148 optional bool did_invalidate_layer_tree_frame_sink = 12; 149 optional bool did_perform_impl_side_invalidaion = 13; 150 optional bool did_prepare_tiles = 14; 151 optional int32 consecutive_checkerboard_animations = 15; 152 optional int32 pending_submit_frames = 16; 153 optional int32 submit_frames_with_current_layer_tree_frame_sink = 17; 154 optional bool needs_redraw = 18; 155 optional bool needs_prepare_tiles = 19; 156 optional bool needs_begin_main_frame = 20; 157 optional bool needs_one_begin_impl_frame = 21; 158 optional bool visible = 22; 159 optional bool begin_frame_source_paused = 23; 160 optional bool can_draw = 24; 161 optional bool resourceless_draw = 25; 162 optional bool has_pending_tree = 26; 163 optional bool pending_tree_is_ready_for_activation = 27; 164 optional bool active_tree_needs_first_draw = 28; 165 optional bool active_tree_is_ready_to_draw = 29; 166 optional bool did_create_and_initialize_first_layer_tree_frame_sink = 30; 167 optional TreePriority tree_priority = 31; 168 optional ScrollHandlerState scroll_handler_state = 32; 169 optional bool critical_begin_main_frame_to_activate_is_fast = 33; 170 optional bool main_thread_missed_last_deadline = 34; 171 optional bool skip_next_begin_main_frame_to_reduce_latency = 35; 172 optional bool video_needs_begin_frames = 36; 173 optional bool defer_begin_main_frame = 37; 174 optional bool last_commit_had_no_updates = 38; 175 optional bool did_draw_in_last_frame = 39; 176 optional bool did_submit_in_last_frame = 40; 177 optional bool needs_impl_side_invalidation = 41; 178 optional bool current_pending_tree_is_impl_side = 42; 179 optional bool previous_pending_tree_was_impl_side = 43; 180 optional bool processing_animation_worklets_for_active_tree = 44; 181 optional bool processing_animation_worklets_for_pending_tree = 45; 182 optional bool processing_paint_worklets_for_pending_tree = 46; 183 } 184 optional MinorState minor_state = 2; 185} 186 187// Next id: 12 188message BeginFrameArgs { 189 // JSON format has a "type" field that was always just "BeginFrameArgs" we 190 // drop this in the proto representation, and instead make the JSON format 191 // "subtype" field become the type field. 192 enum BeginFrameArgsType { 193 BEGIN_FRAME_ARGS_TYPE_UNSPECIFIED = 0; 194 BEGIN_FRAME_ARGS_TYPE_INVALID = 1; 195 BEGIN_FRAME_ARGS_TYPE_NORMAL = 2; 196 BEGIN_FRAME_ARGS_TYPE_MISSED = 3; 197 } 198 optional BeginFrameArgsType type = 1; 199 optional uint64 source_id = 2; 200 optional uint64 sequence_number = 3; 201 optional int64 frame_time_us = 4; 202 optional int64 deadline_us = 5; 203 optional int64 interval_delta_us = 6; 204 optional bool on_critical_path = 7; 205 optional bool animate_only = 8; 206 oneof created_from { 207 // The interned SourceLocation. 208 uint64 source_location_iid = 9; 209 // The SourceLocation that this args was created from. 210 // TODO(nuskos): Eventually we will support interning inside of 211 // TypedArgument TraceEvents and then we shouldn't need this SourceLocation 212 // since we can emit it as part of the InternedData message. When we can 213 // remove this |source_location|. 214 SourceLocation source_location = 10; 215 } 216} 217 218// Next id: 7 219message BeginImplFrameArgs { 220 optional int64 updated_at_us = 1; 221 optional int64 finished_at_us = 2; 222 enum State { 223 BEGIN_FRAME_FINISHED = 0; 224 BEGIN_FRAME_USING = 1; 225 } 226 optional State state = 3; 227 oneof args { 228 // Only set if |state| is BEGIN_FRAME_FINISHED. 229 BeginFrameArgs current_args = 4; 230 // Only set if |state| is BEGIN_FRAME_USING. 231 BeginFrameArgs last_args = 5; 232 } 233 message TimestampsInUs { 234 optional int64 interval_delta = 1; 235 optional int64 now_to_deadline_delta = 2; 236 optional int64 frame_time_to_now_delta = 3; 237 optional int64 frame_time_to_deadline_delta = 4; 238 optional int64 now = 5; 239 optional int64 frame_time = 6; 240 optional int64 deadline = 7; 241 } 242 optional TimestampsInUs timestamps_in_us = 6; 243} 244 245message BeginFrameObserverState { 246 optional int64 dropped_begin_frame_args = 1; 247 optional BeginFrameArgs last_begin_frame_args = 2; 248} 249 250message BeginFrameSourceState { 251 optional uint32 source_id = 1; 252 optional bool paused = 2; 253 optional uint32 num_observers = 3; 254 optional BeginFrameArgs last_begin_frame_args = 4; 255} 256 257message CompositorTimingHistory { 258 optional int64 begin_main_frame_queue_critical_estimate_delta_us = 1; 259 optional int64 begin_main_frame_queue_not_critical_estimate_delta_us = 2; 260 optional int64 begin_main_frame_start_to_ready_to_commit_estimate_delta_us = 261 3; 262 optional int64 commit_to_ready_to_activate_estimate_delta_us = 4; 263 optional int64 prepare_tiles_estimate_delta_us = 5; 264 optional int64 activate_estimate_delta_us = 6; 265 optional int64 draw_estimate_delta_us = 7; 266} 267