rotorgames / Rg.Plugins.Popup

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

Navigation.PopAllPopupAsync crashes app #489

Open jerdine opened 5 years ago

jerdine commented 5 years ago

Using iOS 13+ device, the app crashes and throws exception when calling Navigation.PopAllPopupAsync. See stack trace below.

Stack trace

at Rg.Plugins.Popup.IOS.Impl.PopupPlatformIos.RemoveAsync (Rg.Plugins.Popup.Pages.PopupPage page) <0x10314cc40 + 0x003b0> in <a0b456689a44455381d8760ee8c0e472#9327f3808f32c583494cd9ee634667e4>:0 at Rg.Plugins.Popup.Services.PopupNavigationImpl.RemoveAsync (Rg.Plugins.Popup.Pages.PopupPage page) <0x102bc9d10 + 0x001a7> in <cde965b472ad4ded822da8d25d677e8c#9327f3808f32c583494cd9ee634667e4>:0 at Rg.Plugins.Popup.Services.PopupNavigationImpl.RemovePageAsync (Rg.Plugins.Popup.Pages.PopupPage page, System.Boolean animate) <0x102bc9360 + 0x00373> in <cde965b472ad4ded822da8d25d677e8c#9327f3808f32c583494cd9ee634667e4>:0 at Rg.Plugins.Popup.Services.PopupNavigationImpl.PopAllAsync (System.Boolean animate) <0x102bc8fd0 + 0x002ab> in <cde965b472ad4ded822da8d25d677e8c#9327f3808f32c583494cd9ee634667e4>:0

Additional info

Phenek commented 5 years ago

Hello I got a lot of crash on this too, more than thousand each day when calling RemovePageAsync method only on iOS 13+

PopupPlatformIos.RemoveAsync (Rg.Plugins.Popup.Pages.PopupPage page)
PopupNavigationImpl.RemoveAsync (Rg.Plugins.Popup.Pages.PopupPage page)
PopupNavigationImpl+<>c__DisplayClass10_0.<RemovePageAsync>b__0 ()
PopupNavigationImpl+<>c__DisplayClass15_0.<InvokeThreadSafty>b__0 ()
AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state)
NSAsyncSynchronizationContextDispatcher.Apply ()
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate)
UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
Application.Main (System.String[] args)
Phenek commented 5 years ago

I got also some crash when adding a page on iOS 13+ only

SIGABRT: Objective-C exception thrown. Name: NSInvalidArgumentException 
Reason: Application tried to present modally an active controller <RgPopupPlatformRenderer: >. Native stack trace: 0 CoreFoundation + libobjc.A.dylib objc_exception_throw + UIKitCore

Runtime.ThrowNSException (System.IntPtr ns_exception)
Runtime.throw_ns_exception (System.IntPtr exc)
(wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
(wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSendSuper(intptr,intptr,intptr,bool,intptr)
UIViewController.PresentViewController (UIKit.UIViewController viewControllerToPresent, System.Boolean animated, System.Action completionHandler)
UIViewController.PresentViewControllerAsync (UIKit.UIViewController viewControllerToPresent, System.Boolean animated)
PopupPlatformIos.AddAsync (Rg.Plugins.Popup.Pages.PopupPage page)
(wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSendSuper(intptr,intptr,intptr,bool,intptr)
UIViewController.PresentViewController (UIKit.UIViewController viewControllerToPresent, System.Boolean animated, System.Action completionHandler)
UIViewController.PresentViewControllerAsync (UIKit.UIViewController viewControllerToPresent, System.Boolean animated)
PopupPlatformIos.AddAsync (Rg.Plugins.Popup.Pages.PopupPage page)
PopupNavigationImpl.AddAsync (Rg.Plugins.Popup.Pages.PopupPage page)
PopupNavigationImpl+<>c__DisplayClass7_0.<PushAsync>b__0 ()
PopupNavigationImpl+<>c__DisplayClass15_0.<InvokeThreadSafty>b__0 ()
AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state)
NSAsyncSynchronizationContextDispatcher.Apply ()
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate)
UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
Application.Main (System.String[] args)
jerdine commented 5 years ago

@Phenek I followed the temporary work around specified in here

Put Navigation.PopAllPopupAsync in a try/catch block.

prabh-62 commented 3 years ago

pop all twice. This might help in recreating crash

await Navigation.PopAllPopupAsync();
await Navigation.PopAllPopupAsync();