Skip to content

CoreCLR startup crash with dotnet new maui -sc #9962

@ivanpovazan

Description

@ivanpovazan

Android framework version

net10.0-android (Preview)

Affected platform version

.NET 10.0.100-preview.3.25167.101

Description

dotnet new maui -sc template crashes at startup with CoreCLR with:

03-25 14:32:41.634  6548  6548 D AndroidRuntime: Shutting down VM
03-25 14:32:41.635  6548  6548 E AndroidRuntime: FATAL EXCEPTION: main
03-25 14:32:41.635  6548  6548 E AndroidRuntime: Process: com.companyname.dotnetnewmauisamplecontent, PID: 6548
03-25 14:32:41.635  6548  6548 E AndroidRuntime: android.runtime.JavaProxyThrowable: [System.InvalidOperationException]: InvalidOperation_HandleIsNotInitialized
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at System.WeakReference`1.SetTarget + 0x18(Unknown Source)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at Microsoft.Maui.ApplicationModel.ActivityLifecycleContextListener.set_Activity + 0x0(Unknown Source)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at Microsoft.Maui.ApplicationModel.ActivityLifecycleContextListener.Android.App.Application.IActivityLifecycleCallbacks.OnActivityResumed + 0x0(Unknown Source)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at Android.App.Application+IActivityLifecycleCallbacksInvoker.n_OnActivityResumed_Landroid_app_Activity_ + 0xe(Unknown Source)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at crc64ba438d8f48cf7e75.ActivityLifecycleContextListener.n_onActivityResumed(Native Method)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at crc64ba438d8f48cf7e75.ActivityLifecycleContextListener.onActivityResumed(ActivityLifecycleContextListener.java:42)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.Application.dispatchActivityResumed(Application.java:431)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.Activity.dispatchActivityResumed(Activity.java:1434)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.Activity.onResume(Activity.java:1995)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at androidx.fragment.app.FragmentActivity.onResume(FragmentActivity.java:309)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1531)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.Activity.performResume(Activity.java:8422)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4793)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4836)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2308)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:201)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:288)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7898)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
03-25 14:32:41.635  6548  6548 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

This might be related to the new _AndroidUseManagedMarshalMethodsLookup feature, as passing -p:_AndroidUseManagedMarshalMethodsLookup=true with Mono reaches:

...
03-25 14:39:02.172  6939  6939 F Mono.Android: GetFunctionPointer failed: should not be reached
...

### Steps to Reproduce

1. Checkout `https://github.com/ivanpovazan/coreclr-android-perf`
2. Run: `./prepare.sh` script to download and install the latest nightly builds of dotnet SDK, dotnet/android and dotnet/maui
3. Build/run the sample with `./build.sh dotnet-new-maui-samplecontent coreclr run`
4. Observe the adb logcat

### Did you find any workaround?

No

### Relevant log output

```shell

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions