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

Null reference exception while closing a popup #350

Closed
CygnusBill opened this issue Jul 29, 2018 · 9 comments
Closed

Null reference exception while closing a popup #350

CygnusBill opened this issue Jul 29, 2018 · 9 comments

Comments

@CygnusBill
Copy link

I'm seeing this with Xamarin.Forms version 3.1.0.637273.

System.NullReferenceException: Object reference not set to an instance of an object
at Rg.Plugins.Popup.IOS.Impl.PopupPlatformIos+d__10.MoveNext () [0x000f8] in :0

My source where the exception is occurring is:

await PopupNavigation.Instance.PopAsync(false);

@CygnusBill
Copy link
Author

Another note: the popup is still visible after the exception occurs

@eramirez3
Copy link

Hi Have the same Issue, I got this message "there is not page in Popupstack" after
await PopupNavigation.Instance.PopAsync();

@EmilAlipiev
Copy link
Contributor

EmilAlipiev commented Sep 21, 2018

you should check it before popping

 if (Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopupStack.Any())
                        {
                          await PopupNavigation.Instance.PopAsync();
                        }

if you look at the source code, it throws exception when there is no popup in the stack


  public Task PopAsync(bool animate = true)
        {
            animate = CanBeAnimated(animate);

            if (PopupStack.Count == 0)
                throw new IndexOutOfRangeException("There is not page in PopupStack");

            return RemovePageAsync(PopupStack.Last(), animate);
        }

@EmilAlipiev
Copy link
Contributor

even though i am seeing this message for Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopAllAsync(); which is not supposed to throw it.
@rotorgames should we also check if any popup in the stack before using PopAllAsync? when I look at the source code PopAllAsync doesnt throw this exception it seems.

@eramirez3
Copy link

But why this error just happens in some devices, I only can reproduce this error in a Samsung Galaxy with Android 7.
But when it happens the Popup it's still visible, so the stack can not be empty.
So what's going on?

@EmilAlipiev
Copy link
Contributor

How do you reproduce it? Can you describe the steps and if possible give some code or repro project?

rotorgames added a commit that referenced this issue Jan 25, 2019
…ere were not any pages in the PopupStack. See #350
@rotorgames
Copy link
Owner

I need more information about this issue. If there are not any pages in PopupStack then all pages are removed. You need to check it before to use PopAsync.
P.S. Xamarin.Forms has similar behavior.

@EmilAlipiev I just have implemented throwing an exception if there are not any pages in PopupStack for PopAllAsync

@veletron2
Copy link

I notice this is closed, but perhaps it shouldn't be. Just a 'me to' post on this. Works fine on Android, but ANY ATTEMPT to close the current popup on IOS via a button on the popup using either await PopupNavigation.Instance.PopAsync(); or await PopupNavigation.Instance.PopAllAsync();

Results in an exception:

System.IndexOutOfRangeException: There is not page in PopupStack

It matters not whether I check the stack before closing via 'if (PopupNavigation.Instance.PopupStack.Any())' it still crashes!!

Trying the operation on the MainThread also crashes in the same way:

Device.BeginInvokeOnMainThread(async () =>
{
if (PopupNavigation.Instance.PopupStack.Any())
await PopupNavigation.Instance.PopAllAsync();
});

Any route forward? Maybe I need to try a different version of the popup plugin or Xamarin.Forms. I am forced to use XF: 3.6.0.344457 as thus far all the 4.x releases feature a known bug that means that images don't load reliably in list controls on Android.

Using rg.Plugins.Popup V1.1.5.188

Nigel

@rotorgames
Copy link
Owner

@veletron2 Try to use the last version from Development NuGet: https://ci.appveyor.com/nuget/rg-plugins-popup-p6l5elugev99.

I fixed it many time ago but I still not publish a new version. I'm going to do it ASAP.

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

5 participants