这是indexloc提供的服务,不要输入任何密码
Skip to content

Make compareTo more robust in semantics.dart #81083

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

Merged
merged 1 commit into from
Apr 23, 2021

Conversation

goderbauer
Copy link
Member

@goderbauer goderbauer commented Apr 23, 2021

In b/180268307 we end up with double.NaN for _BoxEdge.offset, which is obviously a bug and shouldn't happen. In debug mode we guard against this with asserts. In release mode, those are turned off and the app crashes because double.NaN.toInt() is illegal.

This change makes the code more robust by avoiding the toInt() call. The bug where _BoxEdge.offset ends up being double.NaN is still present, though and I haven't been able to reproduce it to investigate why it is happening. :(

With this change, instead of crashing the traversal order of the SemanticsNodes may be not as expected.

@google-cla google-cla bot added the cla: yes label Apr 23, 2021
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@flutter-dashboard flutter-dashboard bot added a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) framework flutter/packages/flutter repository. See also f: labels. labels Apr 23, 2021
@Hixie
Copy link
Contributor

Hixie commented Apr 23, 2021

test-exempt: code refactor

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -2353,7 +2353,7 @@ class _BoxEdge implements Comparable<_BoxEdge> {

@override
int compareTo(_BoxEdge other) {
return (offset - other.offset).sign.toInt();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add an assert just so that it still crashes in debug mode. Otherwise, I feel we won't ever figure out what the issue is.

Copy link
Member Author

Choose a reason for hiding this comment

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

line 2333 has the assert that will trigger before this line crashes.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants