-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Possible window leak #9
Comments
when modal out animation ends, it will execute the super dismiss() https://github.com/pedant/sweet-alert-dialog/blob/master/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java#L104 . When the dialog pops up, user must press "back" key, or click buttons that will call SweetAlertDialog.dismiss(). If you hide the dialog, remember to dismiss it when activity destroy. I can't realize, under what situation does it cause a window leak? |
Yes I saw this code, but since it's executed in a different thread (asyncly), so if we do, e.g.:
Then it's most likely that the parent activity finishes before we actually dismiss(sweetAlertDialog.super.dismiss();) the dialog. |
Hi, @UglyTroLL . I do a test in such a situation:
then log at SweetAlertDialog dismiss, Modal out animation end, calling super.dismiss.
every time I clicked the button, I got the same output. |
Yes, but the sequence is not guaranteed, since it's, still, multi-threaded. That's why I put 'Possible' in the title, since I saw the 'window leak' error several times when I was testing on the real device. |
Sorry about my fool. I have realized the problem.the better solution is super dismiss should not be overwrite, maybe implementing dismiss with a flag param. thank you, I will fix it soon! |
That would be great, thanks! |
overwrite cancel() 32edea2, so users press back-key or touch outside dialog that dismissWithAnimation() can be called. |
Cool! Thanks! |
Since the dismiss() method is doing some async work there(modal out animation, https://github.com/pedant/sweet-alert-dialog/blob/master/library/src/main/java/cn/pedant/SweetAlert/SweetAlertDialog.java#L310 ) , Dialog.dismiss() may not be invoked before the container activity actually stopped/finished.
Would be great if we can provide some sync dismiss() method there.
The text was updated successfully, but these errors were encountered: