dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.92k stars 526 forks source link

EnableLLVM make Application Crash #8736

Open mattleibow opened 7 months ago

mattleibow commented 7 months ago

Issue moved from dotnet/maui#20665


From @Eskissimo on Saturday, February 17, 2024 2:11:40 PM

Description

When i compile for release with the parameter EnableLLVM at True. The generate APK Launch, show the splashscreen, the first page for 1/2 seconds and the application crash.

Release Property group

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|AnyCPU'">
    <DebugType>none</DebugType>
    <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
    <RunAOTCompilation>True</RunAOTCompilation>
    <EnableLLVM>True</EnableLLVM>
    <PublishTrimmed>True</PublishTrimmed>
    <AndroidUseAapt2>True</AndroidUseAapt2>
    <AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>
    <Optimize>True</Optimize>
    <AndroidEnableMultiDex>True</AndroidEnableMultiDex>
    <AndroidLinkTool>r8</AndroidLinkTool>
    <AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
    <AndroidPackageFormat>apk</AndroidPackageFormat>
</PropertyGroup>

Nugets packages

<ItemGroup>
    <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.7" />
    <PackageReference Include="CommunityToolkit.Maui" Version="7.0.1" />
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
    <PackageReference Include="HtmlAgilityPack" Version="1.11.59" />
    <PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.2" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
    <PackageReference Include="Microsoft.Identity.Client" Version="4.59.0" />
    <PackageReference Include="SkiaSharp" Version="2.88.7" />
</ItemGroup>

Proguard configuration

-keepclassmembers public class androidx.security.crypto.** {
    public <fields>;
}

-keepclassmembers public class androidx.startup.** {
    public <fields>;
}

-keepclassmembers public class androidx.core.app.** {
    public <fields>;
}

If i don't add androidx.startup & androidx.core.app the application crash immediatly.

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.6 SR1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

mattleibow commented 7 months ago

Issue moved from dotnet/maui#20665


From @Eskissimo on Saturday, February 17, 2024 2:12:29 PM

Adb Log : log.zip

jonpryor commented 7 months ago

The app crashes because we're aborting:

4258  4258 F DEBUG   : Process name is fr.dalkia.eti.rscs, not key_process
4258  4258 F DEBUG   : keyProcess: 0
4258  4258 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
4258  4258 F DEBUG   : Build fingerprint: 'OnePlus/NE2213EEA/OP516FL1:14/UKQ1.230924.001/S.1598562-2db37-2df50:user/release-keys'
4258  4258 F DEBUG   : Revision: '0'
4258  4258 F DEBUG   : ABI: 'arm64'
4258  4258 F DEBUG   : Timestamp: 2024-02-17 14:44:37.634932002+0100
4258  4258 F DEBUG   : Process uptime: 63s
4258  4258 F DEBUG   : Cmdline: fr.dalkia.eti.rscs
4258  4258 F DEBUG   : pid: 2673, tid: 4165, name: .NET Timer  >>> fr.dalkia.eti.rscs <<<
4258  4258 F DEBUG   : uid: 10396
4258  4258 F DEBUG   : tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
4258  4258 F DEBUG   : pac_enabled_keys: 000000000000000f (PR_PAC_APIAKEY, PR_PAC_APIBKEY, PR_PAC_APDAKEY, PR_PAC_APDBKEY)
4258  4258 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
4258  4258 F DEBUG   :     x0  0000000000000000  x1  0000000000001045  x2  0000000000000006  x3  00000079637fac80
4258  4258 F DEBUG   :     x4  0000000000000000  x5  0000000000000000  x6  0000000000000000  x7  7f7f7f7f7f7f7f7f
4258  4258 F DEBUG   :     x8  00000000000000f0  x9  0000007b1a436d58  x10 0000000000000001  x11 0000007b1a4bc0ec
4258  4258 F DEBUG   :     x12 00000079637f9a80  x13 000000000000005e  x14 00000079637f9b30  x15 00000adc9f5daf7c
4258  4258 F DEBUG   :     x16 0000007b1a527090  x17 0000007b1a4ffd30  x18 000000796261a000  x19 0000000000000a71
4258  4258 F DEBUG   :     x20 0000000000001045  x21 00000000ffffffff  x22 00000079637fb410  x23 00000079637fb380
4258  4258 F DEBUG   :     x24 0000000000000001  x25 0000000000000001  x26 00000079637fb8a0  x27 0000007970df1000
4258  4258 F DEBUG   :     x28 00000079637fb8c0  x29 00000079637fad00
4258  4258 F DEBUG   :     lr  0000007b1a4acde4  sp  00000079637fac60  pc  0000007b1a4ace10  pst 0000000000001000
4258  4258 F DEBUG   : 9 total frames
4258  4258 F DEBUG   : backtrace:
4258  4258 F DEBUG   :       #00 pc 000000000009ce10  /apex/com.android.runtime/lib64/bionic/libc.so (abort+168) (BuildId: d1a98b526f2f94260a53c3055979a4f6)
4258  4258 F DEBUG   :       #01 pc 000000000001f360  /data/app/~~9Khaypa5B9_2D6UMDbhZew==/fr.dalkia.eti.rscs-8NPrynAGuPYDfDGQGjjjBg==/lib/arm64/libmonodroid.so (xamarin::android::Helpers::abort_application()+8) (BuildId: 29b6b17deb69ead9812e93161fff1e8c50fe531d)
4258  4258 F DEBUG   :       #02 pc 0000000000035660  /data/app/~~9Khaypa5B9_2D6UMDbhZew==/fr.dalkia.eti.rscs-8NPrynAGuPYDfDGQGjjjBg==/lib/arm64/libmonodroid.so (xamarin::android::internal::MonodroidRuntime::mono_log_handler(char const*, char const*, char const*, int, void*)+144) (BuildId: 29b6b17deb69ead9812e93161fff1e8c50fe531d)
4258  4258 F DEBUG   :       #03 pc 00000000001d7068  /data/app/~~9Khaypa5B9_2D6UMDbhZew==/fr.dalkia.eti.rscs-8NPrynAGuPYDfDGQGjjjBg==/lib/arm64/libmonosgen-2.0.so (BuildId: b4eabab966ddf1c49d3c8b923cca5b14598b39f3)
4258  4258 F DEBUG   :       #04 pc 00000000001d7194  /data/app/~~9Khaypa5B9_2D6UMDbhZew==/fr.dalkia.eti.rscs-8NPrynAGuPYDfDGQGjjjBg==/lib/arm64/libmonosgen-2.0.so (BuildId: b4eabab966ddf1c49d3c8b923cca5b14598b39f3)
4258  4258 F DEBUG   :       #05 pc 00000000001d71d8  /data/app/~~9Khaypa5B9_2D6UMDbhZew==/fr.dalkia.eti.rscs-8NPrynAGuPYDfDGQGjjjBg==/lib/arm64/libmonosgen-2.0.so (BuildId: b4eabab966ddf1c49d3c8b923cca5b14598b39f3)
4258  4258 F DEBUG   :       #06 pc 000000000013f210  /data/app/~~9Khaypa5B9_2D6UMDbhZew==/fr.dalkia.eti.rscs-8NPrynAGuPYDfDGQGjjjBg==/lib/arm64/libmonosgen-2.0.so (BuildId: b4eabab966ddf1c49d3c8b923cca5b14598b39f3)
4258  4258 F DEBUG   :       #07 pc 00000000001526fc  /data/app/~~9Khaypa5B9_2D6UMDbhZew==/fr.dalkia.eti.rscs-8NPrynAGuPYDfDGQGjjjBg==/lib/arm64/libmonosgen-2.0.so (BuildId: b4eabab966ddf1c49d3c8b923cca5b14598b39f3)
4258  4258 F DEBUG   :       #08 pc 0000000000004f00  <anonymous:7b38000000>

Note that frame #00 is libc.so (abort+168, and frame #01 is xamarin::android::Helpers::abort_application()+8.

Searching for [Aa][Ss][Ss][Ee][Rr][Tt] ("assert", case-insensitive), and I find:

2673  4165 E dalkia.eti.rscs: * Assertion at /__w/1/s/src/mono/mono/mini/aot-runtime.c:5220, condition `plt_entry' not met
2673  4167 E dalkia.eti.rscs: * Assertion at /__w/1/s/src/mono/mono/mini/aot-runtime.c:5220, condition `plt_entry' not met
jonpryor commented 7 months ago

At a guess, I think we're hitting one of these asserts:

jonpryor commented 7 months ago

Looks like it's this:

which in turn is basically a re-opening of this: