Skip to content

[video_player] Activate leak testing #8379

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

Merged

Conversation

ValentinVignal
Copy link
Contributor

The package manipulates disposable objects. This PR activates leak testing to make sure disposable objects are correctly disposed.

It also fixes the memory leak warnings from the tests

See the documentation: https://github.com/dart-lang/leak_tracker/blob/main/doc%2Fleak_tracking%2FDETECT.md

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@ValentinVignal
Copy link
Contributor Author

Since I modified only the tests, I think this PR is eligible for the tags override: no versioning needed and override: no changelog needed

@ValentinVignal
Copy link
Contributor Author

cc @polina-c

@@ -698,6 +723,7 @@ void main() {
expect(controller.value.isPlaying, isTrue);

await controller.pause();
await tester.runAsync(controller.dispose);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For those ones, I didn't manage to make the test pass without using runAsync.

If I use

addTearDown(() {
  controller.dispose();
});

or

// end of test
unawaited(controller.dispose());
// a lot of 
tester.pump();
tester.pump();

it doesn't fix the memory leak.

If I use

addTearDown(controller.dispose());

or

// end of test
await controller.dispose();

the test hangs and times out.

Do you have an idea on how to do it better?

Copy link

Choose a reason for hiding this comment

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

It looks smelly for me that dispose is async. But, it is test only class, so it is ok.
And thus runAsync makes perfect sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are these tests doing anything to test the real implementation of this class (VideoPlayerController)? In the actual usage of dispose there are asynchronous happenings. I'm not super familiar with how the leak testing works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I remember, they do. Those controller were created and I had issues making the tests wait for the dispose methods to finish

@polina-c polina-c added the a: leak tracking Issues and PRs related to memory leaks detected by leak_tracker label Jan 7, 2025
@ValentinVignal ValentinVignal force-pushed the video-player/activate-leak-testing branch from b1e7de6 to 19261d2 Compare January 15, 2025 13:48
@ValentinVignal
Copy link
Contributor Author

Any thoughts on this PR @tarrinneal ?

@@ -33,6 +33,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
leak_tracker_flutter_testing: any
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what our version policies are for dev_deps. @stuartmorgan is there guidance on 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.

For more context, here is the documentation: https://prudential-ps.atlassian.net/browse/GTP-2844

Put any instead of version, because the version is defined by your Flutter SDK.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, generally this would be a very bad idea, but it's specifically needed for the case of this package (IIUC because it's not in the SDK, so can't use sdk:, but is pinned by Flutter).

@@ -698,6 +723,7 @@ void main() {
expect(controller.value.isPlaying, isTrue);

await controller.pause();
await tester.runAsync(controller.dispose);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these tests doing anything to test the real implementation of this class (VideoPlayerController)? In the actual usage of dispose there are asynchronous happenings. I'm not super familiar with how the leak testing works.

@tarrinneal
Copy link
Contributor

@stuartmorgan another question on this one. I think it should be exempt from changelog and versioning as it is only changing tests and dev-dependencies.

Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

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

lgtm sans response from Stuart about versioning.

@stuartmorgan-g stuartmorgan-g added override: no versioning needed Override the check requiring version bumps for most changes override: no changelog needed Override the check requiring CHANGELOG updates for most changes labels Jan 23, 2025
@stuartmorgan-g
Copy link
Contributor

Version/changelog override: dev-only changes are exempt

@stuartmorgan-g
Copy link
Contributor

@stuartmorgan another question on this one. I think it should be exempt from changelog and versioning as it is only changing tests and dev-dependencies.

That's correct; the version-check tooling just hasn't been taught to do analysis deeper than file path level, so it can't currently distinguish between pubspec.yaml chages that need publishing, and those that only affect dev_dependencies. I think I filed it at some point, but it hasn't been a priority since it's easy to override.

@tarrinneal
Copy link
Contributor

@stuartmorgan another one for your list

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

This shouldn't need a second approval, but LGTM

@ValentinVignal ValentinVignal added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 23, 2025
@auto-submit auto-submit bot merged commit 4e53528 into flutter:main Jan 23, 2025
77 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 23, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 23, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 23, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 24, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 24, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 24, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 27, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Jan 27, 2025
flutter/packages@3d3ab7b...258f6dc

2025-01-24 adsonpleal@gmail.com [shared_preferences] Add shared
preferences devtool (flutter/packages#8494)
2025-01-24 tarrinneal@gmail.com [shared_preferences] update List<String>
encode/decode (flutter/packages#8335)
2025-01-24 engine-flutter-autoroll@skia.org Manual roll Flutter from
c1561a4 to c1ffaa9 (21 revisions) (flutter/packages#8498)
2025-01-24 stuartmorgan@google.com [ios_platform_images] Switch to
`loadImage` (flutter/packages#8216)
2025-01-24 mchudy@users.noreply.github.com [camera] Remove OCMock from
CameraExposureTests and CameraFocusTests (flutter/packages#8351)
2025-01-24 tarrinneal@gmail.com [shared_preferences] Tool for migrating
from legacy shared_preferences to shared_preferences_async
(flutter/packages#8229)
2025-01-23 stuartmorgan@google.com Revert "[shared_preferences] Add
shared preferences devtool" (flutter/packages#8493)
2025-01-23 20254485+kaboc@users.noreply.github.com [go_router] Fix
return type of current state getter to be non-nullable
(flutter/packages#8173)
2025-01-23 engine-flutter-autoroll@skia.org Manual roll Flutter from
b2f515f to c1561a4 (18 revisions) (flutter/packages#8491)
2025-01-23 tarrinneal@gmail.com [pigeon] fixes event channel dart
instance name usage and adds test (flutter/packages#8483)
2025-01-23 51104750+AffanShaikhsurab@users.noreply.github.com [go
_route] fragment parameter added (flutter/packages#8232)
2025-01-23 mchudy@users.noreply.github.com [in_app_purchase] Update
in_app_purchase_android version in in_app_purchase
(flutter/packages#8463)
2025-01-23 stuartmorgan@google.com [image_picker] Reference alternate
macOS implementations (flutter/packages#8487)
2025-01-23 32538273+ValentinVignal@users.noreply.github.com [rfw]
Activate leak testing (flutter/packages#8370)
2025-01-23 32538273+ValentinVignal@users.noreply.github.com
[video_player] Activate leak testing (flutter/packages#8379)
2025-01-23 engine-flutter-autoroll@skia.org Manual roll Flutter from
b9e86a5 to b2f515f (42 revisions) (flutter/packages#8482)
2025-01-23 olli.helenius@codemate.com [camera] Add API support query for
image streaming (app-facing) (flutter/packages#8422)
2025-01-23 engine-flutter-autoroll@skia.org Manual roll Flutter from
b9e86a5 to eb6af3d (13 revisions) (flutter/packages#8473)
2025-01-23 adsonpleal@gmail.com [shared_preferences] Add shared
preferences devtool (flutter/packages#8322)

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-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
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
androidseb pushed a commit to androidseb/packages that referenced this pull request Jun 8, 2025
The package manipulates disposable objects. This PR activates leak testing to make sure disposable objects are correctly disposed.

It also fixes the memory leak warnings from the tests

See the documentation: https://github.com/dart-lang/leak_tracker/blob/main/doc%2Fleak_tracking%2FDETECT.md
FMorschel pushed a commit to FMorschel/packages that referenced this pull request Jun 9, 2025
The package manipulates disposable objects. This PR activates leak testing to make sure disposable objects are correctly disposed.

It also fixes the memory leak warnings from the tests

See the documentation: https://github.com/dart-lang/leak_tracker/blob/main/doc%2Fleak_tracking%2FDETECT.md
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 override: no changelog needed Override the check requiring CHANGELOG updates for most changes override: no versioning needed Override the check requiring version bumps for most changes p: video_player
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants