-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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 racey dialog dismissal in PlacePickerActivity
#13461
base: main
Are you sure you want to change the base?
Conversation
app/src/main/java/org/thoughtcrime/securesms/maps/PlacePickerActivity.java
Outdated
Show resolved
Hide resolved
.../org/thoughtcrime/securesms/components/settings/conversation/ConversationSettingsFragment.kt
Outdated
Show resolved
Hide resolved
...ava/org/thoughtcrime/securesms/conversation/mutiselect/forward/MultiselectForwardFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/thoughtcrime/securesms/conversationlist/ConversationListFragment.java
Outdated
Show resolved
Hide resolved
...sms/groups/ui/invitesandrequests/invite/GroupLinkInviteFriendsBottomSheetDialogFragment.java
Outdated
Show resolved
Hide resolved
...ava/org/thoughtcrime/securesms/recipients/ui/sharablegrouplink/ShareableGroupLinkFragment.kt
Outdated
Show resolved
Hide resolved
@alex-signal I added another commit with your requested changes. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been closed due to inactivity. |
Still current, please reopen. |
This reverts commit c6f4a01.
Avoids a race condition when dismiss is delayed because the progress bar hadn't been shown for long enough, while avoiding the flickering that would be caused when immediately dismissing the dialog earlier.
In case `dismiss` (with delay) is called during an activity and the activity is consequently destroyed, and calls `dismissNow` in the process of its cleanup (i.e. in `onDestroy`), the delayed `dismiss` callback could still try to dismiss the dialog, causing an `IllegalArgumentException: View[…] not attached to window manager`. To avoid this faulty behavior, the delayed callbacks are removed whenever `dismissNow` is called.
42cee93
to
79e84b1
Compare
In the meantime, @greyson-signal fixed the crash that this PR also fixes with c6f4a01, but the dialog view still leaks. With the implementation provided in this PR, the view is not leaked as the dialog is destroyed as soon as the lifecycle owner that it is attached to is destroyed. Therefore I consider reversing c6f4a01 and applying the changes from this PR to be an improvement; I updated the branch to reflect these suggested changes. |
First time contributor checklist
Contributor checklist
Fixes #1234
syntaxDescription
The first commit avoids a race condition with closing the location picker map for location sharing where the following exception would occur:
This was because
dismiss
, together with its delay, could be executed after the activity that contained the dialog,PlacePickerActivity
, had already been destroyed. This faulty behavior can be reproduced more easily when artificially increasing the minimum time that the dialog should be shown. Instead of potentially scheduling a dismissal for the future usingdismiss
,dismissNow
is now called duringonDestroy
.The second commit avoids similar problems in the future, because it ensures that the delayed dismiss callback is always cancelled when
dismissNow
is called (which it should be whenever the activity containing the progress bar is closed for some reason, which may be in between adismiss
call and thedismiss
-scheduled delayed dismissal.The second commit could be left out as the first one already fixes the crash I mentioned above, but I would recommend to add it nonetheless.