-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Make sure that a FocusScope doesn't crash in 0x0 environment #180715
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
Make sure that a FocusScope doesn't crash in 0x0 environment #180715
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.
Code Review
This pull request adds a regression test for an issue where FocusScope would crash in a zero-sized environment. The new test case correctly sets up this scenario to prevent future regressions. My feedback focuses on improving the test's teardown logic to ensure better test isolation.
| tester.view.physicalSize = Size.zero; | ||
| final focusScopeNode = FocusScopeNode(); | ||
| addTearDown(tester.view.reset); | ||
| addTearDown(focusScopeNode.dispose); |
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.
To ensure test isolation, it's better to restore the original physicalSize of the view in a teardown block rather than calling tester.view.reset(). This prevents side effects on other tests that might rely on a default view size. The suggested change saves the original size and restores it after the test, ensuring a clean state for subsequent tests.
| tester.view.physicalSize = Size.zero; | |
| final focusScopeNode = FocusScopeNode(); | |
| addTearDown(tester.view.reset); | |
| addTearDown(focusScopeNode.dispose); | |
| final Size originalSize = tester.view.physicalSize; | |
| addTearDown(() => tester.view.physicalSize = originalSize); | |
| tester.view.physicalSize = Size.zero; | |
| final focusScopeNode = FocusScopeNode(); | |
| addTearDown(focusScopeNode.dispose); |
victorsanni
left a comment
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.
Does FocusScope have its own renderbox? I took a look at the source code and it just wraps its child in an InheritedNotifier + Semantics. cc @dkwingsmt
dkwingsmt
left a comment
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. I think it's fine. It's to guarantee that we don't make any significant changes that involve layout in the future.
…#180715) This is my attempt to handle flutter#6537 for the FocusScope widget.
Manual roll requested by tarrinneal@google.com flutter/flutter@b45a73b...5a2067b 2026-01-13 engine-flutter-autoroll@skia.org Roll Packages from e57e7f4 to eb9e1dc (6 revisions) (flutter/flutter#180907) 2026-01-13 ahmedsameha1@gmail.com Make sure that a FocusScope doesn't crash in 0x0 environment (flutter/flutter#180715) 2026-01-13 bkonyi@google.com [ Tool ] Handle `DartDevelopmentServiceException` when launching web applications (flutter/flutter#180905) 2026-01-13 116356835+AbdeMohlbi@users.noreply.github.com Removes `RequiresApi 23` (flutter/flutter#180629) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Manual roll requested by tarrinneal@google.com flutter/flutter@b45a73b...48c2475 2026-01-13 ahmedsameha1@gmail.com Make sure that a FocusScope doesn't crash in 0x0 environment (flutter/flutter#180715) 2026-01-13 bkonyi@google.com [ Tool ] Handle `DartDevelopmentServiceException` when launching web applications (flutter/flutter#180905) 2026-01-13 116356835+AbdeMohlbi@users.noreply.github.com Removes `RequiresApi 23` (flutter/flutter#180629) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This is my attempt to handle #6537 for the FocusScope widget.