Rg.plugins.popup: iOS 10+ crash in plugin version 1.1.0-pre2

Created on 25 May 2017  路  24Comments  路  Source: rotorgames/Rg.Plugins.Popup

PCL Interface:

public class NavigationInternal : INavigationInternal
{
        public async Task ShowItemsAsync(object context)
        {
                await PopupNavigation.Instance.PushAsync(
                        new PopupItemsPage { BindingContext = context });
        }
}

PCL Usage:
await navigationInternal.ShowItemsAsync(this); // (this) -> instance of VM

PCL Popup class:

public partial class PopupItemsPage : Rg.Plugins.Popup.Pages.PopupPage
{
        public PopupItemsPage()
        {
            InitializeComponent();
        }
}

It is crashing on iOS 10+, after multiple open/close of popup.
P.S. Opening by code, close by tapping background (and make it for multiple times)

Please see the info:
NSObject.get_SuperHandle ()
/Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/Foundation/NSObject2.cs line 423
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'PopupPageRenderer'.

CANNOT ACCESS A DISPOSED OBJECT. OBJECT NAME: 'POPUPPAGERENDERER'.

_NSObject.get_SuperHandle () /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/Foundation/NSObject2.cs:423

UIViewController.ViewDidLayoutSubviews () /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/build/ios/native/UIKit/UIViewController.g.cs:1210

PopupPageRenderer.ViewDidLayoutSubviews ()

Trampolines+SDAction.Invoke (System.IntPtr block) /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/build/ios/native/ObjCRuntime/Trampolines.g.cs:10343

(wrapper native-to-managed) ObjCRuntime.Trampolines+SDAction:Invoke (intptr)

(wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend_Double_IntPtr_IntPtr (intptr,intptr,double,intptr,intptr)

UIView.AnimateNotify (System.Double duration, System.Action animation, UIKit.UICompletionHandler completion) /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/build/ios/native/UIKit/UIView.g.cs:370

UIView.AnimateNotifyAsync (System.Double duration, System.Action animation) /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/build/ios/native/UIKit/UIView.g.cs:382

UIView.AnimateAsync (System.Double duration, System.Action animation) /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIView.cs:177

PopupPageRenderer+d__19.MoveNext ()

ExceptionDispatchInfo.Throw () /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151

AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018

UIKitSynchronizationContext+c__AnonStorey0.<>m__0 () /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIKitSynchronizationContext.cs:24

NSAsyncActionDispatcher.Apply () /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/Foundation/NSAction.cs:163

(wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)

UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIApplication.cs:79

UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIApplication.cs:63

Application.Main (System.String[] args) /Users/alezhuk/Project_X/PinPayment/PinPayment/PinPayment.iOS/Main.cs:14_

bug priority-high

Most helpful comment

@rotorgames Using latest, 1.1.4.158-pre. Here is the stack trace I see in AppCenter but I am unable to repro this for now. But I do see users encountering it.

Xamarin Exception Stack:
System.NullReferenceException: Object reference not set to an instance of an object
at Rg.Plugins.Popup.IOS.Renderers.PopupPageRenderer.ViewDidLayoutSubviews () <0x101db4e54 + 0x0005c> in :0
at (wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSend(intptr,intptr)
at CoreAnimation.CATransaction.Commit () <0x1010f6498 + 0x00023> in <0b60c1467e7449608ac42f9c7bbfdd05#510e478a0d8b9e3668d2cdf02e572773>:0
at Xamarin.Forms.Platform.iOS.CADisplayLinkTicker.StartThread () <0x101478e04 + 0x0002f> in <3d97176e5e4b463eb17f36e790a716e1#510e478a0d8b9e3668d2cdf02e572773>:0
at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) <0x10086cbd8 + 0x000e3> in :0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) <0x10086b268 + 0x00227> in :0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) <0x10086b1f4 + 0x0002f> in :0
at System.Threading.ThreadHelper.ThreadStart () <0x10086cd88 + 0x0002f> in :0

All 24 comments

@alezhuk Thank you, I will fix it soon. You can be able to result in v1.1.0-pre3

@alezhuk P.S. Is it problem only on iOS?

@rotorgames yup, only for iOS. I was testing on Droid and no crash with the same steps.

I have the same issue in my project, when trying to open popup second time after closing first one. Only iOS. Any news on solving this one?

I think I have the same issue, here is my StackTrace:

Failed to marshal the Objective-C object 0x110f55940 (type: Rg_Plugins_Popup_IOS_Renderers_PopupPageRenderer). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'Rg.Plugins.Popup.IOS.Renderers.PopupPageRenderer' does not have a constructor that takes one IntPtr argument). Additional information: Selector: viewDidLayoutSubviews Method: Rg.Plugins.Popup.IOS.Renderers.PopupPageRenderer:ViewDidLayoutSubviews ()

(wrapper managed-to-native) ObjCRuntime.Messaging:objc_msgSend (intptr,intptr)
CATransaction.Commit ()
CADisplayLinkTicker.StartThread ()
ThreadHelper.ThreadStart_Context (System.Object state)
ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx)
ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state)
ThreadHelper.ThreadStart ()

@bruzkovsky Please try to remove this plugin from each project using nuget and reinstall again.

Ok I'll try that, I'll let you know if it worked.

@bruzkovsky did you manage to solve the problem?

@shnaz I made another package after wiping all bin/obj/packages folders and it since never happened again.

@rotorgames Do you think this bug will get fixed anytime soon? I'm only asking because I'd like to help fix it ASAP. This bug with the latest version 1.1.0 pre2 has completely stopped development for my dev team.
let me know, thank you

@rotorgames any update on when will v1.1.0-pre3 be available?

@alezhuk @gcadmes I'm so sorry that you had to wait my answer so long. I begin to fix this bug.

I have published v1.1.0-pre3. You can test it.

I think that I resolved this problem. You can test it from the development NuGet: https://ci.appveyor.com/nuget/rg-plugins-popup-p6l5elugev99

Not afraid to reopen this issue if you have this problem again.

Thanks.

I am still getting this crash with 1.1.4.158-pre

I use
PopupNavigation.Instance.PushAsync
then
PopupNavigation.Instance.PopAsync

and the app crashes when trying to call PopAsync

Edit 1:
I get the crash on an Android device, the same code works fine on an iOS device.

I think I should describe the situation:
I pop a popup page to get text input. There is a "label" that behaves as a save button. I add a tap gesture recognizer to that label. If you tap the label it saves the input and calls "PopupNavigation.Instance.PopAsync" at one point.

So, If I tap the label with keyboard visible on the screen, the app crashes. If I tap that label after I hide the keyboard with the back button, the app does not crash. Weird huh?

Edit 2:
I decided to go back to 2016 version 1.0.4 after wasting my entire day on this. I am ok with random crashes I guess

@cetso Can you give me the stack trace of the exception? I don't understand what happens.

@rotorgames Using latest, 1.1.4.158-pre. Here is the stack trace I see in AppCenter but I am unable to repro this for now. But I do see users encountering it.

Xamarin Exception Stack:
System.NullReferenceException: Object reference not set to an instance of an object
at Rg.Plugins.Popup.IOS.Renderers.PopupPageRenderer.ViewDidLayoutSubviews () <0x101db4e54 + 0x0005c> in :0
at (wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSend(intptr,intptr)
at CoreAnimation.CATransaction.Commit () <0x1010f6498 + 0x00023> in <0b60c1467e7449608ac42f9c7bbfdd05#510e478a0d8b9e3668d2cdf02e572773>:0
at Xamarin.Forms.Platform.iOS.CADisplayLinkTicker.StartThread () <0x101478e04 + 0x0002f> in <3d97176e5e4b463eb17f36e790a716e1#510e478a0d8b9e3668d2cdf02e572773>:0
at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) <0x10086cbd8 + 0x000e3> in :0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) <0x10086b268 + 0x00227> in :0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) <0x10086b1f4 + 0x0002f> in :0
at System.Threading.ThreadHelper.ThreadStart () <0x10086cd88 + 0x0002f> in :0

This error occurred for me... I soon realised i was attempting to show to same PopupPage while 1 was open.
The crash error/crash was hitting appDelegate on iOS. (object reference as above)

Still facing the same issue. The app crashes because of this.
It usually happens when SoftKeyboard is about to appear
Here is the stack trace from appcenter.

Rg.Plugins.Popup.1.1.4.168

NSObject.get_SuperHandle () UIViewController.ViewDidLayoutSubviews () PopupPageRenderer.ViewDidLayoutSubviews () PopupPageRenderer.KeyBoardUpNotification (Foundation.NSNotification notifi) InternalNSNotificationHandler.Post (Foundation.NSNotification s) (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)

Can someone give exactly line of stack trace for this issue? I can't reproduce it and I made a lot of things to avoid this bug but it didn't help.

I can confirm that also using the latest stable version (1.1.5.180) I can reproduce on IOS:

Unhandled managed exception:
Object reference not set to an instance of an object (System.NullReferenceException)
at Rg.Plugins.Popup.IOS.Renderers.PopupPageRenderer.ViewDidLayoutSubviews () [0x00026] in :0
at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend(intptr,intptr)
at CoreAnimation.CATransaction.Commit () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/CoreAnimation/CATransaction.g.cs:89
at Xamarin.Forms.Platform.iOS.CADisplayLinkTicker.StartThread () [0x0003a] in D:\agent_work\1\s\Xamarin.Forms.Platform.iOS\CADisplayLinkTicker.cs:61
at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/thread.cs:68
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionC
ontext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:961
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:908
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:897
at System.Threading.ThreadHelper.ThreadStart ()
[0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/thread.cs:105
The app has been terminated.

@AdelaPetrut Can you create a simple project which can reproduce this error?

P.S. Can someone try to reproduce it in 1.1.5.185 (develop nuget)?

Unfortunatelly it crashes on Android also:
Nuget: 1.1.5.188

[EXCEPTION] Cannot access a disposed object.
Object name: 'Rg.Plugins.Popup.Droid.Renderers.PopupPageRenderer'. (/Users/vsts/agent/2.147.1/work/1/s/PMA/PMA.Android/Diagnostics/LoggerAndroid.cs, OnCurrentDomainUnhandledException:52)
      at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <676d7664b4c644aebe247026c785071b>:0 
      at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <676d7664b4c644aebe247026c785071b>:0 
      at Android.Views.View.get_Context () [0x0000a] in <280aba1c4e524fb5931dec44a33b152d>:0 
      at Rg.Plugins.Popup.Droid.Renderers.PopupPageRenderer.DispatchTouchEvent (Android.Views.MotionEvent e) [0x00055] in <d927ed3c90894f1eb311e2dc2f5953ba>:0 
      at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00011] in <280aba1c4e524fb5931dec44a33b152d>:0 
      at (wrapper dynamic-method) System.Object.46(intptr,intptr,intptr)

Guys. Try to use the last version in development nuget please https://ci.appveyor.com/nuget/rg-plugins-popup-p6l5elugev99

I hope it will fix all issues you have.

Was this page helpful?
0 / 5 - 0 ratings