-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Make sure that a DisplayFeatureSubScreen doesn't crash in 0x0 environ… #180357
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 DisplayFeatureSubScreen doesn't crash in 0x0 environ… #180357
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 valuable test case for DisplayFeatureSubScreen that confirms a crash when the widget is constrained to a zero-sized area, as reported in issue #6537. The test is well-structured and effectively reproduces the issue.
However, the implementation to fix the underlying crash appears to be missing from this pull request. The StateError: Bad state: No element will still be thrown in _closestToAnchorPoint because subScreensInBounds can return an empty list when the widget's size is zero and there are display features.
To resolve this, I recommend adding a guard at the beginning of the DisplayFeatureSubScreen.build method to handle the zero-size case. For instance, if mediaQuery.size is empty, the widget should return its child directly, bypassing the sub-screen calculation logic.
Here's a suggested implementation:
// in packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
@override
Widget build(BuildContext context) {
// ...
final MediaQueryData mediaQuery = MediaQuery.of(context);
final Size parentSize = mediaQuery.size;
if (parentSize.isEmpty) {
return child;
}
// ... rest of the build method
}Once the fix is included, this pull request will be ready for another review. Thank you for adding the test coverage!
justinmc
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 👍
|
autosubmit label was removed for flutter/flutter/180357, because This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.
|
flutter/flutter@d81cd3e...793b0b8 2026-01-13 ahmedsameha1@gmail.com Make sure that a FormField doesn't crash at 0x0 environment (flutter/flutter#180810) 2026-01-13 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from VYeyMPe1lyCtlcl-V... to vTYb37OeUqZRxpiiP... (flutter/flutter#180880) 2026-01-13 ahmedsameha1@gmail.com Make sure that a DisplayFeatureSubScreen doesn't crash in 0x0 environ… (flutter/flutter#180357) 2026-01-13 ahmedsameha1@gmail.com Make sure that a DragTarget doesn't crash in 0x0 environment (flutter/flutter#180422) 2026-01-13 goderbauer@google.com Manually roll test dependencies (flutter/flutter#180886) 2026-01-12 engine-flutter-autoroll@skia.org Roll Skia from f70bcbf1b090 to 714d0af2eda7 (2 revisions) (flutter/flutter#180866) 2026-01-12 jason-simmons@users.noreply.github.com Roll libpng to version 1.6.53 (flutter/flutter#180712) 2026-01-12 30870216+gaaclarke@users.noreply.github.com Turn on fragment shader equality test (flutter/flutter#180784) 2026-01-12 116356835+AbdeMohlbi@users.noreply.github.com Update `PlatformPlugin` to not call `setStatusBarColor`, `setNavigationBarColor`, `setNavigationBarDividerColor` when disabled (flutter/flutter#180061) 2026-01-12 engine-flutter-autoroll@skia.org Roll Skia from a650ce2b0d50 to f70bcbf1b090 (1 revision) (flutter/flutter#180860) 2026-01-12 augustocesarperin@gmail.com Fix RawAutocomplete unmounted crash during async optionsBuilder (flutter/flutter#180824) 2026-01-12 116356835+AbdeMohlbi@users.noreply.github.com Fix `documentation member not recognized` because of missing import in `FlutterEngine.java` (flutter/flutter#180731) 2026-01-12 engine-flutter-autoroll@skia.org Roll Dart SDK from 42fd9ef68c1a to 34318de9874b (1 revision) (flutter/flutter#180854) 2026-01-12 gowsik.andro@gmail.com Add API sample and docs for Expansible widget (flutter/flutter#180273) 2026-01-12 engine-flutter-autoroll@skia.org Roll Skia from 487a9943210b to a650ce2b0d50 (2 revisions) (flutter/flutter#180849) 2026-01-12 116356835+AbdeMohlbi@users.noreply.github.com Improve code quality in `BinaryMessenger.java` (flutter/flutter#180733) 2026-01-12 30870216+gaaclarke@users.noreply.github.com Reland `Enabled some disabled impeller fragment shader dart tests` (flutter/flutter#180788) 2026-01-12 bkonyi@google.com [ Tool ] Fix `flutter run -d all` crash (flutter/flutter#180845) 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
flutter#180357) This is my attempt to handle flutter#6537 for the DisplayFeatureSubScreen widget. Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
This is my attempt to handle #6537 for the DisplayFeatureSubScreen widget.