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

Fix memory leak in RenderAnimatedSize #133653

Merged
merged 3 commits into from Sep 11, 2023

Conversation

ksokolovskyi
Copy link
Contributor

@ksokolovskyi ksokolovskyi commented Aug 30, 2023

AnimationController and CurvedAnimation objects were not disposed in RenderAnimatedSize.

Description

Tests

  • Updates animated_size_test.dart to test that AnimationController and CurvedAnimation are disposed after RenderSize disposal.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

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.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Aug 30, 2023
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Hi @ksokolovskyi thanks for contributing! Is there an open issue this PR would resolve? Also, the bot comment provides instructions for seeking test exemption.

@ksokolovskyi
Copy link
Contributor Author

ksokolovskyi commented Aug 30, 2023

Hi @Piinks, thank you for the review!

  1. I don't have a specific issue for this PR. I've found out that there is a memory leak in the RenderAnimatedSize and made a PR with a fix. Do I need to create an issue?
  2. Asked for a test exemption in #hackers chat.

@Hixie
Copy link
Contributor

Hixie commented Aug 30, 2023

test-exempt: will be tested later when we can catch these leaks

@@ -351,6 +351,8 @@ class RenderAnimatedSize extends RenderAligningShiftedBox {
@override
void dispose() {
_clipRectLayer.layer = null;
_controller.dispose();
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can add a test to check the state of controller after the widgets removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xu-baolin thank you for the advice. I've added the test. Could you please take a look?

Copy link
Member

Choose a reason for hiding this comment

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

This change looks good to me, thanks for your nice job.
Could you file a new issue to track this problem and link it to this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, of course, I will create a new issue.

@ksokolovskyi
Copy link
Contributor Author

@xu-baolin Here is the issue: #133903

///
/// The animation itself is exposed by the [animation] property.
@visibleForTesting
AnimationController get controller => _controller;
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 a public API not only for testing, right?

We can refer to the implementation of DragGestureRecognizer.debugLastPendingEventTimestamp and document that it is only available for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously _controller and _animation were private because AnimatedSize is a kind of implicit animation, so users don't need to have access to the animation controller.
Are you sure that we need to expose them to the users and create additional getters for testing only?

Copy link
Member

Choose a reason for hiding this comment

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

I mean we should not add new APIs to AnimatedSize.

If I'm not mistaken, the @visibleForTesting annotation is not meant to be visible only to testing.

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 got your point, thanks.
Could you please review the latest commit?

Copy link
Member

Choose a reason for hiding this comment

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

There is a problem with the CI infra, let's wait for it to be fixed.

Copy link
Member

@xu-baolin xu-baolin left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks for finding and fixing this bug.
@Piinks Hi, could you take a second review on this : )

@XilaiZhang
Copy link
Contributor

XilaiZhang commented Sep 8, 2023

hopefully people wouldn't mind me test some Google Testing logic on this PR (only involves a few extra clicks on "update branch" button) while Kate is OOO. choosing this PR since it is from an external contributor and has gotten approval from a flutter hacker member.

update: indeed found a bug and sent out cl/563861992 for review.

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

This LGTM, thank you for contributing @ksokolovskyi!

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 11, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 11, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Sep 11, 2023

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

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 11, 2023
@XilaiZhang XilaiZhang removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 11, 2023
@XilaiZhang
Copy link
Contributor

Umm quick question, there seems to be 1k+ failures reported in Google Testing in previous runs from the commits, are those failures considered to be unrelated to this PR? thank you!

@Piinks
Copy link
Contributor

Piinks commented Sep 11, 2023

are those failures considered to be unrelated to this PR?

I think so

@Piinks
Copy link
Contributor

Piinks commented Sep 11, 2023

When I checked, the 1k+ failures looked like infra failures. Like the tests failed to build and run, which would not be due to this change.

@XilaiZhang
Copy link
Contributor

ah cool, thanks for verifying!

@XilaiZhang XilaiZhang added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 11, 2023
@auto-submit auto-submit bot merged commit e7058f5 into flutter:master Sep 11, 2023
66 checks passed
@Piinks
Copy link
Contributor

Piinks commented Sep 11, 2023

Looks like it merged without running Google testing this time @XilaiZhang

@XilaiZhang
Copy link
Contributor

yeah sorry i was testing out a few things on this PR today and temporarily made it disappear (sent cl/564489978 as fix)

last time i checked this PR it created cl/564478862 and the results at test/564478862 was green so I merged it.

@ksokolovskyi
Copy link
Contributor Author

@xu-baolin @Piinks @XilaiZhang thanks for the review!

victorgalo pushed a commit to victorgalo/flutter that referenced this pull request Sep 11, 2023
`AnimationController` and `CurvedAnimation` objects were not disposed in `RenderAnimatedSize`.

### Description
- Fixes flutter#133903;
- Adds the missing `dispose()` calls for `AnimationController` and `CurvedAnimation` in `RenderAnimatedSize`.

### Tests
- Updates `animated_size_test.dart` to test that `AnimationController` and `CurvedAnimation` are disposed after `RenderSize` disposal.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Sep 12, 2023
flutter/flutter@219efce...4e7a07a

2023-09-12 katelovett@google.com Remove chip tooltip deprecations (flutter/flutter#134486)
2023-09-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 8a8ddaeecf8a to d4698c65aa8d (2 revisions) (flutter/flutter#134553)
2023-09-12 katelovett@google.com Remove deprecated TextSelectionOverlay.fadeDuration (flutter/flutter#134485)
2023-09-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 25be03186d82 to 8a8ddaeecf8a (1 revision) (flutter/flutter#134545)
2023-09-12 engine-flutter-autoroll@skia.org Roll Packages from ef0c65e to e04ba88 (5 revisions) (flutter/flutter#134546)
2023-09-12 47866232+chunhtai@users.noreply.github.com Revert "Adds a parent scope TraversalEdgeBehavior and fixes modal rou� (flutter/flutter#134550)
2023-09-12 fluttergithubbot@gmail.com Marks Windows_android channels_integration_test_win to be unflaky (flutter/flutter#133129)
2023-09-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4091167e402d to 25be03186d82 (1 revision) (flutter/flutter#134536)
2023-09-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 54175da7ba90 to 4091167e402d (1 revision) (flutter/flutter#134532)
2023-09-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 85f3f02e5c37 to 54175da7ba90 (2 revisions) (flutter/flutter#134531)
2023-09-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 1369ab35aaa7 to 85f3f02e5c37 (1 revision) (flutter/flutter#134519)
2023-09-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 2f1efe5967f3 to 1369ab35aaa7 (1 revision) (flutter/flutter#134512)
2023-09-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4d8265cbc133 to 2f1efe5967f3 (3 revisions) (flutter/flutter#134511)
2023-09-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from ee7215553deb to 4d8265cbc133 (1 revision) (flutter/flutter#134506)
2023-09-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6ddee4423d2c to ee7215553deb (2 revisions) (flutter/flutter#134505)
2023-09-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from a98348946d61 to 6ddee4423d2c (1 revision) (flutter/flutter#134490)
2023-09-12 xubaolin@oppo.com [New feature] Allowing the `ListView` slivers to have different extents while still having scrolling performance (flutter/flutter#131393)
2023-09-12 engine-flutter-autoroll@skia.org Roll Flutter Engine from 8389ad914b21 to a98348946d61 (4 revisions) (flutter/flutter#134487)
2023-09-12 kouhei.seino@woven-planet.global ScaleGestureRecognizer: make pointerCount public (flutter/flutter#127310)
2023-09-11 chinmay@blend.to Fix DataTable example not being scrollable (flutter/flutter#131556)
2023-09-11 engine-flutter-autoroll@skia.org Roll Flutter Engine from 06696e768c1b to 8389ad914b21 (2 revisions) (flutter/flutter#134469)
2023-09-11 christopherfujino@gmail.com [flutter_tools] disallow -O0 for flutter build web (flutter/flutter#134185)
2023-09-11 sokolovskyi.konstantin@gmail.com Cover focus tests with leak tracking (flutter/flutter#134457)
2023-09-11 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0774ddcda9b0 to 06696e768c1b (4 revisions) (flutter/flutter#134462)
2023-09-11 sokolovskyi.konstantin@gmail.com Fix memory leak in RenderAnimatedSize (flutter/flutter#133653)
2023-09-11 engine-flutter-autoroll@skia.org Roll Flutter Engine from e42fd367adcb to 0774ddcda9b0 (1 revision) (flutter/flutter#134447)
2023-09-11 engine-flutter-autoroll@skia.org Roll Flutter Engine from d593002b7159 to e42fd367adcb (1 revision) (flutter/flutter#134444)
2023-09-11 engine-flutter-autoroll@skia.org Roll Packages from aaae5ef to ef0c65e (6 revisions) (flutter/flutter#134445)
2023-09-11 engine-flutter-autoroll@skia.org Roll Flutter Engine from 2b5961cbc40d to d593002b7159 (3 revisions) (flutter/flutter#134439)
2023-09-11 polinach@google.com Mark leak: instances of OpacityLayer, created by _RenderChip, should be disposed. (flutter/flutter#134395)

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://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 framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory Leak: RenderAnimatedSize doesn't dispose AnimationController and CurvedAnimation
5 participants