-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Make sure that a Tooltip doesn't crash in 0x0 environment #178461
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
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 to ensure that a Tooltip with a zero-sized child does not crash the application. This is a valuable addition to prevent future regressions of the issue.
My review includes a suggestion to improve the test to more accurately reflect the conditions of the original crash report. Specifically, I recommend triggering the tooltip to be displayed, as the crash occurred during the tooltip's positioning logic. This will make the test more comprehensive.
| testWidgets('Tooltip does not crash at zero area', (WidgetTester tester) async { | ||
| await tester.pumpWidget( | ||
| const MaterialApp( | ||
| home: Center( | ||
| child: SizedBox.shrink(child: Tooltip(message: 'X')), | ||
| ), | ||
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(Tooltip)), Size.zero); | ||
| }); |
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.
This test is a great addition to prevent regressions for the zero-sized tooltip crash. However, it can be improved to more accurately reproduce the conditions that led to the original crash.
The current test verifies that a Tooltip constrained to a zero size can be laid out. The original issue, however, was related to a crash during the positioning of the tooltip when it's being displayed. The current test doesn't trigger the tooltip to appear.
Additionally, the issue describes a Tooltip with a zero-sized child, whereas the test has a Tooltip with a null child that is itself constrained to be zero-sized.
The suggested change updates the test to:
- Wrap a zero-sized widget (
SizedBox.shrink()) with theTooltip, matching the scenario from the issue. - Programmatically trigger the tooltip to be shown using
ensureTooltipVisible(). - Verify that the tooltip content is visible, which implicitly confirms that no crash occurred during the positioning and rendering of the tooltip.
This will make the test more robust and ensure it fully covers the intended crash scenario.
testWidgets('Tooltip does not crash at zero area', (WidgetTester tester) async {
final GlobalKey<TooltipState> tooltipKey = GlobalKey<TooltipState>();
await tester.pumpWidget(
MaterialApp(
home: Center(
child: Tooltip(
key: tooltipKey,
message: 'X',
child: const SizedBox.shrink(),
),
),
),
);
expect(tester.getSize(find.byType(Tooltip)), Size.zero);
// Trigger the tooltip to ensure the positioning logic doesn't crash.
tooltipKey.currentState!.ensureTooltipVisible();
await tester.pump(); // Start the tooltip animation.
await tester.pump(const Duration(seconds: 2)); // Wait for it to be fully visible.
// Verifying the tooltip is visible confirms that no crash occurred during positioning.
expect(find.text('X'), findsOneWidget);
});51adfdc to
e2fa7de
Compare
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(Tooltip)), Size.zero); | ||
| key.currentState!.ensureTooltipVisible(); |
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.
Should we check that the tooltip is of size zero after ensuring it is visible?
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 suggest we should use set the view size to zero since the tooltip is an overlay.
e2fa7de to
128403a
Compare
|
autosubmit label was removed for flutter/flutter/178461, because - The status or check suite Linux analyze has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
…8461) This is my attempt to handle flutter#6537 for the Tooltip widget. --------- Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com> Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
…10601) Manual roll Flutter from 6a1f5b7f85a4 to e25d71b086d6 (30 revisions) Manual roll requested by tarrinneal@google.com flutter/flutter@6a1f5b7...e25d71b 2025-12-10 jason-simmons@users.noreply.github.com Ensure that the engine converts std::filesystem::path objects to UTF-8 strings on Windows (flutter/flutter#179528) 2025-12-10 ybz975218925@gmail.com Fix the issue with pinned headers in nested SliverMainAxisGroup. (flutter/flutter#179132) 2025-12-10 Akashefrath@gmail.com added onUserInteractionIfError for form (flutter/flutter#175515) 2025-12-10 39942340+prash4931@users.noreply.github.com Fixed RenderFlex overflow in RouteObserver Example (flutter/flutter#170980) 2025-12-10 engine-flutter-autoroll@skia.org Roll Dart SDK from 17749965ec57 to 077062c5e515 (3 revisions) (flutter/flutter#179691) 2025-12-10 carapacik@gmail.com Manually roll characters (flutter/flutter#179447) 2025-12-10 engine-flutter-autoroll@skia.org Roll Packages from 338ecd3 to 74a5a53 (4 revisions) (flutter/flutter#179693) 2025-12-10 fluttergithubbot@gmail.com Marks Mac_ios draw_arcs_all_stroke_styles_perf_ios__timeline_summary to be unflaky (flutter/flutter#179669) 2025-12-10 jason-simmons@users.noreply.github.com Check for a null cached image in SingleFrameCodec::getNextFrame (flutter/flutter#179483) 2025-12-10 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from _pSztGZvEA3-Ry-GW... to u5vxWTRT0HlxOP5_r... (flutter/flutter#179652) 2025-12-10 robert.ancell@canonical.com Implement flutter/accessibility channel (flutter/flutter#179484) 2025-12-10 engine-flutter-autoroll@skia.org Roll Skia from 82fff05cc621 to e61cc6d073fd (4 revisions) (flutter/flutter#179646) 2025-12-10 ahmedsameha1@gmail.com Make sure that a CupertinoDialogAction doesn't crash in 0x0 environment (flutter/flutter#178956) 2025-12-10 matt.boetger@gmail.com Make SettingsChannel configuration queue not static (flutter/flutter#179636) 2025-12-10 ahmedsameha1@gmail.com Make sure that a CupertinoListSection doesn't crash in 0x0 environment (flutter/flutter#179068) 2025-12-10 ahmedsameha1@gmail.com Make sure that a CupertinoFormSection doesn't crash in 0x0 environment (flutter/flutter#179001) 2025-12-10 ahmedsameha1@gmail.com Make sure that a CupertinoMagnifier doesn't crash in 0x0 environment (flutter/flutter#179206) 2025-12-10 ahmedsameha1@gmail.com Make sure that a Tooltip doesn't crash in 0x0 environment (flutter/flutter#178461) 2025-12-10 ahmedsameha1@gmail.com Make sure that a CupertinoSegmentedControl doesn't crash in 0x0 envir… (flutter/flutter#179544) 2025-12-10 ahmedsameha1@gmail.com Make sure that a CupertinoSlider doesn't crash in 0x0 environment (flutter/flutter#179566) 2025-12-10 ahmedsameha1@gmail.com Make sure that a CupertinoPageScaffold doesn't crash in 0x0 environment (flutter/flutter#179245) 2025-12-09 engine-flutter-autoroll@skia.org Roll Skia from f9e32c28c5c5 to 82fff05cc621 (2 revisions) (flutter/flutter#179641) 2025-12-09 engine-flutter-autoroll@skia.org Roll Dart SDK from 019cb923bf62 to 17749965ec57 (5 revisions) (flutter/flutter#179640) 2025-12-09 116356835+AbdeMohlbi@users.noreply.github.com Enhance documentation for `LocalHistoryEntry` class (flutter/flutter#179223) 2025-12-09 Rusino@users.noreply.github.com WebParagrah: ellipsis (flutter/flutter#178748) 2025-12-09 chingjun@google.com Update the doc on Google Testing to reflect the current state (flutter/flutter#177187) 2025-12-09 jacksongardner@google.com [wimp] Initial Impeller on Web implementation. (flutter/flutter#175442) 2025-12-09 47866232+chunhtai@users.noreply.github.com Relax assertion for adding semantics locale (flutter/flutter#178140) 2025-12-09 45459898+RamonFarizel@users.noreply.github.com Fix Scrollbar drag behavior (flutter/flutter#179199) 2025-12-09 engine-flutter-autoroll@skia.org Roll Skia from 502ee6f2a0d7 to f9e32c28c5c5 (6 revisions) (flutter/flutter#179632) 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 Tooltip widget.