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