packages icon indicating copy to clipboard operation
packages copied to clipboard

[go_router] Use `leak_tracker_flutter_testing`

Open ValentinVignal opened this issue 1 year ago • 18 comments

Activate leak_tracker_flutter_testing in the tests to detect memory leak issues.

cc @polina-c

Pre-launch Checklist

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

ValentinVignal avatar Feb 27 '24 10:02 ValentinVignal

@polina-c Is there an issue to link this PR to?

ValentinVignal avatar Feb 27 '24 10:02 ValentinVignal

Because go_router depends on flutter_test from sdk which depends on leak_tracker_flutter_testing 3.0.3, leak_tracker_flutter_testing 3.0.3 is required.
So, because go_router depends on leak_tracker_flutter_testing ^2.0.1, version solving failed.

But leak_tracker_flutter_testing ^2.0.1 is the version available on stabe. @polina-c how can I make it work?

ValentinVignal avatar Feb 27 '24 14:02 ValentinVignal

Because go_router depends on flutter_test from sdk which depends on leak_tracker_flutter_testing 3.0.3, leak_tracker_flutter_testing 3.0.3 is required.
So, because go_router depends on leak_tracker_flutter_testing ^2.0.1, version solving failed.

But leak_tracker_flutter_testing ^2.0.1 is the version available on stabe. @polina-c how can I make it work?

Will investigate. Thank you. Converted the PR to draft for now.

polina-c avatar Feb 27 '24 16:02 polina-c

Because go_router depends on flutter_test from sdk which depends on leak_tracker_flutter_testing 3.0.3, leak_tracker_flutter_testing 3.0.3 is required.
So, because go_router depends on leak_tracker_flutter_testing ^2.0.1, version solving failed.

But leak_tracker_flutter_testing ^2.0.1 is the version available on stabe. @polina-c how can I make it work?

Will investigate. Thank you. Converted the PR to draft for now.

Okay, it should be leak_tracker_flutter_testing: any in pubspec.yaml to pick up the version of leak tracker from sdk. Thanks for raising this. I will update documentation.

polina-c avatar Feb 27 '24 22:02 polina-c

Great thank you! I changed it in chore: Use any version for leak_tracker_flutter_testing

ValentinVignal avatar Feb 28 '24 02:02 ValentinVignal

I see tests are failing. And they are failing because of leaks. And many of them are originated by flutter itself.

For example, leaking "_NotAnnounced" was cleaned up this week in Flutter master.

It seems packages that use stable should not be early adopters of leak tracker. So, let's shelve this PR till leak_tracker is released and recommended for stable.

Thank you for the experiment. It helped:

  1. To understand go_router has leaks.
  2. To document that version should be any.

Converting this to draft.

polina-c avatar Feb 28 '24 22:02 polina-c

@chunhtai what do you want me to do? Maybe I can remove leak_tracker_flutter_testing from the pubspec.yaml and revert the flutter_test_config.dart but keep the changes to prepare for when leak_tracker_flutter_testing can be used ?

ValentinVignal avatar Feb 29 '24 01:02 ValentinVignal

@chunhtai what do you want me to do? Maybe I can remove leak_tracker_flutter_testing from the pubspec.yaml and revert the flutter_test_config.dart but keep the changes to prepare for when leak_tracker_flutter_testing can be used ?

Yes, I like it: to merge fixes, while postponing regression testing. @chunhtai, how does it sound for you?

polina-c avatar Feb 29 '24 16:02 polina-c

@chunhtai what do you want me to do? Maybe I can remove leak_tracker_flutter_testing from the pubspec.yaml and revert the flutter_test_config.dart but keep the changes to prepare for when leak_tracker_flutter_testing can be used ?

Yes, I like it: to merge fixes, while postponing regression testing. @chunhtai, how does it sound for you?

chunhtai is unavailable at the moment I think we can proceed with merging the change.

polina-c avatar Mar 06 '24 18:03 polina-c

I removed the leak_tracker_flutter_testing from the pubspec.yaml and revert the flutter_test_config.dart in test: Disable leak tracking

ValentinVignal avatar Mar 07 '24 01:03 ValentinVignal

'Linux analyze_legacy N-2' is failing because HeroController did not have method dispose yet.

@johnpryan, is this legacy job fixed forever or we can upgrade it for newer versions of flutter?

polina-c avatar Mar 07 '24 01:03 polina-c

'Linux analyze_legacy N-2' is failing because HeroController did not have method dispose yet.

@johnpryan, is this legacy job fixed forever or we can upgrade it for newer versions of flutter?

More information: https://github.com/flutter/packages/blob/main/.ci/legacy_project/README.md

@ValentinVignal, invoked dispose does not exist for this job, that is on Flutter 2.0.6. What is minimal version of Flutter that has this method? We either need to increase oldest supported version of flutter, or not to add this missing dispose (that may cause memory leaks)

@stuartmorgan, are you right person to help here? Is it ok to stop supporting 2.0.6 and increase minimal supported version a little?

polina-c avatar Mar 07 '24 17:03 polina-c

@stuartmorgan, are you right person to help here? Is it ok to stop supporting 2.0.6 and increase minimal supported version a little?

The earliest version of Flutter that any package in this repo is allowed to support (enforced by CI) is 3.13, so I don't really understand the question.

If N-2 is failing, then the PR doesn't work in 3.13.9. It's fine to drop 3.13 per the wiki, but that's unrelated to 2.0.6.

stuartmorgan-g avatar Mar 07 '24 17:03 stuartmorgan-g

Thanks.

I took 2.0.6 from https://github.com/flutter/packages/blob/main/.ci/legacy_project/README.md, but now i see it is just very first supported version.

polina-c avatar Mar 07 '24 17:03 polina-c

I'm a bit unsure of what I should do, should I stop using HeroController.dispose or should I make a change to the pipeline?

ValentinVignal avatar Mar 08 '24 01:03 ValentinVignal

I took 2.0.6 from https://github.com/flutter/packages/blob/main/.ci/legacy_project/README.md, but now i see it is just very first supported version.

That's actually unrelated to analyze_legacy; it's for the legacy native build step in android_build_all_packages.

stuartmorgan-g avatar Mar 08 '24 14:03 stuartmorgan-g

I'm a bit unsure of what I should do, should I stop using HeroController.dispose or should I make a change to the pipeline?

To choose between these two options we need to find out what pipeline change is needed. Then we will decide if this change makes sense or if it is better not to use dispose for now and instead create tech debt issue and leave TODO to dispose when all supported versions of flutter have the dispose. Does it help?

polina-c avatar Mar 08 '24 22:03 polina-c

@polina-c After looking at it, it is because HeroControlle.dispose was released in flutter 3.16.x

  • https://github.com/flutter/flutter/pull/133951
  • https://docs.flutter.dev/release/release-notes/release-notes-3.16.0 So I had to increase the minimum flutter version of flutter to ^3.16.0

Is that okay? Or is it too soon?

ValentinVignal avatar Mar 11 '24 11:03 ValentinVignal