-
Notifications
You must be signed in to change notification settings - Fork 319
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
Conversation
Codecov Report
@@ 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 |
ba915e7
to
15daa64
Compare
@@ -62,6 +62,7 @@ protected void onFinishInflate() { | |||
protected void onDetachedFromWindow() { | |||
super.onDetachedFromWindow(); | |||
if (countdownAnimation != null) { | |||
countdownAnimation.removeAllListeners(); |
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'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.
15daa64
to
1f5fe7b
Compare
@Guardiola31337 thanks for testing that out, I updated the code to reflect your recommendations 🚀 |
1f5fe7b
to
ce7d83d
Compare
ce7d83d
to
a4b1090
Compare
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.
Still wondering how / where we should cancel the animation and remove the listener previously added
Line 154 in a4b1090
countdownAnimation.addListener(new AlertViewAnimatorListener(this)); |
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 🙏
@Guardiola31337 spotted this leak when testing 👁:
It seems this is reproducible when closing the
NavigationView
while theAlertView
is still showing / animating. I wasn't able to reproduce with thew newWeakReference
.We also have an existing check to cancel the animation when the
AlertView
is detached from the window.