[BUG] Repeatedly displaying and hiding the popup at short intervals does not display the Popup as intended on iOS.
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Did you read the “Reporting a bug” section on Contributing file?
- I have read the “Reporting a bug” section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
This issue transfer from from Discussion #1202. Since I was able to write code that can easily reproduce the problem, I uploaded the source code to github.
I am using Popup to display the indicator. Indicators using Popup are displayed before the start of processing and closed after the end of processing. The length of the processing varies, some long, some short.
The Indicator using the Popup is displayed as follows.
private void ShowIndicator()
{
if (pIndicator == null)
{
pIndicator = new Indicator();
this.ShowPopup(pIndicator);
}
}
The Indicator using the Popup is closed as follows.
private void CloseIndicator()
{
if (pIndicator != null)
{
pIndicator.Close();
pIndicator = null;
}
}
pIndicator is an instance of Indicator class that inherits from Popup class and is a class variable. Popups are managed by class variables, and only one Popup is displayed at a time.
private Indicator pIndicator = null;
I use it as follows.
ShowIndicator();
GetTestItem();
CloseIndicator();
If there is no problem, it will be displayed as follows.
If the following warning is displayed, it will be displayed as follows.
Warning: Attempt to dismiss from view controller <CommunityToolkit_Maui_Core_Views_MauiPopup: 0x16c8d4250> while a presentation or dismiss is in progress!
Below is a video of the issue being reproduced.
https://github.com/CommunityToolkit/Maui/assets/125236133/6acfcb64-e1be-4fb8-9657-854d563d2b12
A Indicator using an Popup will appear in a position other than the center of the screen and will not close at all. The above phenomenon rarely occurs.
As far as I can see from the warnings, it looks like the object was not destroyed immediately after calling the Popup’s Close method and is still there.
The problem occurs in both of the repros below. The former is the reproduction code described in Discussion #1202. The latter is the reproducible code described in this issue.
https://github.com/cat0363/MauiComm-IssuePopup.git https://github.com/cat0363/MauiComm-IssuePopup2.git
Expected Behavior
I expected the indicator to show/hide even after calling ShowPopup and Close in succession.
Steps To Reproduce
The steps to reproduce are as follows.
- Launch the app uploaded to github with the device on iOS.
- Scrolls the ScrollView downward many times.
In step 2, the Indicator remains displayed at the bottom of the screen, blocking scrolling.
Link to public reproduction project repository
https://github.com/cat0363/MauiComm-IssuePopup2.git
Environment
- .NET MAUI CommunityToolkit:5.2.0
- OS:iOS 16.4
- .NET MAUI:7.0.86
Anything else?
No response
Issue Analytics
- State:
- Created 4 months ago
- Comments:11 (10 by maintainers)
Thanks for the heads up!
I’ve added linked #1213 to the PR so that it’ll be closed when the PR is merged 👍
Hi, @brminnick By solving Issue #1111 with PR #1223, which you are currently working on, this issue will also be resolved. I was able to confirm that using PR #1223 fixed the issue. This issue was resolved by awaiting using the CloseAsync method. Once #1222 is closed, I will close this issue. Popup behavior is now what I expected. Thank you.
It turns out that the solution I posted earlier only guarded the occurrence of the problem, not the root solution. By controlling the calls to the PresentViewController and DismissViewControllerAsync methods using the ViewController’s IsBeingPresented and IsBeingDismissed property values, the phenomenon no longer occurs, but when I checked the Popup display count, it was not the intended count.