• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    }
177
178    // Game mode that the layer was running at. Used to track user engagement
179    // in different modes. The modes are defined in GameManager.java
180    // Game modes are used only for integrating with GameManager. All non-game
181    // layers will have this field set to UNSUPPORTED.
182    // Introduced in Android 12
183    // This is intended to be used as a dimension in collecting per-game mode
184    // fps and frame related metrics.
185    optional GameMode game_mode = 26;
186    // The layer for this set of metrics
187    // In many scenarios the package name is included in the layer name, e.g.,
188    // layers created by Window Manager. But this is not a guarantee - in the
189    // general case layer names are arbitrary debug names.
190    optional string layer_name = 1;
191    // Total number of frames presented
192    optional int64 total_frames = 2;
193    // Total number of dropped frames while latching a buffer for this layer.
194    optional int64 dropped_frames = 3;
195    // Set of timings measured between successive presentation timestamps.
196    optional FrameTimingHistogram present_to_present = 4;
197    // Set of timings measured from when an app queued a buffer for
198    // presentation, until the buffer was actually presented to the
199    // display.
200    optional FrameTimingHistogram post_to_present = 5;
201    // Set of timings measured from when a buffer is ready to be presented,
202    // until the buffer was actually presented to the display.
203    optional FrameTimingHistogram acquire_to_present = 6;
204    // Set of timings measured from when a buffer was latched by
205    // SurfaceFlinger, until the buffer was presented to the display
206    optional FrameTimingHistogram latch_to_present = 7;
207    // Set of timings measured from the desired presentation to the actual
208    // presentation time
209    optional FrameTimingHistogram desired_to_present = 8;
210    // Set of timings measured from when an app queued a buffer for
211    // presentation, until the buffer was ready to be presented.
212    optional FrameTimingHistogram post_to_acquire = 9;
213    // Frames missed latch because the acquire fence didn't fire
214    optional int64 late_acquire_frames = 10;
215    // Frames latched early because the desired present time was bad
216    optional int64 bad_desired_present_frames = 11;
217    // Number of frames where SF saw a frame, based on its frame timeline.
218    // Frame timelines may include transactions without updating buffer contents.
219    // Introduced in Android 12.
220    optional int32 total_timeline_frames = 13;
221    // Number of frames where SF saw a janky frame.
222    // Introduced in Android 12.
223    optional int32 total_janky_frames = 14;
224    // Number of janky frames where SF spent a long time on the CPU.
225    // Introduced in Android 12.
226    optional int32 total_janky_frames_with_long_cpu = 15;
227    // Number of janky frames where SF spent a long time on the GPU.
228    // Introduced in Android 12.
229    optional int32 total_janky_frames_with_long_gpu = 16;
230    // Number of janky frames where SF missed the frame deadline, but there
231    // was not an attributed reason (e.g., maybe HWC missed?)
232    // Introduced in Android 12.
233    optional int32 total_janky_frames_sf_unattributed = 17;
234    // Number of janky frames where the app missed the frame deadline, but
235    // there was not an attributed reason
236    // Introduced in Android 12.
237    optional int32 total_janky_frames_app_unattributed = 18;
238    // Number of janky frames that were caused because of scheduling errors in
239    // SF that resulted in early present (e.g., SF sending a buffer to the
240    // composition engine earlier than expected, resulting in a present that is
241    // one vsync early)
242    // Introduced in Android 12.
243    optional int32 total_janky_frames_sf_scheduling = 19;
244    // Number of frames that were classified as jank because of possible drift in
245    // vsync predictions.
246    // Introduced in Android 12.
247    optional int32 total_jank_frames_sf_prediction_error = 20;
248    // Number of janky frames where the app was in a buffer stuffed state (more
249    // than one buffer ready to be presented at the same vsync). Usually caused
250    // when the first frame is unusually long, the following frames enter into a
251    // stuffed state.
252    // Introduced in Android 12.
253    optional int32 total_jank_frames_app_buffer_stuffing = 21;
254
255    /**
256     * Encapsulates the FrameRateVote information sent by the application while
257     * calling setFrameRate.
258     * Metrics exist beginning in Android 12.
259     */
260    message SetFrameRateVote {
261        // The desired frame rate the application wishes to run on.
262        optional float frame_rate = 1;
263
264        enum FrameRateCompatibility {
265            FRAME_RATE_UNDEFINED = 0;
266            FRAME_RATE_DEFAULT = 1;
267            FRAME_RATE_EXACT_OR_MULTIPLE = 2;
268        }
269
270        // Specifies how to interpret the frame rate associated with the layer.
271        // Defined in Layer.h
272        optional FrameRateCompatibility frame_rate_compatibility = 2;
273
274        enum Seamlessness {
275            SEAMLESS_UNDEFINED = 0;
276            SEAMLESS_SHOULD_BE_SEAMLESS = 1;
277            SEAMLESS_NOT_REQUIRED = 2;
278        }
279        // Indicates whether seamless refresh rate switch is required or not.
280        optional Seamlessness seamlessness = 3;
281    }
282
283    // The last frame rate vote set by the application.
284    // Introduced in Android 12.
285    optional SetFrameRateVote set_frame_rate_vote = 24;
286    // Buckets of timings in ms by which the app deadline was missed while
287    // submitting work for a frame.
288    // Introduced in Android 12.
289    optional FrameTimingHistogram app_deadline_misses = 25;
290
291    // Next ID: 27
292}
293
294/**
295 * Histogram of frame counts bucketed by time in milliseconds.
296 * Because of size limitations, we hard-cap the number of buckets, with
297 * buckets for corresponding to larger milliseconds being less precise.
298 */
299message FrameTimingHistogram {
300    // Timings in milliseconds that describes a set of histogram buckets
301    repeated int32 time_millis_buckets = 1;
302    // Number of frames that match to each time_millis, i.e. the bucket
303    // contents
304    // It's required that len(time_millis) == len(frame_count)
305    repeated int64 frame_counts = 2;
306}
307