[Android] -Picker dialog causes crash when page is popped while dialo…#31747
[Android] -Picker dialog causes crash when page is popped while dialo…#31747PureWeen merged 5 commits intodotnet:mainfrom
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.
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.
@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.
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). |
|
/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