Skip to content

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Apr 12, 2019

Description

flutter/engine#8524 had to be reverted because the increased precision fixed some issues, but caused our tests to fail for others.

In paritcular, FloatingActionButton animations involve a transform that gets very slightly translated. After going through various matrix multiplications, there's a slight loss of precision now that's captured by a double backed Rect. That's resolved with a new matcher called rectMoreOrLessEquals, which works like moreOrLessEquals.

The semantics change is because the rect also has more precision, and when that extra precision is pumped through to SizedBox it causes a failure. I'm hoping @yjbanov or @goderbauer can validate that this is safe - it seems so to me but I may be missing a bug in the semantics traversal algorithm.

Related Issues

Fixes #30920
Allows us to reland flutter/engine#8524 (or something similar to it).

Tests

I added the following tests:

New tests for rectMoreOrLessEquals.
Updated tests in preparation for increased precision in Rects.

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.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

///
/// See also:
///
/// * [moreOrLessEquals], which is for [double]s.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also within. Because within also supports Rect let's make sure their behavior is consistent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why can't we use within?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we could, but it seems confusing. reading something like expect(find.byKey(fabKey).getRect(), within(Rect.fromLTRB(...)) makes me think we expect the fab rect to be smaller - whereasrectMoreOrLessEquals reads a little more clearly IMHO

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But let's make sure the two are more or less (:wink:) consistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can rectMoreOrLessEquals internally just defer to within to ensure they are consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works for me. I'm trying to figure out why the semantics traversal test is behaving differently on different platforms right now.

@goderbauer goderbauer added a: tests "flutter test", flutter_test, or one of our tests f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Apr 12, 2019
@dnfield
Copy link
Contributor Author

dnfield commented Apr 12, 2019

We will have to update the semantics_traversal_test with the roll. I can't quite get it to work in both 64 and 32 bit precision, and it doesn't seem worth it to spend more effort on that when we can just fix it in the roll.

@Hixie
Copy link
Contributor

Hixie commented Apr 19, 2019

LGTM, see also #31333

@dnfield dnfield merged commit 37bc48f into flutter:master Apr 22, 2019
@dnfield dnfield deleted the rect_precision branch April 22, 2019 16:40
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: tests "flutter test", flutter_test, or one of our tests f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Change Rect internal representation from Float32List to Float64List (#8524)" causes Rect comparisons to fail

5 participants