Skip to content

Commit

Permalink
[tests] enable .NET 7 LLVM tests without Profiled AOT
Browse files Browse the repository at this point in the history
Context: dotnet/runtime#68914

We found that the issue with LLVM only occurs when using Profiled AOT.

This is enabled by default for `Release` builds in .NET 6+, so let's
try using `-p:AndroidEnableProfiledAot=false`.

This at least gets some of our LLVM test coverage running again.

When testing this, we started getting a crash:

    05-24 15:11:36.809  5024  5024 F DEBUG   : Abort message: 'Internal p/invoke symbol 'java-interop @ java_interop_jvm_list' (hash: 0x58c48fc8b89cb484) not found in compile-time map.'

It appeared that `Android.App.Application.cctor` was running before
`JNIEnv.Initialize()` is complete:

    05-25 11:12:33.177 10812 10812 D Mono    : AOT: FOUND method Android.Runtime.JNIEnv/<>c:.cctor () [0x78e0d04608 - 0x78e0d04678 0x78e0d6f8a0]
    05-25 11:12:33.177 10812 10812 D Mono    : Running class .cctor for Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager from 'Mono.Android.dll'
    05-25 11:12:33.177 10812 10812 D Mono    : AOT: FOUND method Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager:.cctor () [0x78e0d31d24 - 0x78e0d31d64 0x78e0d6f8a0]
    05-25 11:12:33.177 10812 10812 D Mono    : Running class .cctor for Android.App.Application from 'Mono.Android.dll'

By adding an explicit static constructor to `Android.App.Application`,
this appears to have workaround this issue.
  • Loading branch information
jonathanpeppers committed May 25, 2022
1 parent 5432886 commit 5832b0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 1 addition & 3 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -699,13 +699,11 @@ stages:

- template: yaml-templates/apk-instrumentation.yaml
parameters:
# TODO: disable LLVM test, see: https://github.com/dotnet/runtime/issues/68914
condition: false
configuration: $(XA.Build.Configuration)
testName: Mono.Android.NET_Tests-AotLlvm
project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj
testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)AotLlvm.xml
extraBuildArgs: -p:TestsFlavor=AotLlvm -p:EnableLlvm=true
extraBuildArgs: -p:TestsFlavor=AotLlvm -p:EnableLlvm=true -p:AndroidEnableProfiledAot=false
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
artifactFolder: $(DotNetTargetFramework)-AotLlvm
useDotNet: true
Expand Down
2 changes: 2 additions & 0 deletions src/Mono.Android/Android.App/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
namespace Android.App {

partial class Application {
// NOTE: an explicit .cctor solves startup ordering with JNIEnv.Initialize()
static Application () { }

static Context? _context;
public static Context Context {
Expand Down

0 comments on commit 5832b0c

Please sign in to comment.