-
Notifications
You must be signed in to change notification settings - Fork 29.8k
- Fixes _DropdownMenuState leaking text controller [prod-leak-fix] #146571
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
- Fixes particular test not handling text controller dispose
|
cc: @polina-c |
| currentHighlight = widget.enableSearch ? i : null; | ||
| widget.onSelected?.call(entry.value); | ||
| _localTextEditingController?.dispose(); | ||
| _localTextEditingController = null; |
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.
Why we need to dispose _localTextEditingController on every click? It will cause recreation of the controller.
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 getter recreates controller if there is no controller:
TextEditingController get _textEditingController {
return widget.controller ?? (_localTextEditingController ??= TextEditingController());
}
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.
Yes, having getter which creates disposable class is quite troublesome even if we fix this issue if bounds to cause issue if new feature is introduced
i'll try to remove getter and minimise instantiation limited to initState and didUpdateWidget
| selection: TextSelection.collapsed(offset: entry.label.length), | ||
| ); | ||
| widget.onSelected?.call(entry.value); | ||
| _localTextEditingController?.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.
The same comment here.
It will cause recreate of controller on each onEditingComplete.
|
Hii @polina-c, Have updated PR as per discussed, let me know if this is good or you'd have some improvement in mind 🤔 |
|
Thanks. Originally the getter was creating local controller if one in widget is not provided. If we understand what was wrong, we may find smaller code change for fix. Or, we may discover some bigger bug in Flutter Framework, that is always a good thing. |
|
Hii @polina-c Yes, its nice idea to understand what is causing this bug, so i did some test and it turns out that
which is there because of copy-paste issue #118731 so it can change focus. which causes if we simply remove post frame callback function and call some additional details that might help:-
but what do you think? we should merge this PR? or we should be changing |
|
Thank you for research! |
Manual roll requested by tarrinneal@google.com flutter/flutter@53cba24...2e748e8 2024-04-15 nate.w5687@gmail.com Implementing control flow collections (flutter/flutter#146601) 2024-04-15 engine-flutter-autoroll@skia.org Roll Packages from 78f684c to 6698b2d (3 revisions) (flutter/flutter#146761) 2024-04-15 32538273+ValentinVignal@users.noreply.github.com test: Fix memory leak in transitions test (flutter/flutter#146747) 2024-04-15 leroux_bruno@yahoo.fr Fix filled text field active indicator overflows container bounds (flutter/flutter#146637) 2024-04-14 102401667+Dimilkalathiya@users.noreply.github.com - Fixes _DropdownMenuState leaking text controller (flutter/flutter#146571) 2024-04-13 32538273+ValentinVignal@users.noreply.github.com Fix memory leaks in `FloatingActionButton` (flutter/flutter#146711) 2024-04-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0e56e3dffe43 to 1a13c7d1f40e (2 revisions) (flutter/flutter#146703) 2024-04-12 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#146704) 2024-04-12 49699333+dependabot[bot]@users.noreply.github.com Bump peter-evans/create-pull-request from 6.0.2 to 6.0.3 (flutter/flutter#146702) 2024-04-12 chingjun@google.com Avoid forwarding the data after socket is disconnected. (flutter/flutter#146665) 2024-04-12 christopherfujino@gmail.com [flutter_tools] Fix conductor for package args roll (flutter/flutter#146646) 2024-04-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6b37b170998e to 0e56e3dffe43 (4 revisions) (flutter/flutter#146698) 2024-04-12 katelovett@google.com Light sliver clean up before SliverTree (flutter/flutter#146696) 2024-04-12 leroux_bruno@yahoo.fr Fix label text color is wrong for a focused and hovered TextField (flutter/flutter#146572) 2024-04-12 31859944+LongCatIsLooong@users.noreply.github.com Fix `getOffsetForCaret` crash (flutter/flutter#146669) 2024-04-12 magder@google.com Update gen_keycodes templates (flutter/flutter#146481) 2024-04-12 jacksongardner@google.com Support `flutter run --wasm` and `flutter drive --wasm`. (flutter/flutter#146231) 2024-04-12 32538273+ValentinVignal@users.noreply.github.com Fix curved animation memory leak for scrollbar (flutter/flutter#146670) 2024-04-12 engine-flutter-autoroll@skia.org Roll Packages from e98839a to 78f684c (6 revisions) (flutter/flutter#146691) 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 rmistry@google.com,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@53cba24...2e748e8 2024-04-15 nate.w5687@gmail.com Implementing control flow collections (flutter/flutter#146601) 2024-04-15 engine-flutter-autoroll@skia.org Roll Packages from 78f684c to 6698b2d (3 revisions) (flutter/flutter#146761) 2024-04-15 32538273+ValentinVignal@users.noreply.github.com test: Fix memory leak in transitions test (flutter/flutter#146747) 2024-04-15 leroux_bruno@yahoo.fr Fix filled text field active indicator overflows container bounds (flutter/flutter#146637) 2024-04-14 102401667+Dimilkalathiya@users.noreply.github.com - Fixes _DropdownMenuState leaking text controller (flutter/flutter#146571) 2024-04-13 32538273+ValentinVignal@users.noreply.github.com Fix memory leaks in `FloatingActionButton` (flutter/flutter#146711) 2024-04-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0e56e3dffe43 to 1a13c7d1f40e (2 revisions) (flutter/flutter#146703) 2024-04-12 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#146704) 2024-04-12 49699333+dependabot[bot]@users.noreply.github.com Bump peter-evans/create-pull-request from 6.0.2 to 6.0.3 (flutter/flutter#146702) 2024-04-12 chingjun@google.com Avoid forwarding the data after socket is disconnected. (flutter/flutter#146665) 2024-04-12 christopherfujino@gmail.com [flutter_tools] Fix conductor for package args roll (flutter/flutter#146646) 2024-04-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6b37b170998e to 0e56e3dffe43 (4 revisions) (flutter/flutter#146698) 2024-04-12 katelovett@google.com Light sliver clean up before SliverTree (flutter/flutter#146696) 2024-04-12 leroux_bruno@yahoo.fr Fix label text color is wrong for a focused and hovered TextField (flutter/flutter#146572) 2024-04-12 31859944+LongCatIsLooong@users.noreply.github.com Fix `getOffsetForCaret` crash (flutter/flutter#146669) 2024-04-12 magder@google.com Update gen_keycodes templates (flutter/flutter#146481) 2024-04-12 jacksongardner@google.com Support `flutter run --wasm` and `flutter drive --wasm`. (flutter/flutter#146231) 2024-04-12 32538273+ValentinVignal@users.noreply.github.com Fix curved animation memory leak for scrollbar (flutter/flutter#146670) 2024-04-12 engine-flutter-autoroll@skia.org Roll Packages from e98839a to 78f684c (6 revisions) (flutter/flutter#146691) 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 rmistry@google.com,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

Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.