Rg.plugins.popup: System.Exception: Failed to marshal the Objective-C object

Created on 16 May 2018  路  7Comments  路  Source: rotorgames/Rg.Plugins.Popup

Today I got this exception (May 16, 2018):
System.Exception: Failed to marshal the Objective-C object 0x111ba62c0 (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 ()

On April 6, 2018:
System.Exception: Failed to marshal the Objective-C object 0x71c935d0 (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 ()

Both versions: 1.0.4
And I just discovered that this version is the latest stable one and dates back to 2016. Did you guys fixed this since 2016? Do you have any suggestions on which version to use on production?

bug

Most helpful comment

I just have fixed it. You can see the solution in b8deca7. You couldn't reproduce this issues stably because the exception is thrown only when the last popup was hidden and GC.Collect() was invoked after it.

All 7 comments

@cetso Hi. Try to use the last pre/beta release I think that it has been fixed. Also you can read this to avoid main bugs.

Hi @rotorgames
The bug is still there, sadly, even on the newest prerelease. It seems to be an issue with the ACR.Userdialogs Plugin, as it always occures when showing a LoadingScreen from them - though there they told me, they cant fix it on their side. It cant be perfectly reproduced, however the requirement is, that a Plugin.Popup has been shown and then later it happens sometimes during the LoadingScreen. Here is an example of a crashlog:

System.Exception: Failed to marshal the Objective-C object 0x1732ae00 (type: Rg_Plugins_Popup_IOS_Platform_PopupWindow). 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.Platform.PopupWindow' does not have a constructor that takes one IntPtr argument).
Runtime.MissingCtor (System.IntPtr ptr, System.IntPtr klass, System.Type type, ObjCRuntime.Runtime+MissingCtorResolution resolution) /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:1003
Runtime.ConstructNSObject[T] (System.IntPtr ptr, System.Type type, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution)
Runtime.GetINativeObject[T] (System.IntPtr ptr, System.Boolean owns)
NSArray.UnsafeGetItem[T] (System.IntPtr handle, System.nuint index)
NSArray.ArrayFromHandle[T] (System.IntPtr handle)
UIApplication.get_Windows () /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.g.cs:1360
ProgressHUD.ShowProgressWorker (System.Single progress, System.String status, BigTed.ProgressHUD+MaskType maskType, System.Boolean textOnly, BigTed.ProgressHUD+ToastPosition toastPosition, System.String cancelCaption, System.Action cancelCallback, System.Double timeoutMs, System.Boolean showContinuousProgress, UIKit.UIImage displayContinuousImage)
ProgressHUD+<>c__DisplayClass18_0.b__0 ()
NSActionDispatcher.Apply () /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/Foundation/NSAction.cs:53
(wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr_bool(intptr,intptr,intptr,intptr,bool)
NSObject.InvokeOnMainThread (System.Action action) /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/Foundation/NSObject2.cs:579
ProgressHUD.Show (System.String status, System.Single progress, BigTed.ProgressHUD+MaskType maskType, System.Double timeoutMs)
BTProgressHUD.Show (System.String status, System.Single progress, BigTed.ProgressHUD+MaskType maskType)
ProgressDialog+<>c__DisplayClass17_0.b__0 ()
NSActionDispatcher.Apply () /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/Foundation/NSAction.cs:53
(wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr_bool(intptr,intptr,intptr,intptr,bool)
NSObject.InvokeOnMainThread (System.Action action) /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/Foundation/NSObject2.cs:579
ProgressDialog.Refresh ()
ProgressDialog.Show ()
AbstractUserDialogs.Progress (Acr.UserDialogs.ProgressDialogConfig config)
AbstractUserDialogs.Loading (System.String title, System.Action onCancel, System.String cancelText, System.Boolean show, System.Nullable1[T] maskType) AbstractUserDialogs.ShowLoading (System.String title, System.Nullable1[T] maskType)
MobileInventory+<>c.b__36_0 () D:\Digitalich\Heimrich App\Heimrich Native App\Heimrich\Heimrich\Mobile GUI\Views\Inventory\MobileInventory.cs:134
NSAsyncActionDispatcher.Apply () /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/Foundation/NSAction.cs:125
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:79
UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:63
Application.Main (System.String[] args) D:\Digitalich\Heimrich App\Heimrich Native App\Heimrich\Heimrich.iOS\Main.cs:12

I also observe it with 1.1.4.158-pre. This is not 100% reproducible, though.

MyApplication to marshal the Objective-C object 0x16121ee90 (type: Rg_Plugins_Popup_IOS_Platform_PopupWindow). 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.Platform.PopupWindow' does not have a constructor that takes one IntPtr argument).
ObjCRuntime.Runtime.MissingCtor(System.IntPtr ptr, System.IntPtr klass, System.Type type, ObjCRuntime.Runtime+MissingCtorResolution resolution) in <0b60c1467e7449608ac42f9c7bbfdd05#c6c74884dc9df2fe68daa51dd29899db>:0
ObjCRuntime.Runtime.ConstructNSObject[T](System.IntPtr ptr, System.Type type, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution) in <0b60c1467e7449608ac42f9c7bbfdd05#c6c74884dc9df2fe68daa51dd29899db>:0
ObjCRuntime.Runtime.GetINativeObject[T](System.IntPtr ptr, System.Boolean owns) in <0b60c1467e7449608ac42f9c7bbfdd05#c6c74884dc9df2fe68daa51dd29899db>:0
Foundation.NSArray.UnsafeGetItem[T](System.IntPtr handle, System.nuint index) in <0b60c1467e7449608ac42f9c7bbfdd05#c6c74884dc9df2fe68daa51dd29899db>:0
Foundation.NSArray.ArrayFromHandle[T](System.IntPtr handle) in <0b60c1467e7449608ac42f9c7bbfdd05#c6c74884dc9df2fe68daa51dd29899db>:0
UIKit.UIApplication.get_Windows() in <0b60c1467e7449608ac42f9c7bbfdd05#c6c74884dc9df2fe68daa51dd29899db>:0
MyApplication.iOS.Helpers.ApiHelper.get_SafeAreaInsets() in <b6abb2ada2b445efa96e0a27e5193842#c6c74884dc9df2fe68daa51dd29899db>:0
MyApplication.iOS.Renderers.TabsView.TabsViewRenderer.SizeThatFits(CoreGraphics.CGSize size) in <b6abb2ada2b445efa96e0a27e5193842#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Platform.iOS.UIViewExtensions.GetSizeRequest(UIKit.UIView self, System.Double widthConstraint, System.Double heightConstraint, System.Double minimumWidth, System.Double minimumHeight) in <3d97176e5e4b463eb17f36e790a716e1#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].GetDesiredSize(System.Double widthConstraint, System.Double heightConstraint) in <3d97176e5e4b463eb17f36e790a716e1#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Platform.iOS.Platform.Xamarin.Forms.Internals.IPlatform.GetNativeSize(Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) in <3d97176e5e4b463eb17f36e790a716e1#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.OnSizeRequest(System.Double widthConstraint, System.Double heightConstraint) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.OnMeasure(System.Double widthConstraint, System.Double heightConstraint) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.GetSizeRequest(System.Double widthConstraint, System.Double heightConstraint) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.Measure(System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.StackLayout.CalculateNaiveLayout(Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.StackLayout.CalculateLayout(Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.StackLayout.LayoutChildren(System.Double x, System.Double y, System.Double width, System.Double height) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Layout.UpdateChildrenLayout() in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Layout.OnSizeAllocated(System.Double width, System.Double height) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
MyApplication.Core.Views.Pages.Projects.MeasurementData.MeasurementView.OnSizeAllocated(System.Double width, System.Double height) in <b81d10e88478495dbfc71596c7a9c90d#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.SizeAllocated(System.Double width, System.Double height) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.SetSize(System.Double width, System.Double height) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.set_Bounds(Xamarin.Forms.Rectangle value) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.Layout(Xamarin.Forms.Rectangle bounds) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion(Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.AbsoluteLayout.LayoutChildren(System.Double x, System.Double y, System.Double width, System.Double height) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Layout.UpdateChildrenLayout() in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Layout.OnSizeAllocated(System.Double width, System.Double height) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.SizeAllocated(System.Double width, System.Double height) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.SetSize(System.Double width, System.Double height) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.set_Bounds(Xamarin.Forms.Rectangle value) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.Layout(Xamarin.Forms.Rectangle bounds) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion(Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Page.LayoutChildren(System.Double x, System.Double y, System.Double width, System.Double height) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Rg.Plugins.Popup.Pages.PopupPage.LayoutChildren(System.Double x, System.Double y, System.Double width, System.Double height) in <f02af3e3da234e9a9bb2fd6f5ab80294#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Page.UpdateChildrenLayout() in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Page.OnSizeAllocated(System.Double width, System.Double height) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
MyApplication.Core.Views.Pages.Projects.MeasurementData.MeasurementDataTabletPage.OnSizeAllocated(System.Double width, System.Double height) in <b81d10e88478495dbfc71596c7a9c90d#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.SizeAllocated(System.Double width, System.Double height) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.SetSize(System.Double width, System.Double height) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.set_Bounds(Xamarin.Forms.Rectangle value) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.VisualElement.Layout(Xamarin.Forms.Rectangle bounds) in <2d556da9653b4f3a86936793d8bb17c3#c6c74884dc9df2fe68daa51dd29899db>:0
Xamarin.Forms.Platform.iOS.PageRenderer.SetElementSize(Xamarin.Forms.Size size) in <3d97176e5e4b463eb17f36e790a716e1#c6c74884dc9df2fe68daa51dd29899db>:0
Rg.Plugins.Popup.IOS.Renderers.PopupPageRenderer.ViewDidLayoutSubviews() in <0c4c8fb664a1439d9c7263ac57e5660d#c6c74884dc9df2fe68daa51dd29899db>:0
UIKit.UIApplication.Main(System.String[] args, System.IntPtr principal, System.IntPtr delegate) in <0b60c1467e7449608ac42f9c7bbfdd05#c6c74884dc9df2fe68daa51dd29899db>:0
UIKit.UIApplication.Main(System.String[] args, System.String principalClassName, System.String delegateClassName) in <0b60c1467e7449608ac42f9c7bbfdd05#c6c74884dc9df2fe68daa51dd29899db>:0
MyApplication.iOS.Application.Main(System.String[] args) in <b6abb2ada2b445efa96e0a27e5193842#c6c74884dc9df2fe68daa51dd29899db>:0

You can see traces of my code in the stacktrace above; the ApiHelper.SafeAreaInsets property is simple:

public static UIEdgeInsets SafeAreaInsets => UIApplication.SharedApplication.Windows[0].SafeAreaInsets;

It looks like accessing Windows property of SharedApplication object may cause Rg.Plugin.Popup to crash, but I'm absolutely clueless why. Any help would be highly appreciated.

I also have the same issue in my projects. I'm trying to fix it now but I think that is is a problem of Xamarin.iOS.

I just have fixed it. You can see the solution in b8deca7. You couldn't reproduce this issues stably because the exception is thrown only when the last popup was hidden and GC.Collect() was invoked after it.

Hello,
I'm using V1.1.4.168 (the latest one) and I'm still having this exception.
Here is it along with the stack trace.
Of course this is happening randomly and I can't figure how to reproduce it.

System.Exception: Failed to marshal the Objective-C object 0x10ecbba70 (type: Rg_Plugins_Popup_IOS_Platform_PopupWindow). 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.Platform.PopupWindow' does not have a constructor that takes one IntPtr argument).

Runtime.MissingCtor (System.IntPtr ptr, System.IntPtr klass, System.Type type, ObjCRuntime.Runtime+MissingCtorResolution resolution) Runtime.ConstructNSObject[T] (System.IntPtr ptr, System.Type type, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution) Runtime.GetINativeObject[T] (System.IntPtr ptr, System.Boolean owns) NSArray.UnsafeGetItem[T] (System.IntPtr handle, System.nuint index) NSArray.ArrayFromHandle[T] (System.IntPtr handle) UIApplication.get_Windows () ProgressHUD.get_VisibleKeyboardHeight () ProgressHUD.PositionHUD (Foundation.NSNotification notification) ProgressHUD.ShowProgressWorker (System.Single progress, System.String status, BigTed.ProgressHUD+MaskType maskType, System.Boolean textOnly, BigTed.ProgressHUD+ToastPosition toastPosition, System.String cancelCaption, System.Action cancelCallback, System.Double timeoutMs, System.Boolean showContinuousProgress, UIKit.UIImage displayContinuousImage) ProgressHUD+<>c__DisplayClass19_0.<Show>b__0 () NSActionDispatcher.Apply () (wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSend(intptr,intptr,intptr,intptr,bool) NSObject.InvokeOnMainThread (System.Action action) ProgressHUD.Show (System.String cancelCaption, System.Action cancelCallback, System.String status, System.Single progress, BigTed.ProgressHUD+MaskType maskType, System.Double timeoutMs) BTProgressHUD.Show (System.String cancelCaption, System.Action cancelCallback, System.String status, System.Single progress, BigTed.ProgressHUD+MaskType maskType) ProgressDialog+<>c__DisplayClass17_0.<Refresh>b__0 () NSActionDispatcher.Apply () (wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSend(intptr,intptr,intptr,intptr,bool) NSObject.InvokeOnMainThread (System.Action action) ProgressDialog.Refresh () ProgressDialog.Show () AbstractUserDialogs.Progress (Acr.UserDialogs.ProgressDialogConfig config) Home+<OnPositionChanged>d__22.MoveNext () ExceptionDispatchInfo.Throw () AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) UIKitSynchronizationContext+<>c__DisplayClass1_0.<Post>b__0 () NSAsyncActionDispatcher.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)

My bad, looking more closely, the version of my app that has this exception uses version 1.1.4.158-pre of Rg.Plugins.Popup so I guess it has indeed been fixed since.

Sorry for that.

Was this page helpful?
0 / 5 - 0 ratings