-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix memory leaks in SnackBar [prod-leak-fix]
#147212
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 leaks in SnackBar [prod-leak-fix]
#147212
Conversation
|
cc @polina-c |
|
We have an internal 'Google testing' test failed. This means one of two:
Putting the test details here hoping they will help you to choose between the two. Test code: Error: |
|
That is a weird bug, it looks like an animation is not set when running the |
|
It is challenging to share internal code in a way that does not leak internal sensitive information. Let's try other approach. Let's see how many tests will fail in Flutter. If not many and they are easy to fix, we may want to keep it. And it may help us to figure out the internal failure. |
|
Sure, I added the |
| return reverseCurve == null || (_curveDirection ?? parent.status) != AnimationStatus.reverse; | ||
| } | ||
|
|
||
| bool _debugDisposed = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can use isDisposed defined on 425.
|
It seems states are used after disposal. Can it be that If yes, can we make the classes more resilient to usage after disposal and some test coverage for the resilience? |
Sure, I guess I should also remove what was done in perf: Add debugDispose to snackbar and curved animation (the debug time protection in asserts for usage after disposal?) ? |
For now you may want to replace debug asserts with debug prints in case of violation, so that we see if usage after disposal is causing failures in google testing, in case they are still here. |
|
Converted the PR to draft, as it is not intended for merge at the moment. |
|
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
@polina-c ci: Add debug prints to investigate failing ci adds some logs, do they show something in the google internal tests? |
|
I see print: The print is followed by the error: Does it help? |
|
🤔 I'm still confused with it haha. I can try to add more prints. Alternatively, I could do a check like that: if (_heightAnimation != null) {
snackBarTransition = AnimatedBuilder(
animation: _heightAnimation!,
builder: (BuildContext context, Widget? child) {
return Align(
alignment: AlignmentDirectional.topStart,
heightFactor: _heightAnimation!.value,
child: child,
);
},
child: snackBar,
);
} else {
snackBarTransition = child;
}but that looks wrong to me |
|
I do not know what is right thing to do here. I am open for experiments in different directions directions. Feel free to start tackling them in parallel by creating number of draft PRs that are intended to solve the same problem, to check how tests will react. :) |
|
Sure I can do that. Can you help me check if there are some useful logs from the commit debug: Add more prints ? |
|
Checking. |
|
# Conflicts: # packages/flutter/lib/src/material/snack_bar.dart
|
@polina-c It looks like fix: Use ValueListenableBuilder did the trick 😃 |
|
@polina-c Is there something else you want me to do on this? |
flutter/flutter@d2da1b2...39651e8 2024-05-15 [email protected] Roll Flutter Engine from d35a1a603c80 to bf1c6da0dd31 (1 revision) (flutter/flutter#148369) 2024-05-15 [email protected] Roll Flutter Engine from 55c62ff82c7e to d35a1a603c80 (4 revisions) (flutter/flutter#148367) 2024-05-15 [email protected] Roll Flutter Engine from a1d930a3a84d to 55c62ff82c7e (3 revisions) (flutter/flutter#148365) 2024-05-14 [email protected] Roll Flutter Engine from dfb5871260a6 to a1d930a3a84d (2 revisions) (flutter/flutter#148360) 2024-05-14 [email protected] Roll Flutter Engine from 1b508a071c96 to dfb5871260a6 (1 revision) (flutter/flutter#148356) 2024-05-14 49699333+dependabot[bot]@users.noreply.github.com Bump codecov/codecov-action from 4.3.1 to 4.4.0 (flutter/flutter#148355) 2024-05-14 [email protected] Fix memory leaks in `SnackBar` (flutter/flutter#147212) 2024-05-14 [email protected] Fix memory leaks in open upwards page transition (flutter/flutter#148046) 2024-05-14 [email protected] Fixes semantics ordering when there are multiple TextFields with pref� (flutter/flutter#148267) 2024-05-14 [email protected] Roll Flutter Engine from ae9ff69a0840 to 1b508a071c96 (2 revisions) (flutter/flutter#148351) 2024-05-14 [email protected] Add missing InputDecorator.hintText tests (flutter/flutter#148113) 2024-05-14 [email protected] Fix abi key for local golden file testing (flutter/flutter#148072) 2024-05-14 [email protected] Maintain the same layout constraints for item in the ReorderableList during dragging as before dragging. (flutter/flutter#147863) 2024-05-14 [email protected] test material text field example (flutter/flutter#147864) 2024-05-14 [email protected] Move toggleable to widget layer (flutter/flutter#148272) 2024-05-14 [email protected] Roll Flutter Engine from 08b44d906fab to ae9ff69a0840 (1 revision) (flutter/flutter#148341) 2024-05-14 [email protected] add another print trace to runInView (flutter/flutter#148337) 2024-05-14 [email protected] Roll Flutter Engine from 7bf865774d06 to 08b44d906fab (4 revisions) (flutter/flutter#148338) 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 [email protected],[email protected] 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
flutter/flutter@d2da1b2...39651e8 2024-05-15 [email protected] Roll Flutter Engine from d35a1a603c80 to bf1c6da0dd31 (1 revision) (flutter/flutter#148369) 2024-05-15 [email protected] Roll Flutter Engine from 55c62ff82c7e to d35a1a603c80 (4 revisions) (flutter/flutter#148367) 2024-05-15 [email protected] Roll Flutter Engine from a1d930a3a84d to 55c62ff82c7e (3 revisions) (flutter/flutter#148365) 2024-05-14 [email protected] Roll Flutter Engine from dfb5871260a6 to a1d930a3a84d (2 revisions) (flutter/flutter#148360) 2024-05-14 [email protected] Roll Flutter Engine from 1b508a071c96 to dfb5871260a6 (1 revision) (flutter/flutter#148356) 2024-05-14 49699333+dependabot[bot]@users.noreply.github.com Bump codecov/codecov-action from 4.3.1 to 4.4.0 (flutter/flutter#148355) 2024-05-14 [email protected] Fix memory leaks in `SnackBar` (flutter/flutter#147212) 2024-05-14 [email protected] Fix memory leaks in open upwards page transition (flutter/flutter#148046) 2024-05-14 [email protected] Fixes semantics ordering when there are multiple TextFields with pref� (flutter/flutter#148267) 2024-05-14 [email protected] Roll Flutter Engine from ae9ff69a0840 to 1b508a071c96 (2 revisions) (flutter/flutter#148351) 2024-05-14 [email protected] Add missing InputDecorator.hintText tests (flutter/flutter#148113) 2024-05-14 [email protected] Fix abi key for local golden file testing (flutter/flutter#148072) 2024-05-14 [email protected] Maintain the same layout constraints for item in the ReorderableList during dragging as before dragging. (flutter/flutter#147863) 2024-05-14 [email protected] test material text field example (flutter/flutter#147864) 2024-05-14 [email protected] Move toggleable to widget layer (flutter/flutter#148272) 2024-05-14 [email protected] Roll Flutter Engine from 08b44d906fab to ae9ff69a0840 (1 revision) (flutter/flutter#148341) 2024-05-14 [email protected] add another print trace to runInView (flutter/flutter#148337) 2024-05-14 [email protected] Roll Flutter Engine from 7bf865774d06 to 08b44d906fab (4 revisions) (flutter/flutter#148338) 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 [email protected],[email protected] 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
SnackBarSnackBar [prod-leak-fix]
Part of #141198
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.