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
AutomatedTestWidgetsFlutterBinding.pump
provides wrong pump time stamp, probably because of forgetting the precision
#112609
Conversation
This reverts commit 857765b.
/// In order to let animation get accurate time information during [pump], | ||
/// set the flag to true. The default value is false for compatibility. | ||
bool accuratePump = false; | ||
|
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.
Is this because of the test failures in your earlier commits?
From what I can tell, one of those failures would be expected (the widget_tester_test.dart "pumping pumpFrames"
test), and the other test is a customer test that I think is reasonable to make a change to or temporarily disable. I'll have to follow up with some people on whether the customer test change is acceptable or not.
If getting a change to the customer test is reasonable, I'd much prefer we get rid of this flag, as it doesn't actual do anything except keep backwards compatibility for something we've pretty thoroughly determined is a bug.
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'll followup again on Monday, but I'm hoping we can fix the failing customer test to prevent needing to add this flag.
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.
Yes, I add that flag because CI fails by widget_tester_test.dart and a consumer-test.
and the other test is a customer test that I think is reasonable to make a change to or temporarily disable. I'll have to follow up with some people on whether the customer test change is acceptable or not.
Take your time :)
If getting a change to the customer test is reasonable, I'd much prefer we get rid of this flag, as it doesn't actual do anything except keep backwards compatibility for something we've pretty thoroughly determined is a bug.
Totally agree! I also want to remove the flag
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.
Apologies for the delay, but I've reached out to the owner of the customer test that's failing and we think we can get a fix in the test that's compatible with this change without the flag. I'll work on getting that test fix in, while I'm doing that could you:
- Remove the
accuratePump
flag - Fix the test in the
widget_tester_test.dart
file that was failing
After we get those failing tests cleared up, this should be good to go!
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.
Alright, the customer test should be fixed now. I tested it with the microsecond change locally to verify that the customer test works before and after this change.
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 :) Code done, waiting for CI
|
@pdblasi-google I guess maybe need to update the custom testing configurations to point to the latest tests? |
@fzyzcjy Yup, you called it. Apologies, I forgot to point the flutter/tests repo to the latest tests. PR is up for that now, I'll ping here when it goes through. |
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
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.
Alright, customer tests are passing, golden files that were affected by the precision change have been triaged and updated, and the code itself looks good to me!
I appreciate your patience working through the tests and everything. I'll pass it off to someone else for another review, and you should be good to go! Good find!
Thanks and 🎉 ! |
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
…mp time stamp, probably because of forgetting the precision (flutter/flutter#112609)
… time stamp, probably because of forgetting the precision (flutter/flutter#112609)
@fzyzcjy @goderbauer this is a breaking change. Can a migration guide be written on how developers can migrate their code with this change? I'm not sure what's needed on my end as a developer, and my animation tests are now very flaky. |
@CaseyHillers Hi,
Could you please share some flaky test minimal reproducible samples? IMHO this should not make any problem so want to see reproductions in order to know what happens |
Here's an example now that is flaky: await tester.pumpWidget(myAnimatedWidget);
await tester.pumpAndSettle();
await tester.sendSelectEvent();
await tester.pumpFrames(scene, Duration(milliseconds: 100));
await expectLater(
find.byType(MyAnimatedWidget),
matchesGoldenFile(
'animated_widget')); The resulting goldens are changing. When I change |
@CaseyHillers Weird. Some possible ideas:
Do you mean the new golden (i.e. after the PR) are different from old golden, and the new golden is itself stable? If so, looks like it is possible. Indeed the animation controller is fed with a changed animation time. |
My animated widgets are just an animated builder that has a custom animation controller. @goderbauer or @pdblasi-google can help with reproducing the issue here. My understanding is I need to change every possible clock to be in microseconds instead of milliseconds. This seems to be a breaking change for any other customers, and I'm having a difficult time tracking all the various clocks in my codebase. I haven't found the discord threads, but I wonder if this is something that should be in the framework. There could be a tester field added for high precision or this can be added directly to your package. I assume most Flutter tests aren't needing high precision, and this is going to cause a lot of pain once it's in beta/stable. |
Btw I am curious why a clock can in milliseconds in codebase -
I agree that an alternative solution is to use a bool flag to enable high-accuracy (I have done that indeed - e0b5882). |
Thanks, that sounds like it would work for me! Are there plans to upstream that change? |
… time stamp, probably because of forgetting the precision (flutter#112609)" This reverts commit 1966aaf.
@CaseyHillers I am ok with that, just not sure what other reviewers think? (Since that was my original design and later a reviewer suggests me to change to what is current merged.) If you guys are OK I will PR it. |
@CaseyHillers Here is the PR: #113433 |
The fix is just one line:
I have
git blame
and find the bug exist since the first version 7yr ago, and no special comments about why this is introduced so I guess it is but not feature.IMHO the bug may be written like, the programmer wants to convert DateTime (the
clock.now()
) into a Duration. But then it is forgotten that both are microseconds precision instead of milliseconds precision, and the milliseconds approach is used.List which issues are fixed by this PR. You must list at least one issue.
Close #112610
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.
p.s. test fails with old code, confirming that the test is effective.