Skip to content

Crash on ios when open new screen or navigate back to it #24032

@DmitryNikiforovCoherent

Description

@DmitryNikiforovCoherent

Description

It seems, there were similar issues previously
#23139,
but now issue appeared after upgrade to maui to 8.0.70 and removing .UseMauiCompatibility()
Sometimes view try to created with NativeHandle argument in constructor

This crash can appeared with Microsoft.Maui.Platform.ContentView|LayoutView and some custom views(so, adding constructor with ObjCRuntime.NativeHandle resolve issue for custom views, but no any options to resolve crashes with ContentView, LayoutView)

Steps to Reproduce

Sometimes just randomly appeared when navigate to new screen or navigate back to existing

Link to public reproduction project repository

No response

Version with bug

8.0.70 SR7

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.40 SR5

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

For custom views we can just add constructor with ObjCRuntime.NativeHandle handle, but no any ways to fix ios ContentView/LayoutView

Relevant log output

Unhandled managed exception: Failed to marshal the Objective-C object 0x14177b170 (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 , IntPtr , Type , MissingCtorResolution , IntPtr , RuntimeMethodHandle )
   at ObjCRuntime.Runtime.ConstructNSObject[UIView](IntPtr , Type , MissingCtorResolution , IntPtr , RuntimeMethodHandle )
   at ObjCRuntime.Runtime.GetNSObject[UIView](IntPtr , IntPtr , RuntimeMethodHandle , Boolean )
   at ObjCRuntime.Runtime.GetNSObject[UIView](IntPtr , IntPtr , RuntimeMethodHandle )
   at ObjCRuntime.Runtime.GetNSObject[UIView](IntPtr )
   at UIKit.UIView.get_Superview()
   at Microsoft.Maui.Platform.MauiView.SetNeedsLayout()

Metadata

Metadata

Assignees

Labels

area-core-lifecycleXPlat and Native UIApplicationDelegate/Activity/Window lifecycle eventsfixed-in-8.0.82fixed-in-8.0.90fixed-in-9.0.0-rc.1.24453.9fixed-in-9.0.0-rc.2.24503.2i/regressionThis issue described a confirmed regression on a currently supported versionp/0Current heighest priority issues that we are targeting for a release.platform/iospotential-regressionThis issue described a possible regression on a currently supported version., verification pendings/needs-attentionIssue has more information and needs another lookt/bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions