Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS crashes on xcode version 16.1 and using a simulator using ios 18.0 #7

Open
mattpearcefanhub opened this issue Dec 9, 2024 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@mattpearcefanhub
Copy link

mattpearcefanhub commented Dec 9, 2024

I've installed the most recent packages provided, however it consistently crashes on iOS. I'm running dotnet 9, maui 8.0.100 and the most recent packages for this wrapper.

My sim is iphone 16, running on iOS 18.0

Crash log:


ObjCRuntime.RuntimeException: Failed to lookup the required marshalling information.
Additional information:
	Selector: drawInContext:
	Type: Microsoft_Maui_Platform_MauiCALayer

 ---> ObjCRuntime.RuntimeException: Failed to get the 'this' instance in a method call to Microsoft.Maui.Platform.MauiCALayer.DrawInContext.
 ---> ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x60000098d5a0 (type: Microsoft_Maui_Platform_MauiCALayer). 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.MauiCALayer' does not have a constructor that takes one NativeHandle argument).
   at ObjCRuntime.Runtime.MissingCtor(IntPtr ptr, IntPtr klass, Type type, MissingCtorResolution resolution, IntPtr sel, RuntimeMethodHandle method_handle) in /Users/builder/azdo/_work/5/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1412
   at ObjCRuntime.Runtime.ConstructNSObject[NSObject](IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution, IntPtr sel, RuntimeMethodHandle method_handle) in /Users/builder/azdo/_work/5/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1543
   at ObjCRuntime.Runtime.ConstructNSObject[NSObject](IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution) in /Users/builder/azdo/_work/5/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1487
   at ObjCRuntime.Runtime.ConstructNSObject(IntPtr ptr, IntPtr klass, MissingCtorResolution missingCtorResolution) in /Users/builder/azdo/_work/5/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1473
   at ObjCRuntime.Runtime.GetNSObject(IntPtr ptr, MissingCtorResolution missingCtorResolution, Boolean evenInFinalizerQueue) in /Users/builder/azdo/_work/5/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1850
   at Registrar.DynamicRegistrar.GetMethodDescriptionAndObject(Type type, IntPtr selector, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc) in /Users/builder/azdo/_work/5/s/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:line 1011
   --- End of inner exception stack trace ---
   at Registrar.DynamicRegistrar.GetMethodDescriptionAndObject(Type type, IntPtr selector, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc) in /Users/builder/azdo/_work/5/s/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:line 1018
   at ObjCRuntime.Runtime.GetMethodAndObjectForSelector(IntPtr klass, IntPtr sel, SByte is_static, IntPtr obj, IntPtr* mthisPtr, IntPtr desc) in /Users/builder/azdo/_work/5/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 977
   at ObjCRuntime.Runtime.get_method_and_object_for_selector(IntPtr cls, IntPtr sel, SByte is_static, IntPtr obj, IntPtr* mthis, IntPtr desc, IntPtr* exception_gchandle) in /Users/builder/azdo/_work/5/s/xamarin-macios/runtime/Delegates.generated.cs:line 712
   --- End of inner exception stack trace ---
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/5/s/xamarin-macios/src/UIKit/UIApplication.cs:line 61
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/5/s/xamarin-macios/src/UIKit/UIApplication.cs:line 96
@mattpearcefanhub mattpearcefanhub changed the title IOS crashes on xcode version 16.1 and using a simulator using os 18.0 IOS crashes on xcode version 16.1 and using a simulator using ios 18.0 Dec 9, 2024
@Kebechet
Copy link
Owner

Kebechet commented Dec 12, 2024

Thank you for report.
I am quite busy but in following week I will take a look

Seems like Clarity released newer fix release so I will try to bump the package and test it on our Demo app

As a potential workaround, can you try to build the app with XCode 16.2 ?

@Kebechet Kebechet self-assigned this Dec 12, 2024
@mattpearcefanhub
Copy link
Author

Thanks for the swift reply @Kebechet. I've just upgraded to xcode 16.2 and the maui packages to 9.0.14 but I'm still receiving the error I logged earlier this week

Thank you again for your work and support, hopefully this is an easy fix on your side

@Kebechet Kebechet added the bug Something isn't working label Dec 12, 2024
Kebechet added a commit that referenced this issue Dec 16, 2024
@Kebechet
Copy link
Owner

I have updated iOS binding to 3.0.2 and wrapper to 1.0.8.
Please test and let me know if it works.

@mattpearcefanhub
Copy link
Author

Hi @Kebechet thank you so much for updating it so quickly. I've just tested it and unfortunately got the same error, do you have any further thoughts or recommendations?

ObjCRuntime.RuntimeException
Failed to marshal the Objective-C object 0x6000007569c0 (type: Microsoft_Maui_Platform_MauiCALayer). 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.MauiCALayer' does not have a constructor that takes one NativeHandle argument).

@Kebechet
Copy link
Owner

interesting 🤔 It crashes during the build or during runtime ?
Can you try to test if the same problem happens in our demo app ?

@mattpearcefanhub
Copy link
Author

It occurs during runtime, it opens the app briefly and then crashes. (By briefly i mean under 1 second)

@Kebechet
Copy link
Owner

even the demo app from my previous comment ?

@mattpearcefanhub
Copy link
Author

Hi @mattpearcefanhub I haven't had the time to fork it and test it yet. And won't be able to do so in the next few hours, but I can get back to you when i can.

@Kebechet
Copy link
Owner

Kebechet commented Dec 19, 2024

Hi @mattpearcefanhub
any update ? Did you try to run the demo app ?

@tobias-goldschmidt
Copy link

Hello @Kebechet and @mattpearcefanhub.

We are facing the same crash with "Failed to marshal the Objective-C", "drawInContext", "Microsoft_Maui_Platform_MauiCALayer" etc. and have been fighting this for a couple of days now.

I am fairly confident, that this crash happens as soon as you place a MAUI RadioButton anywhere on the page.

Your demo app does not crash because it consists only of razor pages. If you remove the BlazorWebView from the MainPage and add a RadioButton there somewhere, it also crashes with the same exception of this ticket (tested this just now).
Another indicator that it is the RadioButton is this bugfix from the official MAUI project, that references iOS, RadioButton and has a single line change in the class "MauiCALayer.cs":
dotnet/maui#25542

For iOS there is no direct equivalent to a radio button so MAUI does some custom rendering of a button. That night be the reason this crash is pretty obscure and does not happen to a lot of people.

We already copied what you did in this repository, to use the newer SDK version 3.0.3 which has a bugfix labelled

  • [BugFix] Fixed crashes caused by layer color issues.

but that also did not resolve the issue.

We are at a means end here and don't know how to proceed other than maybe redesigning our page to use something other than a RadioButton. Issue is happening locally on

macOS 15.3, Xcode 16.2, iOS 18.2 (Simulator and iPhone), iOS 17.5 (Simulator)
pipeline build that crashes has macOS 14 and Xcode 16.1

Same result with MAUI 8.0.91 as with the latest 9.0.30

@mattpearcefanhub can you confirm that you are also using a RadioButton? If not, can you maybe try to single out one component that crashes your app?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants