Skip to content

See if we can use $(AndroidAotMode)=full MONO_AOT_MODE_FULL #9469

@jonathanpeppers

Description

@jonathanpeppers

Android framework version

net9.0-android

Affected platform version

.NET 9 RC 2

Description

I was trying to enable "full AOT" and disable JIT on Android:

  • dotnet new maui - remove the other platforms beside Android
  • dotnet build build -c Release -p:AndroidAotMode=full -p:AndroidEnableProfiledAot=false -p:RunAOTCompilation=true -r android-arm64 -bl -t:Run

This should "AOT everything" and also toggle MONO_AOT_MODE_FULL at runtime.

This appears to pass the right flags to the <MonoAOTCompiler/> task:
Image

And at runtime:

10-30 08:58:14.982  9378  9378 D monodroid: Mono AOT mode: full
...
10-30 08:58:14.982  9378  9378 D monodroid: Probing for Mono AOT mode
10-30 08:58:14.982  9378  9378 D monodroid: Enabling AOT mode in Mono
10-30 08:58:14.982  9378  9378 D monodroid: Probing if we should use LLVM

mono_jit_set_aot_mode (mode);

But then the JIT is still used and we crash:

10-30 08:58:15.015  9378  9378 F mono-rt : [ERROR] FATAL UNHANDLED EXCEPTION: System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode. See https://learn.microsoft.com/xamarin/ios/internals/limitations for more information.
10-30 08:58:15.015  9378  9378 F mono-rt : 
10-30 08:58:15.015  9378  9378 F mono-rt :    at System.Runtime.InteropServices.Marshal.PtrToStructure[JavaVMInterface](IntPtr )
10-30 08:58:15.015  9378  9378 F mono-rt :    at Java.Interop.JniRuntime.CreateInvoker(IntPtr )
10-30 08:58:15.015  9378  9378 F mono-rt :    at Java.Interop.JniRuntime..ctor(CreationOptions )
10-30 08:58:15.015  9378  9378 F mono-rt :    at Android.Runtime.AndroidRuntime..ctor(IntPtr , IntPtr , IntPtr , IntPtr , Boolean )
10-30 08:58:15.015  9378  9378 F mono-rt :    at Android.Runtime.JNIEnvInit.Initialize(JnienvInitializeArgs* )

Perhaps it fails on the first generic method?

Steps to Reproduce

See above.

Did you find any workaround?

No.

Relevant log output

aot-mode-full.txt

Metadata

Metadata

Labels

Area: App RuntimeIssues in `libmonodroid.so`.Area: App+Library BuildIssues when building Library projects or Application projects.enhancementProposed change to current functionality.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions