Skip to content
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

Day picker should dispose created MaterialStatesController's. #133884

Merged
merged 25 commits into from Sep 9, 2023

Conversation

polina-c
Copy link
Contributor

@polina-c polina-c commented Sep 1, 2023

Fixes #133862

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Sep 1, 2023
@polina-c polina-c added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 6, 2023
@@ -1008,7 +1013,7 @@ class _DayPickerState extends State<_DayPicker> {
focusNode: _dayFocusNodes[day - 1],
onTap: () => widget.onChanged(dayToBuild),
radius: _dayPickerRowHeight / 2 + 4,
statesController: MaterialStatesController(states),
statesController: _materialStatesController,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right, every date widget should have a separate states controller. cc @HansMuller

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. each day widget should have its own selected/disabled/etc state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is interesting that tests passed...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Looks better?

Copy link
Contributor

@HansMuller HansMuller Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that looks better although factoring out a stateful day widget per @chunhtai's suggestion seems like a cleaner way to do this.

And, as you pointed out, it looks like need some additional tests.

Copy link
Contributor Author

@polina-c polina-c Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test.

Copy link
Contributor Author

@polina-c polina-c Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect separate widget for a day will take 2-3 iterations, and I do not want to block conversion of tests to testWidgetsWithLeakTracking, that will insure disposable are disposed. Created TODO: #134323.

@polina-c polina-c changed the title Day picker should not create MaterialStatesController on every build Day picker should dispose created MaterialStatesController's. Sep 6, 2023
@polina-c polina-c removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 7, 2023
@polina-c polina-c requested review from HansMuller and removed request for goderbauer September 7, 2023 22:31
@@ -1008,7 +1016,7 @@ class _DayPickerState extends State<_DayPicker> {
focusNode: _dayFocusNodes[day - 1],
onTap: () => widget.onChanged(dayToBuild),
radius: _dayPickerRowHeight / 2 + 4,
statesController: MaterialStatesController(states),
statesController: statesController,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may leak if this widget rebuild with different days.

One idea to make this easier to manage is to create a statefulwidget wrapper around the dayWidget that holds the statesController. that way you won't need to keep track of each statesController in this widget.

Copy link
Contributor Author

@polina-c polina-c Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will not leak because the map's keys are from 1 to 31.
So' it will create maximum 31 controllers. Even if month changes, controllers for days will get new correct values in next build.
Anything I am missing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes you are right that it will not grow forever. I am fine with this change then. But since @HansMuller is more familiar with this part of the code, we should get his LGTM before merge

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but it is better to wait for @HansMuller's approval

@@ -1008,7 +1016,7 @@ class _DayPickerState extends State<_DayPicker> {
focusNode: _dayFocusNodes[day - 1],
onTap: () => widget.onChanged(dayToBuild),
radius: _dayPickerRowHeight / 2 + 4,
statesController: MaterialStatesController(states),
statesController: statesController,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes you are right that it will not grow forever. I am fine with this change then. But since @HansMuller is more familiar with this part of the code, we should get his LGTM before merge

@HansMuller
Copy link
Contributor

I'm OK with the change as it is although I'd prefer to see a Day widget factored out and a regression test that would fail if didn't properly maintain state per day (#133884 (comment)).

@polina-c polina-c changed the title Day picker should dispose created MaterialStatesController's. Day picker should dispose created MaterialStatesController's (abandoned). Sep 8, 2023
@polina-c polina-c changed the title Day picker should dispose created MaterialStatesController's (abandoned). Day picker should dispose created MaterialStatesController's. Sep 8, 2023
@polina-c polina-c added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Sep 8, 2023

auto label is removed for flutter/flutter/133884, due to - The status or check suite Linux analyze has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2023
@polina-c polina-c added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2023
@polina-c polina-c merged commit 5555836 into flutter:master Sep 9, 2023
66 of 67 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 9, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 9, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 9, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Sep 9, 2023
flutter/flutter@da676f7...7c28e8e

2023-09-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4e3231af6efc to d1913cb6a276 (1 revision) (flutter/flutter#134355)
2023-09-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 348e3a376807 to 4e3231af6efc (1 revision) (flutter/flutter#134353)
2023-09-09 polinach@google.com Day picker should dispose created MaterialStatesController's. (flutter/flutter#133884)
2023-09-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 00ef109b845e to 348e3a376807 (1 revision) (flutter/flutter#134349)
2023-09-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 7af8a5d8d556 to 00ef109b845e (1 revision) (flutter/flutter#134336)
2023-09-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 1f2da3d69da7 to 7af8a5d8d556 (2 revisions) (flutter/flutter#134332)
2023-09-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3a5f3ad1d054 to 1f2da3d69da7 (1 revision) (flutter/flutter#134328)
2023-09-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from d6aa2d9061c1 to 3a5f3ad1d054 (3 revisions) (flutter/flutter#134327)
2023-09-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 66bec85d5005 to d6aa2d9061c1 (1 revision) (flutter/flutter#134324)
2023-09-08 engine-flutter-autoroll@skia.org Roll Flutter Engine from 8d2892211366 to 66bec85d5005 (3 revisions) (flutter/flutter#134321)
2023-09-08 engine-flutter-autoroll@skia.org Roll Flutter Engine from 2da727e23518 to 8d2892211366 (1 revision) (flutter/flutter#134316)
2023-09-08 sokolovskyi.konstantin@gmail.com Fix memory leak in _DraggableScrollableSheetState (flutter/flutter#134212)
2023-09-08 polinach@google.com RestorationManager should dispatch creation in constructor. (flutter/flutter#133911)
2023-09-08 31859944+LongCatIsLooong@users.noreply.github.com Remove TextPainter migration flag from the framework (flutter/flutter#134274)
2023-09-08 rmolivares@renzo-olivares.dev InputDecoration.error should activate error state (flutter/flutter#134001)
2023-09-08 engine-flutter-autoroll@skia.org Roll Flutter Engine from b2cb1d271a88 to 2da727e23518 (1 revision) (flutter/flutter#134314)
2023-09-08 tessertaha@gmail.com Update chip docs to clarify how to specify a shape with no border & explain default values for Material 3 (flutter/flutter#134298)
2023-09-08 47866232+chunhtai@users.noreply.github.com Add ios analyzer command for universal links (flutter/flutter#134155)
2023-09-08 engine-flutter-autoroll@skia.org Roll Flutter Engine from 47a79306eed3 to b2cb1d271a88 (5 revisions) (flutter/flutter#134313)
2023-09-08 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6d6b44886175 to 47a79306eed3 (2 revisions) (flutter/flutter#134310)

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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_DayPickerState should not create MaterialStatesController on every build, without disposing
3 participants