-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix crash when editableText is not mounted #171159
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
Fix crash when editableText is not mounted #171159
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. 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.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
7d2f678 to
75b226f
Compare
|
@Renzo-Olivares - could you take a look? |
|
This will need a test before it can be merged. |
I do not see good way to test this. This is edge case, with very specific edge case. |
|
Friendly request to review and approve. Tests are not feasible, did not find way to reproduce using tests. This is crash at Google/money client, and we would like to fix in github, instead of workarounds internally. |
Renzo-Olivares
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, sorry for the delay. I also tried writing a test but could not reproduce the bug (editableText was always mounted for me).
|
I'm going to request a test exemption on discord and then we can land this. |
|
Hi @matasb-google, this PR doesn't qualify for a test exemption because it does not fall under the criteria noted in https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests. In most cases when fixing a regression like this one we want to add a test to make sure we don't break the fix in the future. This particular fix was rather tricky to write a test for, but I gave it another shot and was able to trigger the crash. If you add this test to the PR then we can move forward and land it. testWidgets(
'does not crash when long press is cancelled after unmounting',
(WidgetTester tester) async {
// Regression test for b/425840577.
final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose);
await tester.pumpWidget(
MaterialApp(
home: Material(
child: CustomScrollView(
controller: scrollController,
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
if (index == 0) {
return const TextField();
}
return const SizedBox(height: 50);
},
childCount: 200,
addAutomaticKeepAlives: false,
),
),
],
),
),
),
);
final EditableTextState state = tester.state<EditableTextState>(find.byType(EditableText));
// Start a long press, don't release it, and don't completely reach kLongPressTimeout so the
// gesture is not accepted and is cancelled when the recognizer is disposed.
await tester.startGesture(tester.getCenter(find.byType(TextField)));
await tester.pump(const Duration(milliseconds: 200));
await tester.pumpAndSettle();
// While attempting to long press, scroll the TextField out of view
// to dispose of it and its gesture recognizers.
scrollController.jumpTo(8000.0);
await tester.pump();
expect(state.mounted, isFalse);
// Should reach the end of the test without any failures.
},
variant: TargetPlatformVariant.only(TargetPlatform.iOS),
); |
f4b61e2 to
d11eb58
Compare
|
Thanks, added test. |
|
autosubmit label was removed for flutter/flutter/171159, 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.
|
loic-sharma
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.
Looks good to me, thanks for taking time to create a test for this!
Fix issue when text_selection crashes due to editableText not being mounted. No issue filled (internal b/425840577) Likely introduced by flutter#167881 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Fix issue when text_selection crashes due to editableText not being mounted. No issue filled (internal b/425840577) Likely introduced by flutter#167881 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Fix issue when text_selection crashes due to editableText not being mounted.
No issue filled (internal b/425840577)
Likely introduced by #167881
Pre-launch Checklist
///).