-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Reland "Fix the first frame logic in tracing and driver (#35297)" #37192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ter#35297)" (flutter#37027)" This reverts commit 3068fc4.
1. Add didSendFirstFrameRasterizedEvent extension and its tests 2. Wait for didSendFirstFrameRasterizedEvent instead of didSendFirstFrameEvent during start up tests 3. Mark missed (probably newly added) start up tests as flaky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #37192 +/- ##
==========================================
+ Coverage 54.55% 55.16% +0.61%
==========================================
Files 193 193
Lines 17849 17851 +2
==========================================
+ Hits 9738 9848 +110
+ Misses 8111 8003 -108
Continue to review full report at Codecov.
|
/// A future that completes when the Flutter engine has rasterized the first | ||
/// frame. | ||
/// | ||
/// {@macro flutter.frame_rasterize`_vs_presented} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is the ` supposed to be in there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Thanks!
@@ -567,6 +587,8 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB | |||
/// | |||
/// This value can also be obtained over the VM service protocol as | |||
/// `ext.flutter.didSendFirstFrameEvent`. | |||
/// | |||
/// See also [firstFrameRasterized]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style for "see also" is:
/// See also [firstFrameRasterized]. | |
/// See also: | |
/// | |
/// * [firstFrameRasterized], <reason why I should look there>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/// A future that completes when the Flutter engine has rasterized the first | ||
/// frame. | ||
/// | ||
/// {@macro flutter.frame_rasterize`_vs_presented} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably have a "see also" section (see below for style) linking to firstFrameRasterized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -556,9 +570,15 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB | |||
/// Whether the Flutter engine has rasterized the first frame. | |||
/// | |||
/// {@macro flutter.frame_rasterized_vs_presented} | |||
Future<void> get firstFrameRasterized => _firstFrameCompleter.future; | |||
bool get firstFrameRasterized => _firstFrameCompleter.isCompleted; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a "see also" section linking to the future version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/// frame. | ||
/// | ||
/// {@macro flutter.frame_rasterize`_vs_presented} | ||
Future<void> get waitUntilFirstFrameRasterized => _firstFrameCompleter.future; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is a little misleading because calling the getter doesn't actually wait for anything. The caller has to do the waiting by awaiting on the result. Not sure what a better name would be, though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of a better name either. But since Dart never has a synchronous waiting mechanism, it seems to be Ok to return a Future for a waitUntilXYZ
function? The only way to wait in Dart is await
(see, e.g., https://github.com/flutter/flutter/blob/master/packages/flutter_driver/lib/src/extension/extension.dart#L242)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestions!
@@ -556,9 +570,15 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB | |||
/// Whether the Flutter engine has rasterized the first frame. | |||
/// | |||
/// {@macro flutter.frame_rasterized_vs_presented} | |||
Future<void> get firstFrameRasterized => _firstFrameCompleter.future; | |||
bool get firstFrameRasterized => _firstFrameCompleter.isCompleted; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/// A future that completes when the Flutter engine has rasterized the first | ||
/// frame. | ||
/// | ||
/// {@macro flutter.frame_rasterize`_vs_presented} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Thanks!
/// A future that completes when the Flutter engine has rasterized the first | ||
/// frame. | ||
/// | ||
/// {@macro flutter.frame_rasterize`_vs_presented} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -567,6 +587,8 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB | |||
/// | |||
/// This value can also be obtained over the VM service protocol as | |||
/// `ext.flutter.didSendFirstFrameEvent`. | |||
/// | |||
/// See also [firstFrameRasterized]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/// frame. | ||
/// | ||
/// {@macro flutter.frame_rasterize`_vs_presented} | ||
Future<void> get waitUntilFirstFrameRasterized => _firstFrameCompleter.future; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of a better name either. But since Dart never has a synchronous waiting mechanism, it seems to be Ok to return a Future for a waitUntilXYZ
function? The only way to wait in Dart is await
(see, e.g., https://github.com/flutter/flutter/blob/master/packages/flutter_driver/lib/src/extension/extension.dart#L242)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@liyuqian Can we mark the previously existing tests non-flaky again and/or revert this PR? We can't be having these critical benchmarks be considered ok-to-break. |
This relands #35297
The followings have been done to fix the broken tests:
didSendFirstFrameRasterizedEvent
extension and its testsdidSendFirstFrameRasterizedEvent
instead ofdidSendFirstFrameEvent
during start up tests