-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Fix App Unresponsive when prompting the user from a new page #31838
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
[Android] Fix App Unresponsive when prompting the user from a new page #31838
Conversation
|
Hey there @@devanathan-vaithiyanathan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
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.
Pull Request Overview
This PR fixes an issue where DisplayAlert, DisplayActionSheet, and DisplayPrompt would not appear when called from a new page's constructor or OnAppearing method on Android, causing the app to become unresponsive.
Key changes:
- Added handler readiness checks before executing dialog requests
- Implemented deferred execution using HandlerChanged event when handler is not ready
- Added comprehensive UI tests to validate the fix
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Controls/src/Core/Platform/AlertManager/AlertManager.Android.cs |
Implements the core fix by adding handler readiness checks and deferred execution logic for alert, action sheet, and prompt requests |
src/Controls/tests/TestCases.HostApp/Issues/Issue25585.cs |
Creates the UI test page that reproduces the issue by calling DisplayAlert from a page constructor |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25585.cs |
Implements the automated test that verifies the dialog appears correctly after navigating to a new page |
| new Label { Text = "If DisplayAlert is shown, the test passed" }, | ||
| } | ||
| }; | ||
| DisplayAlert("Hi", "This is from Constructor", "OK", "Cancel"); |
Copilot
AI
Oct 2, 2025
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.
The test case only validates DisplayAlert from the constructor. Consider adding test coverage for DisplayActionSheet and DisplayPrompt as well, since the fix addresses all three dialog types and they may have different behavior patterns.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| editText.RequestFocus(); | ||
| } | ||
|
|
||
| bool WaitForHandlerIfNeeded(IView sender, System.Action action) |
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.
Could be a public extension method useful for developers.
#31838) * Update AlertManager.Android.cs * Update AlertManager.Android.cs * Update AlertManager.Android.cs * Update AlertManager.Android.cs * Test case added * Update Issue25585.cs * Update Issue25585.cs * Update AlertManager.Android.cs * Update AlertManager.Android.cs * Curly braces added * unused namespace removed
#31838) * Update AlertManager.Android.cs * Update AlertManager.Android.cs * Update AlertManager.Android.cs * Update AlertManager.Android.cs * Test case added * Update Issue25585.cs * Update Issue25585.cs * Update AlertManager.Android.cs * Update AlertManager.Android.cs * Curly braces added * unused namespace removed
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!
Issue Details
DisplayPrompt/DisplayAlert/DisplayActionSheet don't display when called in new page constructor or OnAppearing.
Description of Change
The fix ensures alerts, action sheets, and prompts are only executed when the view’s Handler is ready. If the handler is not yet set, the action is deferred using the HandlerChanged event, so the UI request executes once the view is fully initialized. This ensures dialogs appear reliably on Android platform platforms
Issues Fixed
Fixes #25585
Tested the behavior in the following platforms.
Output Screenshot
Before.mov
After.mov