Tested versions
- Reproducible in v4.3.stable.mono
System information
Windows 11
Issue description
The Problem
I've been testing my game on various mobile devices with high end and low end targets. On one of the lower end targets (Google Pixel 4a) a cold startup takes about ~26 seconds! This is an unacceptably slow startup time considering my game's binary is under 250mb. On empty Godot projects the startup time is excellent, and I had a hard time believing the assets being loaded was adding all that extra time.
The Source
Long story short it seems to be a long standing issue that the dotnet runtime on Android has a slow startup time because of JIT compilation and other various factors. This is something that's been hotly debated with projects such as Xamarin and its successor Maui. One solution to this is native ahead of time compilation. Starting with .NET 8, there's experimental support for Android.
The Bug
As of 4.3, Godot doesn't support NativeAOT out of the box for Android. Just mono. iOS also has experimental support within the dotnet runtime, but that is supported in Godot (or at least that's the default functionality since NativeAOT is required on iOS).
To enable NativeAOT all one must do is use the <PublishAOT> tag in the .csproj file. The problem is, to make it work properly, other tags are needed that are overridden by Godot during the export process which is the bug. On such example is the RuntimeIdenitifer tag. linux-bionic-arm64 is the currently used runtime identifier for NativeAOT but Godot always overrides it to android-arm64 even when it's specified in the .csproj file. So, theoretically Godot can support NativeAOT on android with this limitation lifted.
Steps to reproduce
- Create project with C# script.
- Export for android with
NativeAOT enabled.
- Build fails.
Minimal reproduction project (MRP)
N/A
Tested versions
System information
Windows 11
Issue description
The Problem
I've been testing my game on various mobile devices with high end and low end targets. On one of the lower end targets (Google Pixel 4a) a cold startup takes about ~26 seconds! This is an unacceptably slow startup time considering my game's binary is under 250mb. On empty Godot projects the startup time is excellent, and I had a hard time believing the assets being loaded was adding all that extra time.
The Source
Long story short it seems to be a long standing issue that the dotnet runtime on Android has a slow startup time because of
JITcompilation and other various factors. This is something that's been hotly debated with projects such as Xamarin and its successor Maui. One solution to this is native ahead of time compilation. Starting with.NET 8,there's experimental support for Android.The Bug
As of
4.3,Godot doesn't supportNativeAOTout of the box for Android. Just mono.iOSalso has experimental support within the dotnet runtime, but that is supported in Godot (or at least that's the default functionality sinceNativeAOTis required oniOS).To enable
NativeAOTall one must do is use the<PublishAOT>tag in the.csprojfile. The problem is, to make it work properly, other tags are needed that are overridden by Godot during the export process which is the bug. On such example is theRuntimeIdenitifertag.linux-bionic-arm64is the currently used runtime identifier forNativeAOTbut Godot always overrides it toandroid-arm64even when it's specified in the.csprojfile. So, theoretically Godot can supportNativeAOTon android with this limitation lifted.Steps to reproduce
NativeAOTenabled.Minimal reproduction project (MRP)
N/A