Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[One .NET] use API 31 "ref" pack with 32 "runtime" pack (dotnet#6647)
Commit 6eb11f1 added support for API-32, while keeping the .NET 6 default `$(TargetFramework)` value as `net6.0-android31.0`: > However, we don't want to change the default API level for .NET 6 > projects; the default will remain `net6.0-android31.0` (API-31), This appears to have had some unforeseen complications: we would use the API-31 `Mono.Android.dll`, with the API-32 `libmonodroid.so`/etc. runtime libraries. This in turn appears to be responsible for some crashes we've seen on CI ever since commit c227042 when running the `Mono.Android.NET_Tests` unit tests under .NET 6 with the interpreter enabled, because `libxamarin-app.so` and `libmonodroid.so` have ABI dependencies: DOTNET : JNI_OnLoad: JNI_OnLoad in pal_jni.c libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x2 in tid 3666 (droid.NET_Tests), pid 3666 (droid.NET_Tests) crash_dump64: performing dump of process 3666 (target tid = 3666) DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** DEBUG : Build fingerprint: 'Android/sdk_phone_x86_64/generic_x86_64:10/QPP6.190730.005.B1/5775370:userdebug/test-keys' DEBUG : Revision: '0' DEBUG : ABI: 'x86_64' DEBUG : Timestamp: 2022-01-18 16:53:04+0000 DEBUG : pid: 3666, tid: 3666, name: droid.NET_Tests >>> Mono.Android.NET_Tests <<< DEBUG : uid: 10105 DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x2 DEBUG : Cause: null pointer dereference DEBUG : rax 0000000000002b36 rbx 000078c8afb3f860 rcx 000078c98b6561f0 rdx 0000000000000000 DEBUG : r8 0000000000000002 r9 0000000000000080 r10 000078c98b296080 r11 000078c987d35178 DEBUG : r12 00007fffe46ae99c r13 000078c8afb89ea0 r14 000078c8afb3f990 r15 000078c98b6746c0 DEBUG : rdi 000078c8afb3f860 rsi 0000000000000002 DEBUG : rbp 0000000000000001 rsp 00007fffe46ae448 rip 000078c8afb1b31c main : type=1400 audit(0.0:40): avc: granted { read } for name="u:object_r:net_dns_prop:s0" dev="tmpfs" ino=6642 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:net_dns_prop:s0 tclass=file app=Mono.Android.NET_Tests DEBUG : DEBUG : backtrace: DEBUG : #00 pc 000000000002c31c /data/app/Mono.Android.NET_Tests-fbdZV696v1UeW3jUzJg9yg==/lib/x86_64/libmonodroid.so (xamarin::android::Util::monodroid_store_package_name(char const*)+12) (BuildId: 91fe7d9c6b30356fcfb8337b8541d0132df4f44a) DEBUG : #1 pc 0000000000025bbc /data/app/Mono.Android.NET_Tests-fbdZV696v1UeW3jUzJg9yg==/lib/x86_64/libmonodroid.so (xamarin::android::internal::MonodroidRuntime::Java_mono_android_Runtime_initInternal(_JNIEnv*, _jclass*, _jstring*, _jobjectArray*, _jstring*, _jobjectArray*, _jobject*, _jobjectArray*, int, unsigned char, unsigned char)+652) (BuildId: 91fe7d9c6b30356fcfb8337b8541d0132df4f44a) DEBUG : #2 pc 00000000000273fb /data/app/Mono.Android.NET_Tests-fbdZV696v1UeW3jUzJg9yg==/lib/x86_64/libmonodroid.so (Java_mono_android_Runtime_initInternal+75) (BuildId: 91fe7d9c6b30356fcfb8337b8541d0132df4f44a) DEBUG : #3 pc 0000000000174641 /apex/com.android.runtime/lib64/libart.so (art_quick_generic_jni_trampoline+209) (BuildId: 8bb3225e7c408f2ca23abac3db0417f2) … Thinking about it more, we should only need to use the API-31 "ref" or "targeting" pack. The "runtime" pack can just use the latest from the workload. To fix this: 1. Create new `$(_AndroidTargetingPackId)` and `$(_AndroidTargetingPackVersion)` properties to use independently of the runtime pack version. 2. Remove `Microsoft.Android.Runtime.31.[rid]` packs from the workload. 3. Remove the `android-32` workload, as it should no longer be needed. The API 31 "ref" pack is fairly small and can go in the `android` workload. Now our `android` workload is: * `Microsoft.Android.Sdk` * `Microsoft.Android.Ref.31` * `Microsoft.Android.Ref.32` * `Microsoft.Android.Runtime.32.android-arm` * `Microsoft.Android.Runtime.32.android-arm64` * `Microsoft.Android.Runtime.32.android-x86` * `Microsoft.Android.Runtime.32.android-x64` * `Microsoft.Android.Templates` After these changes, I get this assembly at build time: dotnet\packs\Microsoft.Android.Ref.31\31.0.101-preview.11.117\ref\net6.0\Mono.Android.dll And this assembly at runtime: dotnet\packs\Microsoft.Android.Runtime.32.android-arm64\31.0.200-preview.13.21\runtimes\android-arm64\lib\net6.0\Mono.Android.dll Additionally, CI is fully green; in particular, the **APKs .NET - macOS** step is green, which hasn't been true on xamarin-android/main since commit c227042.
- Loading branch information