rotorgames / Rg.Plugins.Popup

Xamarin Forms popup plugin
MIT License
1.15k stars 337 forks source link

NullReferenceException during PopAsync on iOS #679

Closed CometSL9 closed 3 years ago

CometSL9 commented 3 years ago

🐛 Bug Report

When using PopAsync, a NullReferenceException is thrown - only on iOS. Under WPF, no problem at all...

Version: 2.0.0.12

Platform:

**Stacktrace: at Rg.Plugins.Popup.IOS.Impl.PopupPlatformIos.RemoveAsync (Rg.Plugins.Popup.Pages.PopupPage page) [0x001fb] in Z:\Documents\OpenSource\Rg.Plugins.Popup\Rg.Plugins.Popup\Platforms\Ios\Impl\PopupPlatformIos.cs:104 at Rg.Plugins.Popup.Services.PopupNavigationImpl+<>cDisplayClass23_0.b0 () [0x0018d] in Z:\Documents\OpenSource\Rg.Plugins.Popup\Rg.Plugins.Popup\Services\PopupNavigationImpl.cs:151 at Rg.Plugins.Popup.Services.PopupNavigationImpl+<>cDisplayClass28_0.b0 () [0x00025] in Z:\Documents\OpenSource\Rg.Plugins.Popup\Rg.Plugins.Popup\Services\PopupNavigationImpl.cs:210 at <_MyPage.ClosePage_> () [0x00069] in <320ef7e7629f4c1dbaa57b140e453ef2>:0

Code in MyPage.ClosPage is quite simple:

private void ClosePage() {
    PopupNavigation.Instance.PopAsync();
}

The page is pushed in the Main Page's constructor via: PopupNavigation.Instance.PushAsync(myPage);

LuckyDucko commented 3 years ago

Hey @CometSL9 Could you provide a working case example project. I have a hunch that something else is causing the problem, because PopAsync has been working fine under my own usage.

CometSL9 commented 3 years ago

Hi LuckyDucko,

As I had to solve the problem immediately, I completely threw out Rg.Plugins.Popup from my project. Therefore, no repo is possibly any more. I guess it had something to do with the new iOS 14.4 and/or the nex Xcode (as it appeared with the iOS update date).

Just my 2 cents: Use Xamarin ContentPage, make its background partly transparent (full transparency does not work on iOS, use ~95 %) -> No Rg.lugins.Popup any more.

LuckyDucko commented 3 years ago

It was most likely not awaiting the popAsync mixed with calling popAsync on the page you are trying to call that lead to the NullReference Exception.

However, glad you worked out a way around the issue.