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

Re-land fix for not disposed TabController [prod-leak-fix] #146745

Merged
merged 14 commits into from
Apr 22, 2024

Conversation

polina-c
Copy link
Contributor

@polina-c polina-c commented Apr 14, 2024

Fixes #144910

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. a: animation Animation APIs f: material design flutter/packages/flutter/material repository. labels Apr 14, 2024
@polina-c polina-c added the a: leak tracking Issues and PRs related to memory leaks detected by leak_tracker label Apr 14, 2024
@polina-c polina-c requested a review from goderbauer April 14, 2024 22:42
@polina-c polina-c marked this pull request as draft April 14, 2024 22:42
@polina-c polina-c removed the request for review from goderbauer April 14, 2024 22:42
@polina-c polina-c marked this pull request as ready for review April 15, 2024 16:11
@polina-c polina-c requested a review from goderbauer April 16, 2024 01:25
@@ -843,6 +843,10 @@ class AnimationController extends Animation<double>
}

void _tick(Duration elapsed) {
if (_ticker == null) {
Copy link
Member

Choose a reason for hiding this comment

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

This looks fishy. Why is _tick still being called when the associated ticker has been disposed?

Copy link
Contributor Author

@polina-c polina-c Apr 16, 2024

Choose a reason for hiding this comment

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

Because ticker uses SchedulerBinding.instance.scheduleFrameCallback to invoke tick.
There is number of cases of usage after disposal in Flutter, as it is validated only for small subset. It is not in scope of current cleanup to fix all these cases.
Current clean up makes sure to dispose all disposables, even when usage after disposal happens.

We can detect and clean up usage after disposal in future phases. The macro @disposable, that I am constructing to instrument disposables, will have this parameter.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but it is unscheduled when the ticker is disposed. So, if _tick is still called after dispose there is something else that is not working as intended and - on the surface - this just seems to paper over that problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could not repro the problem I was trying to solve with this. Removed.

@@ -276,7 +281,9 @@ class TabController extends ChangeNotifier {

@override
void dispose() {
_animationController?.dispose();
if (_disposeAnimationController) {
Copy link
Member

Choose a reason for hiding this comment

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

This is also a strange pattern. Either the TabController owns the AnimationController (then it needs to be disposed here) or it doesn't own it and should never dispose it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added doc comment. Does it help?

Copy link
Member

Choose a reason for hiding this comment

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

The pattern is still strange. How about: copyWith will move the animationController to the new TabController and null out _animationController on the old one (this should be added to the documentation of _copyWith). Then, instead of doing an internal dispose call in _copyWith whoever calls _copyWith should follow up with a dispose call if they no longer need the old controller.

Copy link
Contributor Author

@polina-c polina-c Apr 20, 2024

Choose a reason for hiding this comment

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

I removed the flag and nulled controller. Thanks for suggesting this.

It is strange for me though to declare that whoever called _copyWith must call dispose. It is easy to miss. If it is always this way, why _copyWith cannot do it?

@polina-c polina-c requested a review from goderbauer April 16, 2024 22:37
@github-actions github-actions bot removed the a: animation Animation APIs label Apr 20, 2024
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@polina-c polina-c added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 22, 2024
@auto-submit auto-submit bot merged commit 1d7c680 into flutter:master Apr 22, 2024
75 checks passed
gilnobrega pushed a commit to gilnobrega/flutter that referenced this pull request Apr 22, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 23, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Apr 23, 2024
flutter/flutter@140edb9...77043ba

2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from ffd3911b1ff7 to 79f49954cce8 (2 revisions) (flutter/flutter#147235)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from c7d9deb66bf7 to ffd3911b1ff7 (1 revision) (flutter/flutter#147227)
2024-04-23 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#147220)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 075d834489d0 to c7d9deb66bf7 (2 revisions) (flutter/flutter#147215)
2024-04-23 leroux_bruno@yahoo.fr Mention visualDensity impact on ButtonStyle.padding documentation (flutter/flutter#147048)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9c0d24ff1cb6 to 075d834489d0 (1 revision) (flutter/flutter#147214)
2024-04-23 32538273+ValentinVignal@users.noreply.github.com Fix memory leaks in `CupertinoTextMagnifier` (flutter/flutter#147208)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 004e98839ed7 to 9c0d24ff1cb6 (1 revision) (flutter/flutter#147211)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 79f753650c6e to 004e98839ed7 (1 revision) (flutter/flutter#147209)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from f8e373da5227 to 79f753650c6e (1 revision) (flutter/flutter#147206)
2024-04-23 102401667+Dimilkalathiya@users.noreply.github.com fixes cupertino page transition leak (flutter/flutter#147133)
2024-04-23 32538273+ValentinVignal@users.noreply.github.com Fix memory leaks in `PopupMenu` (flutter/flutter#147174)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 62c9f17169cf to f8e373da5227 (2 revisions) (flutter/flutter#147205)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 33c828fb3ff5 to 62c9f17169cf (4 revisions) (flutter/flutter#147203)
2024-04-23 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 4.3.2 to 4.3.3 (flutter/flutter#147192)
2024-04-23 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.1 to 3.25.2 (flutter/flutter#147193)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from a4b71f02a1c7 to 33c828fb3ff5 (9 revisions) (flutter/flutter#147190)
2024-04-22 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#147094)
2024-04-22 polinach@google.com Re-land fix for not disposed TabController (flutter/flutter#146745)
2024-04-22 engine-flutter-autoroll@skia.org Roll Flutter Engine from 75ca2195c936 to a4b71f02a1c7 (1 revision) (flutter/flutter#147175)
2024-04-22 lamnhandev@gmail.com Update `examples/api` for android platform (flutter/flutter#147102)

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 camillesimon@google.com,rmistry@google.com,stuartmorgan@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
@polina-c polina-c deleted the tabs-fix branch April 26, 2024 04:37
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this pull request May 22, 2024
flutter/flutter@140edb9...77043ba

2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from ffd3911b1ff7 to 79f49954cce8 (2 revisions) (flutter/flutter#147235)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from c7d9deb66bf7 to ffd3911b1ff7 (1 revision) (flutter/flutter#147227)
2024-04-23 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#147220)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 075d834489d0 to c7d9deb66bf7 (2 revisions) (flutter/flutter#147215)
2024-04-23 leroux_bruno@yahoo.fr Mention visualDensity impact on ButtonStyle.padding documentation (flutter/flutter#147048)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9c0d24ff1cb6 to 075d834489d0 (1 revision) (flutter/flutter#147214)
2024-04-23 32538273+ValentinVignal@users.noreply.github.com Fix memory leaks in `CupertinoTextMagnifier` (flutter/flutter#147208)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 004e98839ed7 to 9c0d24ff1cb6 (1 revision) (flutter/flutter#147211)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 79f753650c6e to 004e98839ed7 (1 revision) (flutter/flutter#147209)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from f8e373da5227 to 79f753650c6e (1 revision) (flutter/flutter#147206)
2024-04-23 102401667+Dimilkalathiya@users.noreply.github.com fixes cupertino page transition leak (flutter/flutter#147133)
2024-04-23 32538273+ValentinVignal@users.noreply.github.com Fix memory leaks in `PopupMenu` (flutter/flutter#147174)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 62c9f17169cf to f8e373da5227 (2 revisions) (flutter/flutter#147205)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 33c828fb3ff5 to 62c9f17169cf (4 revisions) (flutter/flutter#147203)
2024-04-23 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 4.3.2 to 4.3.3 (flutter/flutter#147192)
2024-04-23 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.1 to 3.25.2 (flutter/flutter#147193)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from a4b71f02a1c7 to 33c828fb3ff5 (9 revisions) (flutter/flutter#147190)
2024-04-22 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#147094)
2024-04-22 polinach@google.com Re-land fix for not disposed TabController (flutter/flutter#146745)
2024-04-22 engine-flutter-autoroll@skia.org Roll Flutter Engine from 75ca2195c936 to a4b71f02a1c7 (1 revision) (flutter/flutter#147175)
2024-04-22 lamnhandev@gmail.com Update `examples/api` for android platform (flutter/flutter#147102)

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 camillesimon@google.com,rmistry@google.com,stuartmorgan@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
arc-yong pushed a commit to Arctuition/packages-arc that referenced this pull request Jun 14, 2024
flutter/flutter@140edb9...77043ba

2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from ffd3911b1ff7 to 79f49954cce8 (2 revisions) (flutter/flutter#147235)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from c7d9deb66bf7 to ffd3911b1ff7 (1 revision) (flutter/flutter#147227)
2024-04-23 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#147220)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 075d834489d0 to c7d9deb66bf7 (2 revisions) (flutter/flutter#147215)
2024-04-23 leroux_bruno@yahoo.fr Mention visualDensity impact on ButtonStyle.padding documentation (flutter/flutter#147048)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9c0d24ff1cb6 to 075d834489d0 (1 revision) (flutter/flutter#147214)
2024-04-23 32538273+ValentinVignal@users.noreply.github.com Fix memory leaks in `CupertinoTextMagnifier` (flutter/flutter#147208)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 004e98839ed7 to 9c0d24ff1cb6 (1 revision) (flutter/flutter#147211)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 79f753650c6e to 004e98839ed7 (1 revision) (flutter/flutter#147209)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from f8e373da5227 to 79f753650c6e (1 revision) (flutter/flutter#147206)
2024-04-23 102401667+Dimilkalathiya@users.noreply.github.com fixes cupertino page transition leak (flutter/flutter#147133)
2024-04-23 32538273+ValentinVignal@users.noreply.github.com Fix memory leaks in `PopupMenu` (flutter/flutter#147174)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 62c9f17169cf to f8e373da5227 (2 revisions) (flutter/flutter#147205)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from 33c828fb3ff5 to 62c9f17169cf (4 revisions) (flutter/flutter#147203)
2024-04-23 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 4.3.2 to 4.3.3 (flutter/flutter#147192)
2024-04-23 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.1 to 3.25.2 (flutter/flutter#147193)
2024-04-23 engine-flutter-autoroll@skia.org Roll Flutter Engine from a4b71f02a1c7 to 33c828fb3ff5 (9 revisions) (flutter/flutter#147190)
2024-04-22 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#147094)
2024-04-22 polinach@google.com Re-land fix for not disposed TabController (flutter/flutter#146745)
2024-04-22 engine-flutter-autoroll@skia.org Roll Flutter Engine from 75ca2195c936 to a4b71f02a1c7 (1 revision) (flutter/flutter#147175)
2024-04-22 lamnhandev@gmail.com Update `examples/api` for android platform (flutter/flutter#147102)

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 camillesimon@google.com,rmistry@google.com,stuartmorgan@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
@polina-c polina-c changed the title Re-land fix for not disposed TabController Re-land fix for not disposed TabController [prod-leak-fix] Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: leak tracking Issues and PRs related to memory leaks detected by leak_tracker 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.

_DefaultTabControllerState should dispose TabContoller instances.
2 participants