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

Crash when Entry get focus #16

Open
REDECODE opened this issue May 24, 2024 · 4 comments
Open

Crash when Entry get focus #16

REDECODE opened this issue May 24, 2024 · 4 comments

Comments

@REDECODE
Copy link
Contributor

Hello,
i have a PopupPage with a inside , then a then another and inside there are a and an .

When i tap on the entry on iOS the debugger breaks at Program.cs on the line UIApplication.Main(args, null, typeof(AppDelegate)); with this error:

System.ObjectDisposedException: 'Cannot access a disposed object.
Object name: 'RGPopup.Maui.IOS.Platform.PopupWindow'.'

I'm. using:

Visual Studio 2022
net8-ios
iPhone 14 with iOS version 17.5.1
Xcode 15.2

Thanks

@REDECODE
Copy link
Contributor Author

I try to open the popup in another page (currently is on a page with GoogleMaps) and all works as expected.
Probably is due to the conflict with another component so probably is not a bug of this library

@microspaze
Copy link
Owner

The popup window will be disposed manually when the popup page removes. Can you provide more detail about this issue, a sample project or code snip about using the conflict library? Then I can take a deeper look. Thanks.

@REDECODE
Copy link
Contributor Author

Finally i found the problem, it was due to my fault.

Practically on the page I have 2 popups, one that opens immediately in the OnAppearing method and the other when you tap on a button. The problem occurs because the first popup that opens has an OnClosed event that I created and which is called in the OnDisappearing of the popup.

protected override void OnDisappearing()
{
    base.OnDisappearing();

    if (OnClosed != null)
    {
        Dispatcher.Dispatch(delegate
        {
            OnClosed?.Invoke(this, EventArgs.Empty);
        });
    }
}

And i use this on the page :

var popup = new Popup.MyCustomPopup();
await Navigation.PushPopupAsync(popup);
popup.OnClosed += async delegate
{
    await DoSomeStuff();
};

If i do so, opening the second popup with the Entry crash when i focus the entry.
All works as expected if i remove the popup.OnClosed += async delegate

This code works on Xamarin, but probably I should rewrite the code of this callback better

@REDECODE
Copy link
Contributor Author

Finally i found the problem. Is because even using the correct Dispatcher.DispatchAsync the DoSomeStuff call a DependencyService that use BTProgressHUD.Show(message); for showing a loading indicator. If I comment the line that Show the HUD and dhe line that Dismiss the HUD BTProgressHUD.Dismiss(); all works as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants