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 AlertView animation leak #1667

Merged
merged 1 commit into from
Jan 16, 2019
Merged

Fix AlertView animation leak #1667

merged 1 commit into from
Jan 16, 2019

Conversation

danesfeder
Copy link
Contributor

@danesfeder danesfeder commented Jan 14, 2019

@Guardiola31337 spotted this leak when testing 👁:

screenshot_20190111-215316

It seems this is reproducible when closing the NavigationView while the AlertView is still showing / animating. I wasn't able to reproduce with thew new WeakReference.

We also have an existing check to cancel the animation when the AlertView is detached from the window.

@danesfeder danesfeder added bug Defect to be fixed. ✓ ready for review labels Jan 14, 2019
@danesfeder danesfeder added this to the v0.27.0 milestone Jan 14, 2019
@danesfeder danesfeder self-assigned this Jan 14, 2019
@codecov-io
Copy link

codecov-io commented Jan 14, 2019

Codecov Report

Merging #1667 into master will increase coverage by 0.08%.
The diff coverage is 57.14%.

@@             Coverage Diff             @@
##             master   #1667      +/-   ##
===========================================
+ Coverage     26.21%   26.3%   +0.08%     
- Complexity      787     790       +3     
===========================================
  Files           196     197       +1     
  Lines          8342    8345       +3     
  Branches        598     598              
===========================================
+ Hits           2187    2195       +8     
+ Misses         5958    5952       -6     
- Partials        197     198       +1

@danesfeder danesfeder force-pushed the dan-alert-leak branch 4 times, most recently from ba915e7 to 15daa64 Compare January 15, 2019 18:20
@@ -62,6 +62,7 @@ protected void onFinishInflate() {
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (countdownAnimation != null) {
countdownAnimation.removeAllListeners();
Copy link
Contributor

Choose a reason for hiding this comment

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

I've tested this and it's not being called because countdownAnimation is null when onDetachedFromWindow is called - causing the leak.

I believe best approach here is bring the WeakReference back and remove onDetachedFromWindow code.

@danesfeder
Copy link
Contributor Author

@Guardiola31337 thanks for testing that out, I updated the code to reflect your recommendations 🚀

Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

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

Still wondering how / where we should cancel the animation and remove the listener previously added

which would remove the necessity of making AlertView a WeakReference but for now it's working and couldn't reproduce the leak anymore 🎉 We can revisit later.

Thanks @danesfeder for addressing the feedback 🙏

@danesfeder danesfeder merged commit 4ed2634 into master Jan 16, 2019
@danesfeder danesfeder deleted the dan-alert-leak branch January 16, 2019 13:53
@danesfeder danesfeder mentioned this pull request Jan 16, 2019
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defect to be fixed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants