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

TextPainter should dispatch creation and disposal events. #137416

Merged
merged 2 commits into from Oct 28, 2023

Conversation

ksokolovskyi
Copy link
Contributor

Description

Tests

  • Updates text_painter_test.dart to test TextPainter object creation and disposal dispatching;
  • Fixes memory leak in _SnackBarState;
  • Fixes memory leak in _SwitchPainter;
  • Fixes memory leak in _FlutterLogoPainter;
  • Fixes memory leak in RenderDecoratedBox;
  • Fixes memory leak in BannerPainter.

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.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Oct 27, 2023
@ksokolovskyi
Copy link
Contributor Author

cc @polina-c

@ksokolovskyi ksokolovskyi changed the title Instrumented TextPainter for leak tracking TextPainter should dispatch creation and disposal events. Oct 27, 2023
@@ -219,6 +219,12 @@ class _FlutterLogoPainter extends BoxPainter {
late TextPainter _textPainter;
late Rect _textBoundingRect;

@override
void dispose() {
_textPainter.dispose();
Copy link
Contributor

Choose a reason for hiding this comment

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

Now the TODO on line 218 is redundant?

test('TextPainter dispatches memory events', () async {
await expectLater(
await memoryEvents(() => TextPainter().dispose(), TextPainter),
areCreateAndDispose,
Copy link
Contributor

Choose a reason for hiding this comment

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

@polina-c Probably an unfortunate typo in leak_tracker_flutter_testing but shouldn't this be named as areCreatedAndDisposed ?

Copy link
Contributor

Choose a reason for hiding this comment

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

nope
the name is about events
the name states that the events are about creation and disposal, not that they are created and disposed

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. That indeed makes more sense.

Copy link
Contributor

@navaronbracke navaronbracke left a comment

Choose a reason for hiding this comment

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

Just skimming through (I tend to keep an eye on leak tracker things :) )

@@ -498,7 +500,15 @@ class TextPainter {
_locale = locale,
_strutStyle = strutStyle,
_textWidthBasis = textWidthBasis,
_textHeightBehavior = textHeightBehavior;
_textHeightBehavior = textHeightBehavior {
if (kFlutterMemoryAllocationsEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add TODO here: #137435

@ksokolovskyi
Copy link
Contributor Author

@polina-c, @navaronbracke thanks for the review.
I made some adjustments according to the latest comments. Could you please take a look again?

@polina-c polina-c merged commit fea5613 into flutter:master Oct 28, 2023
65 checks passed
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Oct 28, 2023
flutter/flutter@5907c97...a4ec627

2023-10-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from f5fbd9cd60c6 to 84dcb4fb9301 (1 revision) (flutter/flutter#137468)
2023-10-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from 03de8a41995b to f5fbd9cd60c6 (2 revisions) (flutter/flutter#137467)
2023-10-28 polinach@google.com Instrument more disposables. (flutter/flutter#137309)
2023-10-28 sokolovskyi.konstantin@gmail.com TextPainter should dispatch creation and disposal events. (flutter/flutter#137416)
2023-10-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from a76821199d9d to 03de8a41995b (2 revisions) (flutter/flutter#137464)
2023-10-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from f1e30b4b9f27 to a76821199d9d (3 revisions) (flutter/flutter#137462)
2023-10-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from 7e2aa68b2f27 to f1e30b4b9f27 (2 revisions) (flutter/flutter#137461)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 513e007ed682 to 7e2aa68b2f27 (1 revision) (flutter/flutter#137460)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 32bb5b057c86 to 513e007ed682 (3 revisions) (flutter/flutter#137457)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from f2ec263cebf9 to 32bb5b057c86 (1 revision) (flutter/flutter#137452)
2023-10-27 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 2.22.4 to 2.22.5 (flutter/flutter#137450)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 453a04dbf891 to f2ec263cebf9 (2 revisions) (flutter/flutter#137449)
2023-10-27 ditman@gmail.com [web] Add 'nonce' prop to flutter.js loadEntrypoint (flutter/flutter#137204)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 1e66c0ae7bda to 453a04dbf891 (1 revision) (flutter/flutter#137446)
2023-10-27 goderbauer@google.com Provide exception for listing an issue. (flutter/flutter#137092)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0bba9eeb8f5d to 1e66c0ae7bda (1 revision) (flutter/flutter#137442)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from a198ad4e740d to 0bba9eeb8f5d (1 revision) (flutter/flutter#137437)
2023-10-27 katelovett@google.com Bump goldctl in .ci.yaml (flutter/flutter#137441)

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
HugoOlthof pushed a commit to moneybird/packages that referenced this pull request Dec 13, 2023
…r#5255)

flutter/flutter@5907c97...a4ec627

2023-10-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from f5fbd9cd60c6 to 84dcb4fb9301 (1 revision) (flutter/flutter#137468)
2023-10-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from 03de8a41995b to f5fbd9cd60c6 (2 revisions) (flutter/flutter#137467)
2023-10-28 polinach@google.com Instrument more disposables. (flutter/flutter#137309)
2023-10-28 sokolovskyi.konstantin@gmail.com TextPainter should dispatch creation and disposal events. (flutter/flutter#137416)
2023-10-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from a76821199d9d to 03de8a41995b (2 revisions) (flutter/flutter#137464)
2023-10-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from f1e30b4b9f27 to a76821199d9d (3 revisions) (flutter/flutter#137462)
2023-10-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from 7e2aa68b2f27 to f1e30b4b9f27 (2 revisions) (flutter/flutter#137461)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 513e007ed682 to 7e2aa68b2f27 (1 revision) (flutter/flutter#137460)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 32bb5b057c86 to 513e007ed682 (3 revisions) (flutter/flutter#137457)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from f2ec263cebf9 to 32bb5b057c86 (1 revision) (flutter/flutter#137452)
2023-10-27 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 2.22.4 to 2.22.5 (flutter/flutter#137450)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 453a04dbf891 to f2ec263cebf9 (2 revisions) (flutter/flutter#137449)
2023-10-27 ditman@gmail.com [web] Add 'nonce' prop to flutter.js loadEntrypoint (flutter/flutter#137204)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 1e66c0ae7bda to 453a04dbf891 (1 revision) (flutter/flutter#137446)
2023-10-27 goderbauer@google.com Provide exception for listing an issue. (flutter/flutter#137092)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0bba9eeb8f5d to 1e66c0ae7bda (1 revision) (flutter/flutter#137442)
2023-10-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from a198ad4e740d to 0bba9eeb8f5d (1 revision) (flutter/flutter#137437)
2023-10-27 katelovett@google.com Bump goldctl in .ci.yaml (flutter/flutter#137441)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: text input Entering text in a text field or keyboard related problems 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.

None yet

3 participants