-
Notifications
You must be signed in to change notification settings - Fork 29.3k
Fix WidgetsBinding.firstFrameRasterized not completing #56022
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
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.
Good catch! The fix looks right. In order to accept the PR we will need a test, though. Can you please add one? Thanks.
This Future does not complete when `deferFirstFrame` is used.
|
||
// Simulates the engine completing a frame render to trigger the | ||
// appropriate callback setting [WidgetBinding.firstFrameRasterized]. | ||
binding.window.onReportTimings( |
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.
Please let me know if there's a better way to do this, as there doesn't seem to be an engine in the tests that actually calls the callbacks.
@goderbauer added tests, please take a look! |
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 after comments are resolved.
packages/flutter/test/widgets/binding_first_frame_rasterized_test.dart
Outdated
Show resolved
Hide resolved
packages/flutter/test/widgets/binding_first_frame_rasterized_test.dart
Outdated
Show resolved
Hide resolved
…est.dart Co-authored-by: Michael Goderbauer <goderbauer@google.com>
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
Description
The completer backing
WidgetsBinding.firstFrameRasterized
never completes whendeferFirstFrame
is used.Please see jiahaog/repro_flutter_first_frame@ed49ba4 for a small reproduction.
This is because
firstFrameCallback
is removed here when the current frame is a deferred frameflutter/packages/flutter/lib/src/widgets/binding.dart
Line 880 in bd6ccb6
but
_needToReportFirstFrame
is reset back totrue
. As a result, the next iteration ofdrawFrame
for the frame that should be sent to the engine will never trigger the conditional block that reports the frames.flutter/packages/flutter/lib/src/widgets/binding.dart
Lines 843 to 860 in bd6ccb6
This affects driver tests as well when the
FlutterDriver.waitUntilFirstFrameRasterized
is used. (Internal bug b/155033896)Related Issues
#45135
Tests
I added the following tests:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.