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 * 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 */ 16syntax = "proto2"; 17option optimize_for = LITE_RUNTIME; 18package android.surfaceflinger; 19 20// This is a copy of surfaceflinger's atoms from frameworks/proto_logging/stats/atoms.proto. 21// Pulled atoms for surfaceflinger must be routed through system server since surfaceflinger is 22// in the bootstrap namespace. This copy is used to pass the atoms as protos to system server using 23// proto lite to serialize/deserialize the atoms. 24 25// These wrappers are so that we can pass a List<Atom> as a single byte string. 26// They are not in atoms.proto 27message SurfaceflingerStatsGlobalInfoWrapper { 28 repeated SurfaceflingerStatsGlobalInfo atom = 1; 29} 30 31message SurfaceflingerStatsLayerInfoWrapper { 32 repeated SurfaceflingerStatsLayerInfo atom = 1; 33} 34 35/** 36 * Global display pipeline metrics reported by SurfaceFlinger. 37 * Metrics exist beginning in Android 11. 38 * Pulled from: 39 * frameworks/native/services/surfaceflinger/TimeStats/TimeStats.cpp 40 */ 41message SurfaceflingerStatsGlobalInfo { 42 // Aggregated refresh rate buckets that layers were presenting at. Buckets 43 // are defined in SurfaceFlinger and are tracked per device. 44 // Introduced in Android 12. 45 // This is intended to be used as a dimenstion in collecting per-refresh rate 46 // jank statistics. 47 optional int32 display_refresh_rate_bucket = 18; 48 // Aggregated render rate buckets that layers were overridden to run at. 49 // Buckets are defined in SurfaceFlinger and are tracked per device. 50 // Introduced in Android 12. 51 // This is intended to be used as a dimension in collecting per-render rate 52 // jank statistics. 53 optional int32 render_rate_bucket = 21; 54 // Total number of frames presented during the tracing period 55 // Note: This stat is not sliced by dimension. It will be duplicated for metrics 56 // using render_rate_bucket as a dimension. 57 optional int64 total_frames = 1; 58 // Total number of frames missed 59 // Note: This stat is not sliced by dimension. It will be duplicated for metrics 60 // using render_rate_bucket as a dimension. 61 optional int64 missed_frames = 2; 62 // Total number of frames that fell back to client composition 63 // Note: This stat is not sliced by dimension. It will be duplicated for metrics 64 // using render_rate_bucket as a dimension. 65 optional int64 client_composition_frames = 3; 66 // Total time the display was turned on 67 // Note: This stat is not sliced by dimension. It will be duplicated for metrics 68 // using render_rate_bucket as a dimension. 69 optional int64 display_on_millis = 4; 70 // Total time that was spent performing animations. 71 // This is derived from the present-to-present layer histogram. 72 // Note: This stat is not sliced by dimension. It will be duplicated for metrics 73 // using render_rate_bucket as a dimension. 74 optional int64 animation_millis = 5; 75 // Total number of event connections tracked by SurfaceFlinger at the time 76 // of this pull. If this number grows prohibitively large, then this can 77 // cause jank due to resource contention. 78 // Note: This stat is not sliced by dimension. It will be duplicated for metrics 79 // using render_rate_bucket as a dimension. 80 optional int32 event_connection_count = 6; 81 // Set of timings measured from when SurfaceFlinger began compositing a 82 // frame, until the frame was requested to be presented to the display. This 83 // measures SurfaceFlinger's total CPU walltime on the critical path per 84 // frame. 85 // Note: This stat is not sliced by dimension. It will be duplicated for metrics 86 // using render_rate_bucket as a dimension. 87 optional FrameTimingHistogram frame_duration = 7; 88 // Set of timings measured from when SurfaceFlinger first began using the 89 // GPU to composite a frame, until the GPU has finished compositing that 90 // frame. This measures the total additional time SurfaceFlinger needed to 91 // perform due to falling back into GPU composition. 92 // Note: This stat is not sliced by dimension. It will be duplicated for metrics 93 // using render_rate_bucket as a dimension. 94 optional FrameTimingHistogram render_engine_timing = 8; 95 // Number of frames where SF saw a frame, based on its frame timeline. 96 // Frame timelines may include transactions without updating buffer contents. 97 // Introduced in Android 12. 98 optional int32 total_timeline_frames = 9; 99 // Number of frames where SF saw a janky frame. 100 // Introduced in Android 12. 101 optional int32 total_janky_frames = 10; 102 // Number of janky frames where SF spent a long time on the CPU. 103 // Introduced in Android 12. 104 optional int32 total_janky_frames_with_long_cpu = 11; 105 // Number of janky frames where SF spent a long time on the GPU. 106 // Introduced in Android 12. 107 optional int32 total_janky_frames_with_long_gpu = 12; 108 // Number of janky frames where SF missed the frame deadline, but there 109 // was not an attributed reason (e.g., maybe HWC missed?) 110 // Introduced in Android 12. 111 optional int32 total_janky_frames_sf_unattributed = 13; 112 // Number of janky frames where the app missed the frame deadline, but 113 // there was not an attributed reason 114 // Introduced in Android 12. 115 optional int32 total_janky_frames_app_unattributed = 14; 116 // Number of janky frames that were caused because of scheduling errors in 117 // SF that resulted in early present (e.g., SF sending a buffer to the 118 // composition engine earlier than expected, resulting in a present that is 119 // one vsync early) 120 // Introduced in Android 12. 121 optional int32 total_janky_frames_sf_scheduling = 15; 122 // Number of frames that were classified as jank because of possible drift in 123 // vsync predictions. 124 // Introduced in Android 12. 125 optional int32 total_jank_frames_sf_prediction_error = 16; 126 // Number of janky frames where the app was in a buffer stuffed state (more 127 // than one buffer ready to be presented at the same vsync). Usually caused 128 // when the first frame is unusually long, the following frames enter into a 129 // stuffed state. 130 // Introduced in Android 12. 131 optional int32 total_jank_frames_app_buffer_stuffing = 17; 132 // Buckets of timings in ms by which SurfaceFlinger's deadline was missed 133 // while latching and presenting frames. 134 // Introduced in Android 12. 135 optional FrameTimingHistogram sf_deadline_misses = 19; 136 // Buckets of timings in ms by which the Vsync prediction drifted, when 137 // compared to the actual hardware vsync. 138 // Introduced in Android 12. 139 optional FrameTimingHistogram sf_prediction_errors = 20; 140 141 // Next ID: 22 142} 143 144/** 145 * Per-layer display pipeline metrics reported by SurfaceFlinger. 146 * Metrics exist beginning in Android 11. 147 * The number of layers uploaded may be restricted due to size limitations. 148 * Pulled from: 149 * frameworks/native/services/surfaceflinger/TimeStats/TimeStats.cpp 150 */ 151message SurfaceflingerStatsLayerInfo { 152 // UID of the application who submitted this layer for presentation 153 // This is intended to be used as a dimension for surfacing rendering 154 // statistics to applications. 155 // Introduced in Android 12. 156 optional int32 uid = 12; 157 // Refresh rate bucket that the layer was presenting at. Buckets are 158 // defined in SurfaceFlinger and are tracked per device. 159 // Introduced in Android 12. 160 // This is intended to be used as a dimension in collecting per-refresh rate 161 // jank statistics 162 optional int32 display_refresh_rate_bucket = 22; 163 // Render rate bucket that the layer was submitting frames at. Buckets are 164 // defined in SurfaceFlinger and are tracked per device. 165 // Introduced in Android 12. 166 // This is intended to be used as a dimension in collecting per-render rate 167 // jank statistics. 168 optional int32 render_rate_bucket = 23; 169 170 enum GameMode { 171 GAME_MODE_UNSPECIFIED = 0; 172 GAME_MODE_UNSUPPORTED = 1; 173 GAME_MODE_STANDARD = 2; 174 GAME_MODE_PERFORMANCE = 3; 175 GAME_MODE_BATTERY = 4; 176 GAME_MODE_CUSTOM = 5; 177 } 178 179 // Game mode that the layer was running at. Used to track user engagement 180 // in different modes. The modes are defined in GameManager.java 181 // Game modes are used only for integrating with GameManager. All non-game 182 // layers will have this field set to UNSUPPORTED. 183 // Introduced in Android 12 184 // This is intended to be used as a dimension in collecting per-game mode 185 // fps and frame related metrics. 186 optional GameMode game_mode = 26; 187 // The layer for this set of metrics 188 // In many scenarios the package name is included in the layer name, e.g., 189 // layers created by Window Manager. But this is not a guarantee - in the 190 // general case layer names are arbitrary debug names. 191 optional string layer_name = 1; 192 // Total number of frames presented 193 optional int64 total_frames = 2; 194 // Total number of dropped frames while latching a buffer for this layer. 195 optional int64 dropped_frames = 3; 196 // Set of timings measured between successive presentation timestamps. 197 optional FrameTimingHistogram present_to_present = 4; 198 // Set of timings measured from when an app queued a buffer for 199 // presentation, until the buffer was actually presented to the 200 // display. 201 optional FrameTimingHistogram post_to_present = 5; 202 // Set of timings measured from when a buffer is ready to be presented, 203 // until the buffer was actually presented to the display. 204 optional FrameTimingHistogram acquire_to_present = 6; 205 // Set of timings measured from when a buffer was latched by 206 // SurfaceFlinger, until the buffer was presented to the display 207 optional FrameTimingHistogram latch_to_present = 7; 208 // Set of timings measured from the desired presentation to the actual 209 // presentation time 210 optional FrameTimingHistogram desired_to_present = 8; 211 // Set of timings measured from when an app queued a buffer for 212 // presentation, until the buffer was ready to be presented. 213 optional FrameTimingHistogram post_to_acquire = 9; 214 // Frames missed latch because the acquire fence didn't fire 215 optional int64 late_acquire_frames = 10; 216 // Frames latched early because the desired present time was bad 217 optional int64 bad_desired_present_frames = 11; 218 // Number of frames where SF saw a frame, based on its frame timeline. 219 // Frame timelines may include transactions without updating buffer contents. 220 // Introduced in Android 12. 221 optional int32 total_timeline_frames = 13; 222 // Number of frames where SF saw a janky frame. 223 // Introduced in Android 12. 224 optional int32 total_janky_frames = 14; 225 // Number of janky frames where SF spent a long time on the CPU. 226 // Introduced in Android 12. 227 optional int32 total_janky_frames_with_long_cpu = 15; 228 // Number of janky frames where SF spent a long time on the GPU. 229 // Introduced in Android 12. 230 optional int32 total_janky_frames_with_long_gpu = 16; 231 // Number of janky frames where SF missed the frame deadline, but there 232 // was not an attributed reason (e.g., maybe HWC missed?) 233 // Introduced in Android 12. 234 optional int32 total_janky_frames_sf_unattributed = 17; 235 // Number of janky frames where the app missed the frame deadline, but 236 // there was not an attributed reason 237 // Introduced in Android 12. 238 optional int32 total_janky_frames_app_unattributed = 18; 239 // Number of janky frames that were caused because of scheduling errors in 240 // SF that resulted in early present (e.g., SF sending a buffer to the 241 // composition engine earlier than expected, resulting in a present that is 242 // one vsync early) 243 // Introduced in Android 12. 244 optional int32 total_janky_frames_sf_scheduling = 19; 245 // Number of frames that were classified as jank because of possible drift in 246 // vsync predictions. 247 // Introduced in Android 12. 248 optional int32 total_jank_frames_sf_prediction_error = 20; 249 // Number of janky frames where the app was in a buffer stuffed state (more 250 // than one buffer ready to be presented at the same vsync). Usually caused 251 // when the first frame is unusually long, the following frames enter into a 252 // stuffed state. 253 // Introduced in Android 12. 254 optional int32 total_jank_frames_app_buffer_stuffing = 21; 255 256 /** 257 * Encapsulates the FrameRateVote information sent by the application while 258 * calling setFrameRate. 259 * Metrics exist beginning in Android 12. 260 */ 261 message SetFrameRateVote { 262 // The desired frame rate the application wishes to run on. 263 optional float frame_rate = 1; 264 265 enum FrameRateCompatibility { 266 FRAME_RATE_UNDEFINED = 0; 267 FRAME_RATE_DEFAULT = 1; 268 FRAME_RATE_EXACT_OR_MULTIPLE = 2; 269 } 270 271 // Specifies how to interpret the frame rate associated with the layer. 272 // Defined in Layer.h 273 optional FrameRateCompatibility frame_rate_compatibility = 2; 274 275 enum Seamlessness { 276 SEAMLESS_UNDEFINED = 0; 277 SEAMLESS_SHOULD_BE_SEAMLESS = 1; 278 SEAMLESS_NOT_REQUIRED = 2; 279 } 280 // Indicates whether seamless refresh rate switch is required or not. 281 optional Seamlessness seamlessness = 3; 282 } 283 284 // The last frame rate vote set by the application. 285 // Introduced in Android 12. 286 optional SetFrameRateVote set_frame_rate_vote = 24; 287 // Buckets of timings in ms by which the app deadline was missed while 288 // submitting work for a frame. 289 // Introduced in Android 12. 290 optional FrameTimingHistogram app_deadline_misses = 25; 291 292 // Variability histogram of present_to_present timings. 293 // Introduced in Android 14. 294 optional FrameTimingHistogram present_to_present_delta = 27; 295 296 // Next ID: 28 297} 298 299/** 300 * Histogram of frame counts bucketed by time in milliseconds. 301 * Because of size limitations, we hard-cap the number of buckets, with 302 * buckets for corresponding to larger milliseconds being less precise. 303 */ 304message FrameTimingHistogram { 305 // Timings in milliseconds that describes a set of histogram buckets 306 repeated int32 time_millis_buckets = 1; 307 // Number of frames that match to each time_millis, i.e. the bucket 308 // contents 309 // It's required that len(time_millis) == len(frame_count) 310 repeated int64 frame_counts = 2; 311} 312