English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

Uno Platform AOT Compilation: Complete Cross-Platform Native Performance Guide

Forum topic · ✨步子哥 · 2026-02-17

Summary

This comprehensive technical study examines AOT (ahead-of-time) compilation support across all platforms in Uno Platform, the cross-platform .NET UI framework. It covers four runtime execution modes—Interpreter, Mixed (InterpreterAndAOT), Full AOT, and the .NET 9+ Jiterpreter—and maps each target platform to its underlying toolchain: Mono AOT for iOS, Mono AOT plus LLVM and Profile-Guided AOT for Android, Emscripten-based Mono AOT for WebAssembly, and .NET Native AOT for Skia desktop and WinUI 3 targets. The guide details version requirements across .NET 7/8/9 and Uno Platform 4.7 through 6.0, including the 74% Windows package size reduction and 35% faster AOT builds in Uno 6.0, and the up to 10x WebAssembly speedup from combining Jiterpreter with Profiled AOT in Uno 5.6. Platform-specific configuration snippets cover MSBuild properties like WasmShellMonoRuntimeExecutionMode, EnableLLVM, AndroidEnableMarshalMethods, and WasmShellEnableJiterpreter, plus Startup Tracing workflows, trimming strategies, GC tuning, and compatibility constraints such as the iOS ban on dynamic code generation and reflection limitations. Recommended defaults: mandatory Full AOT on iOS, PG-AOT plus LLVM plus Marshal Methods on Android, and Mixed AOT plus Jiterpreter on WebAssembly.

Uno Platform AOT Compilation: Complete Cross-Platform Native Performance Guide

This post presents a full-scope study of AOT (ahead-of-time) compilation support in Uno Platform, covering execution modes, platform toolchains, configuration steps, optimization strategies, and compatibility constraints for iOS, Android, WebAssembly, and desktop targets.

Key points

  • Four runtime execution modes: Interpreter (default, ~30x slower than compiled WASM), Mixed (InterpreterAndAOT, ~50% smaller than full AOT, recommended for WASM production), Full AOT (mandatory on iOS), and Jiterpreter (.NET 9+, runtime JIT within the interpreter, up to 10x speedup when combined with Profiled AOT).
  • Platform toolchain matrix: iOS uses Mono Full AOT (required by Apple's no-dynamic-code policy / W^X memory protection); Android uses Mono AOT with optional LLVM backend (-p:EnableLLVM=true, ~20-40% perf gain) and Profile-Guided AOT; WebAssembly uses Mono AOT via Emscripten; Skia Desktop and WinUI 3 use .NET Native AOT (ILC + RyuJIT).
  • .NET 9 milestones: Jiterpreter, incremental AOT builds, WebCIL packaging, and automatic Emscripten toolchain management (no manual EMSDK install; ARM64 host support on Windows/macOS/Linux).
  • Version highlights: Uno 4.7 introduced Native AOT for Skia+GTK; Uno 5.6 delivered up to 10x WASM AOT performance; Uno 6.0 replaced WPF with a Win32 backend, cutting Windows blank-app size by 74%, iOS by 21%, and improving AOT build times by 35%. iOS startup on iPhone 13 dropped from 1.5s to 0.49s with the unified Skia engine.
  • iOS

  • Full AOT is forced by the platform; no PublishAot needed. Release config relies on RuntimeIdentifier=ios-arm64, PublishTrimmed, and UnoXamlTrimming (Uno 6.0+).
  • Trimming modes: None, SdkOnly (default), Full (aggressive; mitigate with [DynamicDependency] and LinkerConfig.xml).
  • Not available on iOS: System.Reflection.Emit, DynamicMethod, Assembly.Load(byte[]), Roslyn scripting; RegexOptions.Compiled is ignored. Use source generators, [JsonSerializable]-based System.Text.Json source-gen serialization, and cached delegates instead.
  • GC tuning via MtouchEnableSGenConc, MtouchNurserySize, or MONO_GC_PARAMS environment variables.
  • Android

  • AOT must be explicitly enabled: RunAOTCompilation=true, EnableLLVM=true, AndroidEnableMarshalMethods=true (.NET 8+, reduces JNI overhead 15-25%), PublishTrimmed=true, AndroidEnableProfiledAot=true.
  • Startup Tracing workflow: add Mono.AotProfiler.Android, run dotnet build -t:BuildAndStartAotProfiling with profiling disabled AOT, exercise the app 30-60s, then FinishAotProfiling to produce custom.aprof; integrate via <AndroidAotProfile Include="Android/custom.aprof" />.
  • Trade-off matrix (relative to interpreter baseline): PG-AOT ≈120-140% size, ~90% perf (production default); Full AOT + LLVM ≈180-220% size, 100% perf, 2-3x build time.
  • Google Play requires AAB format (-p:AndroidPackageFormat=aab) and arm64-v8a; multi-ABI builds scale AOT time linearly. String resource trimming via AndroidLinkResources can cut 10-30% of resource size.
  • WebAssembly

  • Production setup: <WasmShellMonoRuntimeExecutionMode>InterpreterAndAOT</WasmShellMonoRuntimeExecutionMode> — active only on dotnet publish / Release builds.
  • Profile-Guided AOT: set WasmShellGenerateAOTProfile=true, run typical scenarios without debugger, press Alt+Shift+P to download the .aotprofile, then include it via WasmShellEnableAotProfile (auto-detected under Platforms/WebAssembly/ with Uno.Sdk).
  • Jiterpreter (.NET 9+): <WasmShellEnableJiterpreter>true</WasmShellEnableJiterpreter>; tune via WasmShellRuntimeOptions (--jiterpreter-estimate-heat, --jiterpreter-stats-enable); inspect stats with INTERNAL.jiterpreter_dump_stats() in the browser console. Recommended: enable Mixed AOT and Jiterpreter together — they are complementary.
  • Desktop

  • Skia desktop targets (GTK/Linux/macOS/Windows) support .NET Native AOT for single-file self-contained deployment (supported since Uno 4.7). WPF does not support Native AOT — migrate to WinUI 3 or GTK. WinUI 3 with the Skia+Win32 path is the recommended Windows configuration on Uno 6.0+.

General compatibility advice

Verify third-party NuGet packages for trim-friendliness (IsTrimmable metadata), reflection/dynamic-proxy usage, native ARM64/P/Invoke availability, and known AOT issues before adoption; validate with trimmer warnings and on-device testing.

Tags

#uno-platform#aot-compilation#dotnet#webassembly#android#ios#native-aot#cross-platform

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/176922805