Ever since updating to Forms version 4.3.0.991211 from 3.6.0.709228, I have been seeing crashes reported in App Center for my iOS applications with the following stack trace:
Application Specific Information:
* Terminating app due to uncaught exception 'SIGABRT', reason: 'Failed to marshal the Objective-C object 0x121d24150 (type: Xamarin_Forms_Platform_iOS_HeaderWrapperView). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'Xamarin.Forms.Platform.iOS.HeaderWrapperView' does not have a constructor that takes one IntPtr argument).'
Xamarin Exception Stack:
ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x121d24150 (type: Xamarin_Forms_Platform_iOS_HeaderWrapperView). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'Xamarin.Forms.Platform.iOS.HeaderWrapperView' does not have a constructor that takes one IntPtr argument).
at ObjCRuntime.Runtime.MissingCtor (System.IntPtr ptr, System.IntPtr klass, System.Type type, ObjCRuntime.Runtime+MissingCtorResolution resolution) <0x101bee434 + 0x0014c> in <79170d3ca0a34f20a27c5ea33d79161f#0e2b703cb3589a8dbaa9302546e46bbe>:0
at ObjCRuntime.Runtime.ConstructNSObject[T] (System.IntPtr ptr, System.Type type, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution) <0x101bee624 + 0x0006f> in <79170d3ca0a34f20a27c5ea33d79161f#0e2b703cb3589a8dbaa9302546e46bbe>:0
at ObjCRuntime.Runtime.GetNSObject[T] (System.IntPtr ptr) <0x101bef2c0 + 0x001eb> in <79170d3ca0a34f20a27c5ea33d79161f#0e2b703cb3589a8dbaa9302546e46bbe>:0
at UIKit.UIView.get_Superview () <0x101c2e930 + 0x0006b> in <79170d3ca0a34f20a27c5ea33d79161f#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].UpdateParentPageAccessibilityElements () <0x1020beb28 + 0x00063> in <42aaf6d52c744ac8a8e2c5c0d8bedcc8#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) <0x1020be480 + 0x00253> in <42aaf6d52c744ac8a8e2c5c0d8bedcc8#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Platform.iOS.BoxRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) <0x1020c7cbc + 0x0003b> in <42aaf6d52c744ac8a8e2c5c0d8bedcc8#0e2b703cb3589a8dbaa9302546e46bbe>:0
at (wrapper delegate-invoke)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) <0x101e92d84 + 0x0006f> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) <0x101ebb8b4 + 0x00057> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) <0x101e939d0 + 0x0020f> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) <0x101e935c8 + 0x00237> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) <0x101e9a028 + 0x00513> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.BindingExpression.Apply (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property) <0x101e99dd8 + 0x00117> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Binding.Apply (System.Object context, Xamarin.Forms.BindableObject bindObj, Xamarin.Forms.BindableProperty targetProperty, System.Boolean fromBindingContextChanged) <0x101e9804c + 0x000fb> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.BindableObject.ApplyBindings (System.Boolean skipBindingContext, System.Boolean fromBindingContextChanged) <0x101e93c28 + 0x000bf> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) <0x101e92b7c + 0x000f3> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) <0x101ebc264 + 0x0000f> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Element.
at Xamarin.Forms.BindableObjectExtensions.PropagateBindingContext[T] (Xamarin.Forms.BindableObject self, System.Collections.Generic.IList1[T] children, System.Action2[T1,T2] setChildBindingContext) <0x101e94334 + 0x000f3> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Element.OnBindingContextChanged () <0x101ebb200 + 0x000cb> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.View.OnBindingContextChanged () <0x101f558a4 + 0x00043> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Grid.OnBindingContextChanged () <0x101ecca04 + 0x00017> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) <0x101e92b7c + 0x00103> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) <0x101ebc264 + 0x0000f> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Element.
at Xamarin.Forms.BindableObjectExtensions.PropagateBindingContext[T] (Xamarin.Forms.BindableObject self, System.Collections.Generic.IList1[T] children, System.Action2[T1,T2] setChildBindingContext) <0x101e94334 + 0x000f3> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Element.OnBindingContextChanged () <0x101ebb200 + 0x000cb> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Cell.OnBindingContextChanged () <0x101ea2818 + 0x00013> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.BindableObject.BindingContextPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) <0x101e93df0 + 0x0003f> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) <0x101e939d0 + 0x0022b> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) <0x101e935c8 + 0x00237> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) <0x101e93464 + 0x000ab> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.BindableObject.set_BindingContext (System.Object value) <0x101e91bb8 + 0x00043> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].UnhookItem (TItem item) <0x101e096c0 + 0x00267> in <99d3427c108749ef9a4a8d96cd2f8344#0e2b703cb3589a8dbaa9302546e46bbe>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () <0x101c551e0 + 0x0002f> in <79170d3ca0a34f20a27c5ea33d79161f#0e2b703cb3589a8dbaa9302546e46bbe>:0
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) <0x101c13780 + 0x0003f> in <79170d3ca0a34f20a27c5ea33d79161f#0e2b703cb3589a8dbaa9302546e46bbe>:0
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x101c136d8 + 0x00053> in <79170d3ca0a34f20a27c5ea33d79161f#0e2b703cb3589a8dbaa9302546e46bbe>:0
at FieldEdge.Mobile.Tablet.iOS.Application.Main (System.String[] args) <0x100aa4e68 + 0x00033> in <0b454f6e4e19418bae2b8f593d445a21#0e2b703cb3589a8dbaa9302546e46bbe>:0
Expect to not see crashes reported.
Crashes reported in App Center
Could you add a repro sample? The origin of the error appears to be at https://github.com/xamarin/Xamarin.Forms/blob/1192deedabdb0fd1eb13243cac1f6ac438afd643/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs#L190 using a ListView with header https://github.com/xamarin/Xamarin.Forms/blob/6a23b8452e7833dbcbb20b2a6ca6699d33db695f/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs#L1108, could it be?
Thank you @jsuarezruiz for the reply. I am unable to reproduce the issue on my side, I only see the crashes logged in App Center, and it started after I updated forms from 3.6 to 4.3. I used the events I added to app center and the stack trace to pinpoint where I thought the issue was occurring. I found 2 places where I was using the BindingContextChanged event of the ViewCell of a GroupHeaderTemplate to dynamically resize the cell, so I refactored it out thinking it would solved the issue. I released a new version of the app with the code refactored but I am still seeing the crash in App Center.
I am also seeing these crashes after upgrading to Xamarin.Forms 4.4.0
EDIT: At the moment also unable to reproduce myself.
I was able to pinpoint where it is happening. What I see in common is that I have an element in the GroupHeaderTemplate with a binding to the IsVisible property. I wonder if that is triggering this issue, maybe resizing.
I've faced same issue using XF 4.4.
Made a repro. Click the red group header
HeaderWrapperView.zip
I think a get a workaround related with.
It's related with IsVisible in several controls, so create a CustomRenderer must be work to avoid crashes with that, because all code that receive crash not seems relative to working correctly.
Here a sample gist.
https://gist.github.com/jmmortega/7f8c894eac2287985942271e4d886f42
I test in repro steps from @Matmork and working correctly. Kudos @Matmork
Since a certain Xamarin Forms update (post 4.0) I also got the same issue. I cannot reliably reproduce the issue, but all I know is the app crashes randomly when a listview (with gropping enabled) is refreshed/updated.
In my case I don't have bindings to the IsVisible property.
We are experiencing this crash as well. I'm can confirm that @Matmork's sample does reproduce the crash.
Note that the deadline for iOS apps to switch away from UIWebView is approaching, and we need to be able to update Forms to meet that requirement.
Still the same error coming in xamarin form 4.8.
Most helpful comment
Still the same error coming in xamarin form 4.8.