-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] -Picker dialog causes crash when page is popped while dialo… #31747
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
Conversation
|
Hey there @@sheiksyedm! 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 a crash on Android that occurs when a Picker dialog is open and the page is navigated away (popped). The fix ensures proper cleanup of the picker dialog in the DisconnectHandler method to prevent resource leaks and crashes.
- Adds dialog cleanup logic to
DisconnectHandlerin the Android picker handler - Includes comprehensive UI tests to verify the fix works correctly
- Addresses a regression introduced in PR #29068
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Core/src/Handlers/Picker/PickerHandler.Android.cs |
Adds dialog cleanup in DisconnectHandler to prevent crashes when page is popped |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31731.cs |
NUnit test that verifies picker dialog doesn't crash when page is popped |
src/Controls/tests/TestCases.HostApp/Issues/Issue31731.cs |
Host app test page that reproduces the crash scenario with auto-navigation |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
/backport to release/9.0.1xx-sr11 |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Started backporting to release/9.0.1xx-sr11: https://github.com/dotnet/maui/actions/runs/17987125383 |
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| { | ||
| _dialog.ShowEvent -= OnDialogShown; | ||
| _dialog.DismissEvent -= OnDialogDismiss; | ||
| _dialog.Hide(); |
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.
@sheiksyedm why is this hide vs dismiss?
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.
@PureWeen Dismiss() is the proper approach to completely clean up the dialog, whereas Hide() only hides the dialog. I have now updated the code to use Dismiss() instead of Hide(). Previously, I had referred to Hide() from the other picker classes. I have now completed the changes to use Dismiss() in those pickers as well.
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.
Hide() makes the dialog invisible but may not fully clean up resources
Dismiss() properly dismisses the dialog and triggers cleanup
In this case, Dismiss have more sense.
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
The base branch was changed.
|
/azp run MAUI-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run MAUI-DeviceTests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/backport to release/9.0.1xx-sr12 |
|
Started backporting to release/9.0.1xx-sr12: https://github.com/dotnet/maui/actions/runs/18353516997 |
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
This pull request addresses a crash on Android that occurs when a
Pickerdialog is open and the page is popped (navigated away). The fix ensures the dialog is properly cleaned up when the handler disconnects.Issues Fixed
Ensured the
Pickerdialog is dismissed and disposed inDisconnectHandlerto prevent crashes when the page is popped while the dialog is open (PickerHandler.Android.cs).Fixes #31731
Regression PR #29068