Open jeffgoku opened 1 year ago
Tagging subscribers to 'arch-android': @steveisok, @akoeplinger See info in area-owners.md if you want to be subscribed.
Author: | jeffgoku |
---|---|
Assignees: | - |
Labels: | `os-android`, `untriaged`, `area-Codegen-AOT-mono` |
Milestone: | - |
hi @jeffgoku thanks for the bug report. Do you have a sample app that demonstrates the issue that you could share with us?
This issue has been marked needs-author-action
and may be missing some important information.
This is probably some profiled AOT issue. I think MAUI ships an AOT profile for android that is used by default on Android
/cc @jonathanpeppers
@jeffgoku If you want to try, you can "AOT everything" by setting AndroidEnableProfiledAot=false
in your .csproj
.
It's worth checking if that fixes it.
hi @jeffgoku thanks for the bug report. Do you have a sample app that demonstrates the issue that you could share with us?
Sorry I dont have a sample app, I think it will crash after allocate enough memory to trigger a GC
@jeffgoku If you want to try, you can "AOT everything" by setting
AndroidEnableProfiledAot=false
in your.csproj
.It's worth checking if that fixes it.
@jonathanpeppers Thanks, I will give it a try some later time.
@jeffgoku @jonathanpeppers Stumbled upon this, hitting the same issue. Setting AndroidEnableProfiledAot to 'false' seems to have fixed the issue. What is the next move here, is this workaround acceptable? Otherwise, I could use some time to create a small sample.
If someone could share a .binlog
of the error, that would help us: https://aka.ms/binlog
In the past, the only case I've seen AndroidEnableProfiledAot=false
help was if EnableLLVM=true
was also being used. So, it's worth knowing if that is the case here.
If you are OK with the app size increase, turning off AndroidEnableProfiledAot
will result in better performance, generally.
Could be related: https://github.com/ppy/osu/pull/24500#issuecomment-1676028731
Just caught this one:
01-22 15:20:27.953 16355 16401 E : * Assertion at /__w/1/s/src/mono/mono/mini/aot-runtime.c:5220, condition `plt_entry' not met
--------- beginning of crash
01-22 15:20:27.954 16355 16401 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 16401 (.NET Timer)
01-22 15:20:27.955 16355 16355 I art : Starting a blocking GC Explicit
01-22 15:20:27.957 16410 16410 I AEE_AED : handle_request(12)
01-22 15:20:27.957 16410 16410 I AEE_AED : check process 16355 name:.myapplication.droid
01-22 15:20:27.957 16410 16410 I AEE_AED : tid 16401 abort msg address:0x0000000000000000 si_code:-6 (request from 16355:10255)
01-22 15:20:27.957 16410 16410 W AEE_AED : debuggerd: handling request: pid=16355 uid=10255 gid=10255 tid=16401
01-22 15:20:27.958 16410 16410 I AEE_AED : [preset_info] pid: 16355, tid: 16401, name: .NET Timer >>> ru.myapplication.droid <<<
01-22 15:20:28.030 16410 16410 I AEE_AED : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-22 15:20:28.030 16410 16410 I AEE_AED : Build fingerprint: 'Sony/H4311/H4311:7.1.1/49.0.A.6.107/2691393601:user/release-keys'
01-22 15:20:28.030 16410 16410 I AEE_AED : Revision: '0'
01-22 15:20:28.030 16410 16410 I AEE_AED : ABI: 'arm64'
01-22 15:20:28.030 16410 16410 I AEE_AED : pid: 16355, tid: 16401, name: .NET Timer >>> ru.myapplication.droid <<<
01-22 15:20:28.030 16410 16410 I AEE_AED : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
01-22 15:20:28.031 16410 16410 I AEE_AED : x0 0000000000000000 x1 0000000000004011 x2 0000000000000006 x3 0000000000000008
01-22 15:20:28.031 16410 16410 I AEE_AED : x4 6f635f736600ffff x5 6f635f736600ffff x6 000000797d64f000 x7 00000000000000c0
01-22 15:20:28.031 16410 16410 I AEE_AED : x8 0000000000000083 x9 ffffffffffffffdf x10 0000000000000000 x11 0000000000000001
01-22 15:20:28.031 16410 16410 I AEE_AED : x12 0101010101010101 x13 0000000000000010 x14 ffffffffffffffff x15 000000797a4b7678
01-22 15:20:28.031 16410 16410 I AEE_AED : x16 000000797a4d3ee0 x17 000000797a47c834 x18 0000000000000000 x19 000000794cfff4f8
01-22 15:20:28.031 16410 16410 I AEE_AED : x20 0000000000000006 x21 000000794cfff450 x22 0000000000000000 x23 000000794cffeb10
01-22 15:20:28.031 16410 16410 I AEE_AED : x24 0000000000000001 x25 0000000000000001 x26 000000794cfff030 x27 0000007951736000
01-22 15:20:28.031 16410 16410 I AEE_AED : x28 000000794cfff050 x29 000000794cffe450 x30 000000797a479c60
01-22 15:20:28.031 16410 16410 I AEE_AED : sp 000000794cffe430 pc 000000797a47c83c pstate 0000000060000000
01-22 15:20:28.035 16410 16410 I AEE_AED :
01-22 15:20:28.035 16410 16410 I AEE_AED : backtrace:
01-22 15:20:28.035 16410 16410 I AEE_AED : #00 pc 000000000006d83c /system/lib64/libc.so (tgkill+8)
01-22 15:20:28.035 16410 16410 I AEE_AED : #01 pc 000000000006ac5c /system/lib64/libc.so (pthread_kill+64)
01-22 15:20:28.035 16410 16410 I AEE_AED : #02 pc 0000000000024198 /system/lib64/libc.so (raise+24)
01-22 15:20:28.035 16410 16410 I AEE_AED : #03 pc 000000000001ca3c /system/lib64/libc.so (abort+52)
01-22 15:20:28.035 16410 16410 I AEE_AED : #04 pc 000000000001f360 /data/app/ru.myapplication.droid-1/lib/arm64/libmonodroid.so (_ZN7xamarin7android7Helpers17abort_applicationEv+8)
01-22 15:20:28.035 16410 16410 I AEE_AED : #05 pc 0000000000035660 /data/app/ru.myapplication.droid-1/lib/arm64/libmonodroid.so (_ZN7xamarin7android8internal16MonodroidRuntime16mono_log_handlerEPKcS4_S4_iPv+144)
01-22 15:20:28.035 16410 16410 I AEE_AED : #06 pc 00000000001d6fe8 /data/app/ru.myapplication.droid-1/lib/arm64/libmonosgen-2.0.so
01-22 15:20:28.035 16410 16410 I AEE_AED : #07 pc 00000000001d7114 /data/app/ru.myapplication.droid-1/lib/arm64/libmonosgen-2.0.so
01-22 15:20:28.035 16410 16410 I AEE_AED : #08 pc 00000000001d7158 /data/app/ru.myapplication.droid-1/lib/arm64/libmonosgen-2.0.so
01-22 15:20:28.035 16410 16410 I AEE_AED : #09 pc 000000000013f1cc /data/app/ru.myapplication.droid-1/lib/arm64/libmonosgen-2.0.so
01-22 15:20:28.035 16410 16410 I AEE_AED : #10 pc 00000000001526b8 /data/app/ru.myapplication.droid-1/lib/arm64/libmonosgen-2.0.so
01-22 15:20:28.035 16410 16410 I AEE_AED : #11 pc 0000000000004f00 <anonymous:0000007977d25000>
Bits from project file
<TargetFramework>net8.0-android</TargetFramework>
<RuntimeIdentifiers>android-arm;android-arm64</RuntimeIdentifiers>
<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>
<TrimMode>link</TrimMode>
<EnableLLVM>True</EnableLLVM>
<!-- begin temporary fix for https://github.com/dotnet/runtime/issues/96872 should be removed after february 2024 service release is released -->
<Target Name="UpdateRuntimePackVersion" BeforeTargets="ProcessFrameworkReferences">
<ItemGroup>
<KnownRuntimePack Condition="%(RuntimePackLabels) == 'Mono'" LatestRuntimeFrameworkVersion="8.0.0" />
</ItemGroup>
</Target>
<!-- end temporary fix for https://github.com/dotnet/runtime/issues/96872 should be removed after february 2024 service release is released -->
Works fine without EnableLLVM.
@jeffgoku Try enabling the trim operation for the debugging mode too ... this might help u find the problem Step 1 : Step 2 :
I hope this might help
Enabling trimming for debug didn't change much for me, Debug
was running fine.
At the same time, I can confirm that the combination of
<AndroidEnableProfiledAot>False</AndroidEnableProfiledAot>
<EnableLLVM>True</EnableLLVM>
runs okay on Release
, while
<EnableLLVM>True</EnableLLVM>
randomly crashes with condition 'plt_entry' not met
message.
Can confirm setting AndroidEnableProfiledAot=false stops crashing of my release app caused by "aot-runtime.c:5220, condition `plt_entry' not met", but the APK is now 63mb, twice the size when I don't have that value set to false (and 3x the size of the Xamarin forms APK version the project was migrated from), the compile time on a core i9 is through the roof.
@jonathanpeppers Is the default MAUI-shipped Android AOT profile at cause here? I don't mind the extra AOT time and space requirements but I am simply curious. Also I vaguely remember that creating your own AOT profile in .NET Android was not possible, yet?
There are some known issues mixing:
<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>
<EnableLLVM>True</EnableLLVM>
The reason being when we record an AOT profile (recorded under JIT), some of the wrong code paths are taken for checks like RuntimeFeature.IsSomeHardwareInstrinsticSupported
. I don't think we have a solution for that.
But this combination should work:
<AndroidEnableProfiledAot>False</AndroidEnableProfiledAot>
<EnableLLVM>True</EnableLLVM>
Or this one:
<!-- Note this is the default if you left these blank -->
<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>
<EnableLLVM>False</EnableLLVM>
You can record your own profile with this NuGet package, but it wouldn't solve this issue:
Thanks - rebuilt with the last setting you mention setting and the APK is back to the regular maui APK size and doesn't crash.
I too experience this issue. If one was to choose between
<AndroidEnableProfiledAot>False</AndroidEnableProfiledAot>
<EnableLLVM>True</EnableLLVM>
and
<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>
<EnableLLVM>False</EnableLLVM>
I believe AndroidEnableProfiledAot=True is important if app-size is an issue, but the best performance on runtime will be with AndroidEnableProfiledAot=False and EnableLLVM=True. Is that generally correct?
If anyone is still looking for a repro of this issue then my ImageSharpMAUITest (as of commit ecdf0d92a7195d8f0e9fb74c64cdca4e53db029b
) will reproduce it.
In the csproj I have
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android' AND '$(Configuration)' == 'Release'">
<EnableLLVM>true</EnableLLVM>
<RunAOTCompilation>true</RunAOTCompilation>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
</PropertyGroup>
which runs fine. Removing AndroidEnableProfiledAot
and hitting the Run all tests
in the application itself will result in a crash.
07-27 14:06:30.804 7895 7961 E gesharpmauitest: * Assertion at /__w/1/s/src/mono/mono/mini/aot-runtime.c:5220, condition `plt_entry' not met 07-27 14:06:30.806 7895 7961 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 7961 (.NET TP Worker), pid 7895 (gesharpmauitest)
I did some different things of using different combinations of EnableLLVM
, RunAOTCompilation
, and AndroidEnableProfiledAot
determining performance and filezie. It is written up in this comment.
The TLDR is,
<EnableLLVM>false</EnableLLVM>
<AndroidEnableProfiledAot>true</AndroidEnableProfiledAot>
Having this setup appears to be the same of just deleting the 2 lines.
<EnableLLVM>true</EnableLLVM>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
Will give more performance, but at a larger filesize.
<RunAOTCompilation>true</RunAOTCompilation>
May be implied by EnableLLVM
. Googling "RunAOTCompilation docs" did not lead to any docs on the first page of results, I don't care enough to try hunt ths down on a Saturday to see if that is true or not 😅
Description
Random crash at the assertion in release mode, no problem for debug mode
Reproduction Steps
No repro, only happened in release mode
Expected behavior
should not crash
Actual behavior
crash
Regression?
works in dotnet 7
Known Workarounds
No response
Configuration
Other information
No response