Reland "Fix the first frame logic in tracing and driver (#35297)"#37192
Reland "Fix the first frame logic in tracing and driver (#35297)"#37192liyuqian merged 3 commits intoflutter:masterfrom
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
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.
nit: is the ` supposed to be in there?
| /// 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.
style for "see also" is:
| /// See also [firstFrameRasterized]. | |
| /// See also: | |
| /// | |
| /// * [firstFrameRasterized], <reason why I should look there>. |
| /// 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.
This should probably have a "see also" section (see below for style) linking to firstFrameRasterized.
| /// | ||
| /// {@macro flutter.frame_rasterized_vs_presented} | ||
| Future<void> get firstFrameRasterized => _firstFrameCompleter.future; | ||
| bool get firstFrameRasterized => _firstFrameCompleter.isCompleted; |
There was a problem hiding this comment.
Add a "see also" section linking to the future version?
| /// frame. | ||
| /// | ||
| /// {@macro flutter.frame_rasterize`_vs_presented} | ||
| Future<void> get waitUntilFirstFrameRasterized => _firstFrameCompleter.future; |
There was a problem hiding this comment.
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.
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)?
liyuqian
left a comment
There was a problem hiding this comment.
Thanks for the suggestions!
| /// | ||
| /// {@macro flutter.frame_rasterized_vs_presented} | ||
| Future<void> get firstFrameRasterized => _firstFrameCompleter.future; | ||
| bool get firstFrameRasterized => _firstFrameCompleter.isCompleted; |
| /// A future that completes when the Flutter engine has rasterized the first | ||
| /// frame. | ||
| /// | ||
| /// {@macro flutter.frame_rasterize`_vs_presented} |
| /// A future that completes when the Flutter engine has rasterized the first | ||
| /// frame. | ||
| /// | ||
| /// {@macro flutter.frame_rasterize`_vs_presented} |
| /// This value can also be obtained over the VM service protocol as | ||
| /// `ext.flutter.didSendFirstFrameEvent`. | ||
| /// | ||
| /// See also [firstFrameRasterized]. |
| /// frame. | ||
| /// | ||
| /// {@macro flutter.frame_rasterize`_vs_presented} | ||
| Future<void> get waitUntilFirstFrameRasterized => _firstFrameCompleter.future; |
There was a problem hiding this comment.
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)?
|
@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:
didSendFirstFrameRasterizedEventextension and its testsdidSendFirstFrameRasterizedEventinstead ofdidSendFirstFrameEventduring start up tests