Skip to content

Conversation

@sheiksyedm
Copy link
Contributor

@sheiksyedm sheiksyedm commented Sep 24, 2025

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 Picker dialog 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 Picker dialog is dismissed and disposed in DisconnectHandler to prevent crashes when the page is popped while the dialog is open (PickerHandler.Android.cs).

Fixes #31731

Regression PR #29068

Copilot AI review requested due to automatic review settings September 24, 2025 08:23
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Sep 24, 2025
@dotnet-policy-service
Copy link
Contributor

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.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Sep 24, 2025
Copy link
Contributor

Copilot AI left a 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 DisconnectHandler in 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

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

/azp run

@PureWeen
Copy link
Member

/backport to release/9.0.1xx-sr11

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@github-actions
Copy link
Contributor

Started backporting to release/9.0.1xx-sr11: https://github.com/dotnet/maui/actions/runs/17987125383

@PureWeen
Copy link
Member

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

{
_dialog.ShowEvent -= OnDialogShown;
_dialog.DismissEvent -= OnDialogDismiss;
_dialog.Hide();
Copy link
Member

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?

Copy link
Contributor Author

@sheiksyedm sheiksyedm Sep 25, 2025

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.

Copy link
Contributor

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.

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

jsuarezruiz
jsuarezruiz previously approved these changes Sep 25, 2025
@sheiksyedm sheiksyedm added this to the .NET 9 SR12 milestone Oct 1, 2025
rmarinho
rmarinho previously approved these changes Oct 6, 2025
@rmarinho rmarinho changed the base branch from main to inflight/current October 6, 2025 18:53
@rmarinho rmarinho changed the base branch from inflight/current to main October 6, 2025 18:54
@rmarinho rmarinho dismissed stale reviews from jsuarezruiz and themself October 6, 2025 18:54

The base branch was changed.

@rmarinho
Copy link
Member

rmarinho commented Oct 6, 2025

/azp run MAUI-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen added the p/0 Current heighest priority issues that we are targeting for a release. label Oct 8, 2025
@PureWeen
Copy link
Member

PureWeen commented Oct 8, 2025

/azp run MAUI-DeviceTests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen
Copy link
Member

PureWeen commented Oct 8, 2025

/backport to release/9.0.1xx-sr12

@github-actions
Copy link
Contributor

github-actions bot commented Oct 8, 2025

Started backporting to release/9.0.1xx-sr12: https://github.com/dotnet/maui/actions/runs/18353516997

@PureWeen PureWeen merged commit a8a818e into dotnet:main Oct 10, 2025
132 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-picker Picker community ✨ Community Contribution p/0 Current heighest priority issues that we are targeting for a release. partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] Picker - System.InvalidOperationException: VirtualView cannot be null here (SIGABRT) with sample

5 participants