Rg.plugins.popup: Issue with pushing Popups on iOS

Created on 12 Apr 2017  路  4Comments  路  Source: rotorgames/Rg.Plugins.Popup

I'm building out a Xamarin.Forms application for iOS and Android and all of my popups are working fine on Android but I'm running into errors on iOS. The iOS application consists of a tabbed page at it's root. Each of these pages has the ability, through a toolbar item, to load a popup, which works fine. However, if I click into a list item on one of those pages (which are loaded by calling Navigation.PushAsync with the new page), then loading a popup, using the same method throws an error. I'm loading the popup like so:

var page = new MyNewPagePopup(string type);
await PopupNavigation.PushAsync(page, false);

This crashes the application with the following error (I've tried with animation both on or off):

2017-04-12 11:18:13.938 MyApp[68906:3628888] critical: Stacktrace:

2017-04-12 11:18:13.938 MyApp[68906:3628888] critical: at <0xffffffff>
2017-04-12 11:18:13.938 MyApp[68906:3628888] critical: at (wrapper managed-to-native) Foundation.NSObject.xamarin_release_managed_ref (intptr,Foundation.NSObject) [0x00008] in <4692b8633c404c758160904e5dff77ed>:0
2017-04-12 11:18:13.938 MyApp[68906:3628888] critical: at Foundation.NSObject.ReleaseManagedRef () [0x00000] in /Users/builder/data/lanes/4466/a04678c2/source/xamarin-macios/src/Foundation/NSObject2.cs:208
2017-04-12 11:18:13.938 MyApp[68906:3628888] critical: at Foundation.NSObject/NSObject_Disposer.Drain (Foundation.NSObject) [0x00062] in /Users/builder/data/lanes/4466/a04678c2/source/xamarin-macios/src/Foundation/NSObject2.cs:784
2017-04-12 11:18:13.939 MyApp[68906:3628888] critical: at (wrapper runtime-invoke) .runtime_invoke_void_object (object,intptr,intptr,intptr) [0x00051] in <4692b8633c404c758160904e5dff77ed>:0
2017-04-12 11:18:13.939 MyApp[68906:3628888] critical: at <0xffffffff>
2017-04-12 11:18:13.939 MyApp[68906:3628888] critical: at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) [0x0005c] in <4692b8633c404c758160904e5dff77ed>:0
2017-04-12 11:18:13.939 MyApp[68906:3628888] critical: at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Users/builder/data/lanes/4466/a04678c2/source/xamarin-macios/src/UIKit/UIApplication.cs:79
2017-04-12 11:18:13.939 MyApp[68906:3628888] critical: at UIKit.UIApplication.Main (string[],string,string) [0x00038] in /Users/builder/data/lanes/4466/a04678c2/source/xamarin-macios/src/UIKit/UIApplication.cs:63
2017-04-12 11:18:13.939 MyApp[68906:3628888] critical: at MyApp.iOS.Application.Main (string[]) [0x0007d] in /Users/chris/code/projects/myapp/src/iOS/Main.cs:17
2017-04-12 11:18:13.940 MyApp[68906:3628888] critical: at (wrapper runtime-invoke) .runtime_invoke_void_object (object,intptr,intptr,intptr) [0x00051] in <29baa8de461448f9affc2c22f07b7b27>:0
2017-04-12 11:18:13.940 MyApp[68906:3628888] critical:
Native stacktrace:

2017-04-12 11:18:13.942 MyApp[68906:3628888] critical: 0 MyApp 0x000000010a3eb6bd mono_handle_native_sigsegv + 253
2017-04-12 11:18:13.942 MyApp[68906:3628888] critical: 1 MyApp 0x000000010a3f83f6 mono_sigsegv_signal_handler + 294
2017-04-12 11:18:13.942 MyApp[68906:3628888] critical: 2 libsystem_platform.dylib 0x0000000113b8ebba _sigtramp + 26
2017-04-12 11:18:13.942 MyApp[68906:3628888] critical: 3 ??? 0x0000000000000000 0x0 + 0
2017-04-12 11:18:13.942 MyApp[68906:3628888] critical: 4 libobjc.A.dylib 0x000000010f4a5022 class_getInstanceMethod + 53
2017-04-12 11:18:13.942 MyApp[68906:3628888] critical: 5 MyApp 0x000000010a5950b4 _ZL12is_user_typeP11objc_object + 36
2017-04-12 11:18:13.942 MyApp[68906:3628888] critical: 6 MyApp 0x000000010a5941d9 xamarin_release_managed_ref + 25
2017-04-12 11:18:13.943 MyApp[68906:3628888] critical: 7 ??? 0x00000001231c96f2 0x0 + 4884043506
2017-04-12 11:18:13.943 MyApp[68906:3628888] critical: 8 ??? 0x0000000124adc7bb 0x0 + 4910335931
2017-04-12 11:18:13.943 MyApp[68906:3628888] critical: 9 MyApp 0x000000010a3fb185 mono_jit_runtime_invoke + 1301
2017-04-12 11:18:13.943 MyApp[68906:3628888] critical: 10 MyApp 0x000000010a4ac9f8 do_runtime_invoke + 88
2017-04-12 11:18:13.943 MyApp[68906:3628888] critical: 11 MyApp 0x000000010a4ac970 mono_runtime_invoke + 208
2017-04-12 11:18:13.943 MyApp[68906:3628888] critical: 12 MyApp 0x000000010a598995 xamarin_invoke_trampoline + 5589
2017-04-12 11:18:13.943 MyApp[68906:3628888] critical: 13 MyApp 0x000000010a5a05ed xamarin_arch_trampoline + 189
2017-04-12 11:18:13.943 MyApp[68906:3628888] critical: 14 MyApp 0x000000010a5a19b1 xamarin_x86_64_common_trampoline + 110
2017-04-12 11:18:13.944 MyApp[68906:3628888] critical: 15 Foundation 0x000000010c6cde51 __NSThreadPerformPerform + 334
2017-04-12 11:18:13.944 MyApp[68906:3628888] critical: 16 CoreFoundation 0x000000010ed52c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
2017-04-12 11:18:13.944 MyApp[68906:3628888] critical: 17 CoreFoundation 0x000000010ed380cf __CFRunLoopDoSources0 + 527
2017-04-12 11:18:13.944 MyApp[68906:3628888] critical: 18 CoreFoundation 0x000000010ed375ff __CFRunLoopRun + 911
2017-04-12 11:18:13.944 MyApp[68906:3628888] critical: 19 CoreFoundation 0x000000010ed37016 CFRunLoopRunSpecific + 406
2017-04-12 11:18:13.944 MyApp[68906:3628888] critical: 20 GraphicsServices 0x000000011031ba24 GSEventRunModal + 62
2017-04-12 11:18:13.944 MyApp[68906:3628888] critical: 21 UIKit 0x000000010ae010d4 UIApplicationMain + 159
2017-04-12 11:18:13.944 MyApp[68906:3628888] critical: 22 ??? 0x0000000122f8843c 0x0 + 4881679420
2017-04-12 11:18:13.944 MyApp[68906:3628888] critical: 23 ??? 0x0000000122f8807d 0x0 + 4881678461

2017-04-12 11:18:13.944 MyApp[68906:3628888] critical:

Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries

used by your application.

need-review

Most helpful comment

I have the same problem, worked without issues before, is there a fix?

EDIT: Updating Xamarin forms to alpha version solved the problem for me :)

All 4 comments

I have the same problem, worked without issues before, is there a fix?

EDIT: Updating Xamarin forms to alpha version solved the problem for me :)

@palla89 that's good to hear. I did find a fix for it for the time being though it sounds like that won't be needed down the road. For anyone that doesn't want to switch to Alpha but would like this to work these are the steps I followed:

  • Pull down the Rg.Plugins.Popup source code from GitHub.
  • Add the following projects to your solution:

    • Rg.Plugins.Popup

    • Rg.Plugins.Popup.IOS

    • Rg.Plugins.Popup.Platform

    • Rg.Plugins.Popup.Platform.iOS

  • Reference those projects from your Xamarin.iOS project.
  • In Rg.Plugin.Popup.IOS in the Popup.cs class, change the class code to be:
public static class Popup
    {
        public static UIViewController PLATFORM_RENDERER;

        [Obsolete("Initialization is not required in iOS project")]
        public static void Init()
        {
            PLATFORM_RENDERER = UIApplication.SharedApplication.KeyWindow.RootViewController;
        }
    }
  • Then i n Rg.Plugin.Popup.IOS in the Impl/PopupNavigationIOS.cs class, change the GetTopViewController method to just return Poup.PLATFORM_RENDERER

That should do it. From testing, it seems like once you've gone down into a navigation page, the default implementation of GetTopViewController returns a UIViewController where as when you haven't navigated down (and the popups still work) it returns a iOS Platform Renderer. This is probably not the best way to fix the problem but it's working for now.

@ChrisRisner Warning, it behavior will be changed in v1.1.x and GetTopViewController will not be used.

This issue was fixed in v1.1.0-pre1. Please test it and tell me about your tests. Thank you.

Was this page helpful?
0 / 5 - 0 ratings