Skip to content

Commit b29069e

Browse files
authored
Document that missed_frame_build_budget_count is misleading (#132137)
Fixes flutter/flutter#109745
1 parent d5a0fcd commit b29069e

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

packages/flutter_driver/lib/src/driver/timeline_summary.dart

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ generated by the interaction.
3131
''';
3232

3333
/// The maximum amount of time considered safe to spend for a frame's build
34-
/// phase. Anything past that is in the danger of missing the frame as 60FPS.
34+
/// phase. Anything past that is in the danger of missing the frame at 60FPS.
35+
///
36+
/// This is a hard-coded number and does not take into account the real device
37+
/// frame rate. Prefer using percentiles on the total build or raster time
38+
/// than metrics based on this value.
3539
const Duration kBuildBudget = Duration(milliseconds: 16);
3640

3741
/// The name of the framework frame build events we need to filter or extract.
@@ -71,9 +75,14 @@ class TimelineSummary {
7175

7276
/// The number of frames that missed the [kBuildBudget] and therefore are
7377
/// in the danger of missing frames.
74-
int computeMissedFrameBuildBudgetCount([ Duration frameBuildBudget = kBuildBudget ]) => _extractFrameDurations()
75-
.where((Duration duration) => duration > kBuildBudget)
76-
.length;
78+
///
79+
/// This does not take into account the real device frame rate. Prefer using
80+
/// [computePercentileFrameBuildTimeMillis] for evaluating performance.
81+
int computeMissedFrameBuildBudgetCount() {
82+
return _extractFrameDurations()
83+
.where((Duration duration) => duration > kBuildBudget)
84+
.length;
85+
}
7786

7887
/// Average amount of time spent per frame in the engine rasterizer.
7988
///
@@ -112,9 +121,14 @@ class TimelineSummary {
112121

113122
/// The number of frames that missed the [kBuildBudget] on the raster thread
114123
/// and therefore are in the danger of missing frames.
115-
int computeMissedFrameRasterizerBudgetCount([ Duration frameBuildBudget = kBuildBudget ]) => _extractGpuRasterizerDrawDurations()
116-
.where((Duration duration) => duration > kBuildBudget)
117-
.length;
124+
///
125+
/// This does not take into account the real device frame rate. Prefer using
126+
/// [computePercentileFrameRasterizerTimeMillis] for evaluating performance.
127+
int computeMissedFrameRasterizerBudgetCount() {
128+
return _extractGpuRasterizerDrawDurations()
129+
.where((Duration duration) => duration > kBuildBudget)
130+
.length;
131+
}
118132

119133
/// The total number of frames recorded in the timeline.
120134
int countFrames() => _extractFrameDurations().length;
@@ -156,7 +170,8 @@ class TimelineSummary {
156170
/// See [computeWorstFrameBuildTimeMillis].
157171
/// * "missed_frame_build_budget_count': The number of frames that missed
158172
/// the [kBuildBudget] and therefore are in the danger of missing frames.
159-
/// See [computeMissedFrameBuildBudgetCount].
173+
/// See [computeMissedFrameBuildBudgetCount]. Because [kBuildBudget] is a
174+
/// constant, this does not represent a real missed frame count.
160175
/// * "average_frame_rasterizer_time_millis": Average amount of time spent
161176
/// per frame in the engine rasterizer.
162177
/// See [computeAverageFrameRasterizerTimeMillis].
@@ -172,8 +187,9 @@ class TimelineSummary {
172187
/// See [computeWorstFrameRasterizerTimeMillis].
173188
/// * "missed_frame_rasterizer_budget_count": The number of frames that missed
174189
/// the [kBuildBudget] on the raster thread and therefore are in the danger
175-
/// of missing frames.
176-
/// See [computeMissedFrameRasterizerBudgetCount].
190+
/// of missing frames. See [computeMissedFrameRasterizerBudgetCount].
191+
/// Because [kBuildBudget] is a constant, this does not represent a real
192+
/// missed frame count.
177193
/// * "frame_count": The total number of frames recorded in the timeline. This
178194
/// is also the length of the "frame_build_times" and the "frame_begin_times"
179195
/// lists.

0 commit comments

Comments
 (0)