-
Notifications
You must be signed in to change notification settings - Fork 405
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
Change the calling conditions of Popup's Dismiss method on Android #2159
Conversation
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.
Thank you @cat0363
I assume this is ready to merge? |
When I checked, the following unit test failed. CommunityToolkit.Maui.UnitTests.Views.PopupTests.PopupDismissedByTappingOutsideOfPopup It is unclear whether the unit test imitates Activity like the Android emulator. @bijington , In this unit test, does the activity exist? |
@bijington , I mistakenly thought that the error was occurring in the unit test on the Android side.
|
@cat0363 thansk for the explanation. I'm not sure why it would be failing on macOS and not windows. I'll try and take a look this week 👍 |
The test passes locally on my mac |
This PR resolves the issue where an exception occurs when the Popup's Close method is called when the Activity that displays the Popup has already been destroyed.
Description of Change
This issue occurs when the Popup's Dismiss method is called when the Activity that displays the Popup has already been discarded.
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.IllegalArgumentException: View=DecorView@357f8b6[MainActivity] not attached to window manager
If the Activity that displays the Popup has already been disposed of, I will modify it so that the Dismiss method of the Popup is not called.
[src\CommunityToolkit.Maui.Core\Handlers\Popup\PopUpHandler.android.cs]
Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRAdditional information
Below are the verification results.
I tested the verification code for Issue #2135 by setting the time to close the Popup to 5 seconds.
Android.Emulator.-.pixel_2_-_api_30_5554.2024-08-29.10-36-57.mp4
Even if the Popup's Close method is called 5 seconds after the Popup is displayed, no exception is thrown.
When you return from standby, you will see that the Activity has been newly started.
The following is the verification result when waiting 5 seconds without setting it to standby.
Android.Emulator.-.pixel_2_-_api_30_5554.2024-08-29.10-41-16.mp4
You can see that the popup is closed as intended.