Description
Apple platform
iOS
Framework version
net9.0-*
Affected platform version
VS 2022 17.12
Description
We have received feedback from users experiencing random crashes in our app, which have led to some instances of data loss. The app, used for creating and managing health records, is encountering issues with "marshaling Objective-C objects" like MauiTextField and ContentView.
ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x13d566800 (type: Microsoft_Maui_Platform_MauiTextField). 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.MauiTextField' does not have a constructor that takes one NativeHandle argument).
at ObjCRuntime.Runtime.MissingCtor(IntPtr , IntPtr , Type , MissingCtorResolution , IntPtr , RuntimeMethodHandle )
at ObjCRuntime.Runtime.ConstructNSObject[NSObject](IntPtr , Type , MissingCtorResolution , IntPtr , RuntimeMethodHandle )
at ObjCRuntime.Runtime.ConstructNSObject[NSObject](IntPtr , Type , MissingCtorResolution )
at ObjCRuntime.Runtime.ConstructNSObject(IntPtr , IntPtr , MissingCtorResolution )
at ObjCRuntime.Runtime.GetNSObject(IntPtr , MissingCtorResolution , Boolean )
at ObjCRuntime.Runtime.GetNSObject(IntPtr )
at ObjCRuntime.Runtime.InvokeConformsToProtocol(IntPtr , IntPtr )
at ObjCRuntime.Runtime.invoke_conforms_to_protocol(IntPtr obj, IntPtr protocol, IntPtr* exception_gchandle)
Exception_EndOfInnerExceptionStack
Error: System.Exception: CurrentDomainOnUnhandledException
---> ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x156f97480 (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 , IntPtr , Type , MissingCtorResolution , IntPtr , RuntimeMethodHandle )
at ObjCRuntime.Runtime.ConstructNSObject[UIResponder](IntPtr , Type , MissingCtorResolution , IntPtr , RuntimeMethodHandle )
at ObjCRuntime.Runtime.GetNSObject[UIResponder](IntPtr , IntPtr , RuntimeMethodHandle , Boolean )
at ObjCRuntime.Runtime.GetNSObject[UIResponder](IntPtr , IntPtr , RuntimeMethodHandle )
at ObjCRuntime.Runtime.GetNSObject[UIResponder](IntPtr )
at UIKit.UIResponder.get_NextResponder()
at Microsoft.Maui.Platform.ViewExtensions.FindResponder[UIScrollView](UIView view)
at Microsoft.Maui.Platform.KeyboardAutoManagerScroll.AnimateHidingKeyboard()
at ObjCRuntime.Trampolines.SDAction.Invoke(IntPtr block)
at UIKit.UIView.AnimateNotify(Double , Double , UIViewAnimationOptions , Action , UICompletionHandler )
at UIKit.UIView.Animate(Double , Double , UIViewAnimationOptions , Action , Action )
at Microsoft.Maui.Platform.KeyboardAutoManagerScroll.WillHideKeyboard(NSNotification notification)
at Foundation.InternalNSNotificationHandler.Post(NSNotification s)
at Foundation.InternalNSNotificationHandler.__Registrar_Callbacks__.callback_1514_Foundation_InternalNSNotificationHandler_Post(IntPtr pobj, IntPtr sel, IntPtr p0, IntPtr* exception_gchandle)
Exception_EndOfInnerExceptionStack
Steps to Reproduce
Unfortunately, we are unable to provide specific steps to reproduce the issue, as the crashes appear to occur randomly. The issue seems to be related to "marshaling Objective-C objects" like MauiTextField and ContentView, but there is no consistent pattern or specific actions that reliably trigger the error. We are continuing to monitor the situation and gather more information in hopes of identifying any potential triggers. Based on the nature of the issue, we believe it may be related to xamarin-macios. We don't think this happens on Windows, but as dotnet/maui#21485 exists, we are not that sure about this.
Did you find any workaround?
No 😔
Relevant logs
No response