Skip to content
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

[BUG] Repeatedly displaying and hiding the popup at short intervals does not display the Popup as intended on iOS. #1213

Closed
2 tasks done
cat0363 opened this issue Jun 1, 2023 · 11 comments · Fixed by #1223
Labels
bug Something isn't working unverified

Comments

@cat0363
Copy link
Contributor

cat0363 commented Jun 1, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

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.

Capture_001

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!

Capture_002

Below is a video of the issue being reproduced.

RPReplay_Final1685603298.MP4

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.

  1. Launch the app uploaded to github with the device on iOS.
  2. 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

@cat0363 cat0363 added bug Something isn't working unverified labels Jun 1, 2023
@cat0363
Copy link
Contributor Author

cat0363 commented Jun 7, 2023

By changing the Community Toolkit code as follows, the problem was resolved,
but the warning is still output.

[MauiPopup.macios.cs]

void AddToCurrentPageViewController(UIViewController viewController)
{
    if (!viewController.IsBeingPresented)
    {
        viewController.PresentViewController(this, true, null);
    }
}

[PopupHandler.macios.cs]

public static async void MapOnClosed(PopupHandler handler, IPopup view, object? result)
{
    var vc = handler.PlatformView.ViewController;
    if (vc is not null)
    {
        if (!vc.IsBeingDismissed)
        {
            await vc.DismissViewControllerAsync(true);
        }
    }

    handler.DisconnectHandler(handler.PlatformView);
}
RPReplay_Final1686130010.MP4

Changed to check the value of IsBeginPresented property and IsBeginDismissed
property before calling PresentViewController method and DismissViewControllerAsync
method. I don't know the impact on others, so could you make a judgment?

@bijington
Copy link
Contributor

It might be worth looking over what @brminnick is working on in this PR:

#1223

@cat0363
Copy link
Contributor Author

cat0363 commented Jun 7, 2023

Hi, @bijington
Thank you for the information.
I'll check the changes in that PR.

@cat0363
Copy link
Contributor Author

cat0363 commented Jun 9, 2023

Hi, @bijington
Verification was performed based on the source code of branch, which is scheduled to be merged into main.
The issue still reproduces, so it's not related to the PR. Should I wait for the merge to main and consider the
solution in the merged code?

Additional Information:
Applying the resolution of this issue to #1223 will resolve this issue.

@bijington
Copy link
Contributor

@cat0363 thanks for taking a look. Sorry I didn't quite follow, are you saying that when we merge #1223 this issue will be resolved?

@cat0363
Copy link
Contributor Author

cat0363 commented Jun 10, 2023

Hi, @bijington
Thank you for your reply. Merging #1223 does not solve this problem.
In addition to #1223, I need the solution I posted earlier.

#1213 (comment)

Can anyone help me determine that I need to check the values ​​of the IsBeingPresented
and IsBeingDismissed properties before calling the PresentViewController and
DismissViewControllerAsync methods?

I used the following as a reference when considering a solution.
https://stackoverflow.com/questions/12261008/strange-warning-dismissing-modal-view-controller

@cat0363
Copy link
Contributor Author

cat0363 commented Jun 12, 2023

Additional Information:
I mentioned that applying my solution will output another Warning, but it seems to be output on the .NET MAUI side.

Warning: Attempt to dismiss from view controller <Microsoft_Maui_Controls_Platform_Compatibility_ShellFlyoutRenderer: 0x10313db20> while a presentation or dismiss is in progress!

The warning that was output before applying the solution is as follows.

Warning: Attempt to dismiss from view controller <CommunityToolkit_Maui_Core_Views_MauiPopup: 0x11ddb6b90> while a presentation or dismiss is in progress!

By solving the problem, the warning that was output on the .NET MAUI side is now output.
Perhaps this seems like a similar issue.

@cat0363
Copy link
Contributor Author

cat0363 commented Jun 14, 2023

Hi, @brminnick
If possible, I would like to hear your opinion.
When this issue is resolved, all the issues I want to resolve about Popup will be resolved.

@cat0363
Copy link
Contributor Author

cat0363 commented Jun 21, 2023

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.

@brminnick brminnick mentioned this issue Jun 21, 2023
6 tasks
@brminnick
Copy link
Collaborator

Thanks for the heads up!

I've added linked #1213 to the PR so that it'll be closed when the PR is merged 👍

@cat0363
Copy link
Contributor Author

cat0363 commented Jun 21, 2023

Thank you for linking the issue.
Your great solution made Popup very good :)

@github-actions github-actions bot locked and limited conversation to collaborators Nov 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working unverified
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants