Maui iOS App is crashing because of Microsoft.Maui.Platform.ContentView

Shingala A 25 Reputation points
2024-01-30T12:31:42.7566667+00:00

Hi, Maui iOS app is crashing because of ContentView. It is coming multiple times but we are not able to generate it frequently. Crash is coming randomly. It is also get logged in app center. but it is not displaying from which method app is getting crashed. We have not done anything with constructor in any of Contentview. We are using MAUI with .Net 7.0. It is coming in all iOS Devices.

Exception message we are getting on crash:

SIGABRT: Failed to marshal the Objective-C object 0x14dee49d0 (type: Microsoft_Maui_Platform_ContentView). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'Microsoft.Maui.Platform.ContentView' does not have a constructor that takes one NativeHandle argument).

We have try to use global exception handling to prevent app from crashing but it is still crashing. Kindly provide any solution for this.

AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
    {
        Exception exception = e.ExceptionObject as Exception;
        if (exception != null)
        {
            // Log the exception, display it, or handle it as you need.
            Console.WriteLine(exception.ToString());
        }
    }

Full crash Log:

2024-01-30 10:57:18.213 JAMApp[11278:62764868] ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x1010db690 (type: Microsoft_Maui_Platform_ContentView). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'Microsoft.Maui.Platform.ContentView' does not have a constructor that takes one NativeHandle argument).
   at ObjCRuntime.Runtime.MissingCtor(IntPtr ptr, IntPtr klass, Type type, MissingCtorResolution resolution)
2024-01-30 10:57:18.213 JAMApp[11278:62764868]    at ObjCRuntime.Runtime.ConstructNSObject[UIView](IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution)
   at ObjCRuntime.Runtime.GetNSObject[UIView](IntPtr ptr)
   at UIKit.UIView.get_Superview()
   at Microsoft.Maui.Platform.LayoutView.WillRemoveSubview(UIView uiview)
2024-01-30 10:57:18.213 JAMApp[11278:62764868]    at UIKit.UIView.RemoveFromSuperview()
   at Microsoft.Maui.Platform.ViewExtensions.ClearSubviews(UIView view)
   at Microsoft.Maui.Handlers.LayoutHandler.DisconnectHandler(LayoutView platformView)
2024-01-30 10:57:18.213 JAMApp[11278:62764868]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnDisconnectHandler(UIView platformView)
2024-01-30 10:57:18.213 JAMApp[11278:62764868]    at Microsoft.Maui.Handlers.ViewHandler.OnDisconnectHandler(Object platformView)
   at Microsoft.Maui.Handlers.ElementHandler.DisconnectHandler(Object platformView)
   at Microsoft.Maui.Handlers.ElementHandler.Microsoft.Maui.IElementHandler.DisconnectHandler()
2024-01-30 10:57:18.213 JAMApp[11278:62764868]    at Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer.UnevenListViewDataSource.CalculateHeightForCell(UITableView tableView, Cell cell)
2024-01-30 10:57:18.213 JAMApp[11278:62764868]    at Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer.UnevenListViewDataSource.GetEstimatedRowHeight(UITableView table)
   at Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer.UnevenListViewDataSource.UpdateEstimatedRowHeight(UITableView tableView)
2024-01-30 10:57:18.213 JAMApp[11278:62764868]    at Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer.ListViewDataSource.DetermineEstimatedRowHeight()
   at Microsoft.Maui.Controls.Handlers.Compatibility.FormsUITableViewController.ViewWillLayoutSubviews()
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
2024-01-30 10:57:18.214 JAMApp[11278:62764868]    at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
   at JAMApp.Program.Main(String[] args) in /Users/shingala/Documents/SourceTree/JMM/MAUI-sprint-73-Chetan/JAMApp/JAMApp/Platforms/iOS/Program.cs:line 17
2024-01-30 10:57:20.729 JAMApp[11278:62764868] Unhandled managed exception: Failed to marshal the Objective-C object 0x1010db690 (type: Microsoft_Maui_Platform_ContentView). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'Microsoft.Maui.Platform.ContentView' does not have a constructor that takes one NativeHandle argument). (ObjCRuntime.RuntimeException)
   at ObjCRuntime.Runtime.MissingCtor(IntPtr ptr, IntPtr klass, Type type, MissingCtorResolution resolution)
   at ObjCRuntime.Runtime.ConstructNSObject[UIView](IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution)
   at ObjCRuntime.Runtime.GetNSObject[UIView](IntPtr ptr)
   at UIKit.UIView.get_Superview()
   at Microsoft.Maui.Platform.LayoutView.WillRemoveSubview(UIView uiview)
   at UIKit.UIView.RemoveFromSuperview()
   at Microsoft.Maui.Platform.ViewExtensions.ClearSubviews(UIView view)
   at Microsoft.Maui.Handlers.LayoutHandler.DisconnectHandler(LayoutView platformView)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnDisconnectHandler(UIView platformView)
   at Microsoft.Maui.Handlers.ViewHandler.OnDisconnectHandler(Object platformView)
   at Microsoft.Maui.Handlers.ElementHandler.DisconnectHandler(Object platformView)
   at Microsoft.Maui.Handlers.ElementHandler.Microsoft.Maui.IElementHandler.DisconnectHandler()
   at Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer.UnevenListViewDataSource.CalculateHeightForCell(UITableView tableView, Cell cell)
   at Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer.UnevenListViewDataSource.GetEstimatedRowHeight(UITableView table)
   at Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer.UnevenListViewDataSource.UpdateEstimatedRowHeight(UITableView tableView)
   at Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer.ListViewDataSource.DetermineEstimatedRowHeight()
   at Microsoft.Maui.Controls.Handlers.Compatibility.FormsUITableViewController.ViewWillLayoutSubviews()
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
   at JAMApp.Program.Main(String[] args) in /Users/shingala/Documents/SourceTree/JMM/MAUI-sprint-73-Chetan/JAMApp/JAMApp/Platforms/iOS/Program.cs:line 17

=================================================================
	Native Crash Reporting
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
	Native stacktrace:
=================================================================
	0x1009d8c34 - /private/var/containers/Bundle/Application/D7FC1D30-8111-4669-A3B4-0BADAF73D507/JAMApp.app/JAMApp : GlobalizationNative_GetICUVersion
	0x1009c3d30 - /private/var/containers/Bundle/Application/D7FC1D30-8111-4669-A3B4-0BADAF73D507/JAMApp.app/JAMApp : GlobalizationNative_GetICUVersion
	0x100b9ef10 - /private/var/containers/Bundle/Application/D7FC1D30-8111-4669-A3B4-0BADAF73D507/JAMApp.app/JAMApp : _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy
	0x1009d8448 - /private/var/containers/Bundle/Application/D7FC1D30-8111-4669-A3B4-0BADAF73D507/JAMApp.app/JAMApp : GlobalizationNative_GetICUVersion
	0x208f90888 - /usr/lib/system/libsystem_platform.dylib : <redacted>
	0x20903b680 - /usr/lib/system/libsystem_pthread.dylib : pthread_kill
	0x1a70fdb90 - /usr/lib/system/libsystem_c.dylib : abort
	0x1006e61f8 - /private/var/containers/Bundle/Application/D7FC1D30-8111-4669-A3B4-0BADAF73D507/JAMApp.app/JAMApp : xamarin_find_protocol_wrapper_type
	0x1008bc5a4 - /private/var/containers/Bundle/Application/D7FC1D30-8111-4669-A3B4-0BADAF73D507/JAMApp.app/JAMApp : _ZNK3icu6number23NumberFormatterSettingsINS0_24LocalizedNumberFormatterEE10toSkeletonER10UErrorCode
	0x1009b0374 - /private/var/containers/Bundle/Application/D7FC1D30-8111-4669-A3B4-0BADAF73D507/JAMApp.app/JAMApp : GlobalizationNative_GetICUVersion
	0x1006f900c - /private/var/containers/Bundle/Application/D7FC1D30-8111-4669-A3B4-0BADAF73D507/JAMApp.app/JAMApp : xamarin_get_original_working_directory_path
	0x100a9e958 - /private/var/containers/Bundle/Application/D7FC1D30-8111-4669-A3B4-0BADAF73D507/JAMApp.app/JAMApp : _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy
	0x1c1daadcc - /usr/lib/dyld : <redacted>

=================================================================
	Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x1e678dfbc):0x1e678dfac  ff 0f 5f d6 c0 03 5f d6 10 29 80 d2 01 10 00 d4  .._..._..)......
0x1e678dfbc  03 01 00 54 7f 23 03 d5 fd 7b bf a9 fd 03 00 91  ...T.#...{......
0x1e678dfcc  e8 dd ff 97 bf 03 00 91 fd 7b c1 a8 ff 0f 5f d6  .........{...._.
0x1e678dfdc  c0 03 5f d6 7f 23 03 d5 ff c3 00 d1 f4 4f 01 a9  .._..#.......O..

=================================================================
	Managed Stacktrace:
=================================================================
=================================================================

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,613 questions
{count} votes