Skip to content

"Failed to marshal the Objective-C object..." MauiTextField crash #23684

@jspfister-sep

Description

@jspfister-sep

Apple platform

iOS

Framework version

net9.0-*

Affected platform version

.NET 9.0.303 (workload 9.0.303.1), iOS workload 18.5.9214, iPhone SE, iOS 18.6

Description

This seems to be at least similar to 21648. I see this exception sometimes when backgrounding and resuming the app on iOS. Unfortunately, I am unable to get a full stack trace.

ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x13755b200 (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).

Steps to Reproduce

  1. Add the following code at the start of AppDelegate.FinishedLaunching to increase the likelihood of the bug occurring.
var thread = new Thread ((v) => {
    while (true) {
        Thread.Sleep (1000);
	GC.Collect ();
    }
});
thread.IsBackground = true;
thread.Start ();
  1. Create memory pressure. In my case this means forcing the app to process a lot of test data at high speed.
  2. Visit a page with an Entry control, anything backed by MauiTextField.
  3. Focus the control.
  4. Exit the page.
  5. Immediately, background and reopen the app.
  6. Observe crash when app tries to reopen.

Did you find any workaround?

I have implemented a workaround based on the one mentioned here.

Relevant logs

No response

Metadata

Metadata

Assignees

Labels

bugIf an issue is a bug or a pull request a bug fixregressionThe issue or pull request is a regression

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions