[Android] Fix app hang when PopModalAsync called immediately after PushModalAsync#32853
Closed
[Android] Fix app hang when PopModalAsync called immediately after PushModalAsync#32853
Conversation
….Yield - Add PresentationCompleted event to ModalFragment to signal when modal is fully presented - For non-animated modals, wait for PresentationCompleted before returning from PresentModal - Fire PresentationCompleted in OnStart() when dialog window is fully laid out - Add safety firing in OnDestroy() to prevent deadlocks if fragment is destroyed early - Add test case Issue32310 to verify the fix Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix app hang issue when calling PopModalAsync
[Android] Fix app hang when PopModalAsync called immediately after PushModalAsync
Nov 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Non-animated modals (
animated: false) return control before the AndroidDialogFragmentcompletes initialization. WhenPopModalAsyncis called immediately after (e.g., with a singleTask.Yield()), the pop operation fails silently, leaving a blank/hung screen.Fix: Introduce
PresentationCompletedevent onModalFragmentthat fires inOnStart()when the dialog is fully laid out. For non-animated modals,PresentModalnow awaits this event before returning—mirroring how animated modals already wait forAnimationEnded.PresentationCompletedevent andFirePresentationCompleted()helper (follows existingFireAnimationEnded()pattern)OnStart()afterdialog.Window.SetLayout()completesOnDestroy()to prevent deadlock if fragment destroyed earlyPresentationCompletedfor non-animated modals inPresentModalIssues Fixed
Fixes #32310
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.