Skip to content

NativeAOT - Crash when constructing a Java class with Java->C# callbacks #10126

@emmauss

Description

@emmauss

Android framework version

net10.0-android (Preview)

Affected platform version

main as of 199efa8

Description

When constructing an object of a class with Java to C# callbacks, the app crashes with the following error:

digest=============com.avalonia.safeareademo /apex/com.android.runtime/lib/bionic/libc.so (abort+) ()
XXlib/arm/libSafeAreaDemo.Android.so (SystemNative_Abort+) ()
XXlib/arm/libSafeAreaDemo.Android.so (S_P_CoreLib_Interop_Sys__Abort+) ()
XXlib/arm/libSafeAreaDemo.Android.so (S_P_CoreLib_System_RuntimeExceptionHelpers__FailFast+) ()
XXlib/arm/libSafeAreaDemo.Android.so (RuntimeFailFast+) ()
XXlib/arm/libSafeAreaDemo.Android.so (S_P_CoreLib_System_Runtime_EH__UnhandledExceptionFailFastViaClasslib+) ()
XXlib/arm/libSafeAreaDemo.Android.so (S_P_CoreLib_System_Runtime_EH__DispatchEx+) ()
XXlib/arm/libSafeAreaDemo.Android.so (RhThrowEx+) ()
XXlib/arm/libSafeAreaDemo.Android.so (RhpThrowEx+) ()
XXlib/arm/libSafeAreaDemo.Android.so (S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__EnsureClassConstructorRun+) ()
XXlib/arm/libSafeAreaDemo.Android.so (RhpCallCatchFunclet+) ()
XXlib/arm/libSafeAreaDemo.Android.so (S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__CheckStaticClassConstructionReturnNonGCStaticBase+) ()
XXlib/arm/libSafeAreaDemo.Android.so (Mono_Android_Runtime_Android_Runtime_AndroidRuntimeInternal__WaitForBridgeProcessing+) ()
XXlib/arm/libSafeAreaDemo.Android.so (Mono_Android_Android_Runtime_JNINativeWrapper__Wrap_JniMarshal_PPLL_L+) ()
XXlib/arm/libSafeAreaDemo.Android.so (Mono_Android__JniMarshal_PPLL_L__InvokeClosedStaticThunk+) ()
XXlib/arm/libSafeAreaDemo.Android.so (Internal_CompilerGenerated__Module___<ReverseDelegateStub>Mono_Android__JniMarshal_PPLL_L+) ()
/apex/com.android.art/lib/libart.so (art_quick_generic_jni_trampoline+) ()

This occurred in my app because created a class inheriting WindowInsetsAnimationCompat.Callback, which has multiple abstract methods with definitions similar to Java.Lang.Object MethodName (Java.Lang.Object, Java.Lang.Object), eg. public WindowInsetsCompat OnApplyWindowInsets(View v, WindowInsetsCompat insets)

Steps to Reproduce

  1. Clone this branch https://github.com/emmauss/AndroidNativeAOTTest/tree/callback_crash
  2. Build app and run
  3. App crashes immediately.

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Labels

Area: NativeAOTIssues that only occur when using NativeAOT.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions