Skip to content

Unable to Export for NativeAOT on Android #97775

Description

@atlasapplications

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

  1. Create project with C# script.
  2. Export for android with NativeAOT enabled.
  3. Build fails.

Minimal reproduction project (MRP)

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions