dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.99k stars 1.72k forks source link

'Microsoft.Maui.Platform.LayoutView' does not have a constructor that takes one NativeHandle argument #22150

Closed MichelePannacciTerex closed 4 months ago

MichelePannacciTerex commented 4 months ago

Description

Hi all, as per the title we're experince Unhandled Exception that happens often but randomly. It appears to happen only while the refresh view is refresing.

Note: Running 'dotnet workload list this is the result' (the drop-down below doesn't match mine exactly): ID carico di lavoro installato Versioni del manifesto Origine dell'installazione

------------------------------------------------------------------------------------------
maui-maccatalyst                    8.0.7/8.0.100               SDK 8.0.200               
maui-ios                                    8.0.7/8.0.100               SDK 8.0.200               
maui-android                            8.0.7/8.0.100               SDK 8.0.200    

The problem in this case happened running on macbook but happens in iPads/iPhones as well, Is there any known fix for it or something i can do? Unfortunately this is our first maui app and we lack of experince. Thanks in advance

Steps to Reproduce

No response

Link to public reproduction project repository

None public

Version with bug

Unknown/Other

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS, I was not able test on other platforms

Affected platform versions

iOS 16.6.7/17.4.1, macOS 14.4.1

Did you find any workaround?

no

Relevant log output

2024-05-01 16:56:37.694 MyMauiApp[34785:737104] 
Unhandled Exception:
ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x11e6fa910 (type: Microsoft_Maui_Platform_LayoutView). 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.LayoutView' 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/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1323
   at ObjCRuntime.Runtime.ConstructNSObject[UIView](IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution, IntPtr sel, RuntimeMethodHandle method_handle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1454
   at ObjCRuntime.Runtime.GetNSObject[UIView](IntPtr ptr, IntPtr sel, RuntimeMethodHandle method_handle, Boolean evenInFinalizerQueue) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1791
   at ObjCRuntime.Runtime.GetNSObject[UIView](IntPtr ptr, IntPtr sel, RuntimeMethodHandle method_handle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1753
   at ObjCRuntime.Runtime.GetNSObject[UIView](IntPtr ptr) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1748
   at UIKit.UIView.get_Superview() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/maccatalyst/generated-sources/UIKit/UIView.g.cs:line 4307
   at Microsoft.Maui.Platform.MauiView.LayoutSubviews()
   at Microsoft.Maui.Platform.ContentView.LayoutSubviews()
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
   at MyMauiApp.Program.Main(String[] args) in /Users/dev01/GitHub/MyMauiApp/MyMauiApp/Platforms/MacCatalyst/Program.cs:line 13
2024-05-01 16:56:37.696 MyMauiApp[34785:737104] Unhandled managed exception: Failed to marshal the Objective-C object 0x11e6fa910 (type: Microsoft_Maui_Platform_LayoutView). 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.LayoutView' does not have a constructor that takes one NativeHandle argument). (ObjCRuntime.RuntimeException)
   at ObjCRuntime.Runtime.MissingCtor(IntPtr ptr, IntPtr klass, Type type, MissingCtorResolution resolution, IntPtr sel, RuntimeMethodHandle method_handle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1323
   at ObjCRuntime.Runtime.ConstructNSObject[UIView](IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution, IntPtr sel, RuntimeMethodHandle method_handle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1454
   at ObjCRuntime.Runtime.GetNSObject[UIView](IntPtr ptr, IntPtr sel, RuntimeMethodHandle method_handle, Boolean evenInFinalizerQueue) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1791
   at ObjCRuntime.Runtime.GetNSObject[UIView](IntPtr ptr, IntPtr sel, RuntimeMethodHandle method_handle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1753
   at ObjCRuntime.Runtime.GetNSObject[UIView](IntPtr ptr) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 1748
   at UIKit.UIView.get_Superview() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/maccatalyst/generated-sources/UIKit/UIView.g.cs:line 4307
   at Microsoft.Maui.Platform.MauiView.LayoutSubviews()
   at Microsoft.Maui.Platform.ContentView.LayoutSubviews()
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
   at MyMauiApp.Program.Main(String[] args) in /Users/dev01/GitHub/MyMauiApp/MyMauiApp/Platforms/MacCatalyst/Program.cs:line 13

=================================================================
    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:
=================================================================
    0x102557778 - /Users/dev01/GitHub/MyMauiApp/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : mono_dump_native_crash_info
    0x10251078c - /Users/dev01/GitHub/MyMauiApp/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : mono_handle_native_crash
    0x102659908 - /Users/dev01/GitHub/MyMauiApp/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : sigabrt_signal_handler.cold.1
    0x102557038 - /Users/dev01/GitHub/MyMauiApp/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : mono_runtime_setup_stat_profiler
    0x18df57584 - /usr/lib/system/libsystem_platform.dylib : _sigtramp
dotnet-policy-service[bot] commented 4 months ago

Hi @MichelePannacciTerex. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

dotnet-policy-service[bot] commented 4 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

MichelePannacciTerex commented 4 months ago

I'm going to close this issue as ended up to be a problem (hard to catch) with a third party (paid) control. With the fixed one the problem goes away. Sorry for the bug report.

MichelePannacciTerex commented 4 months ago

Not a maui bug