Skip to content

Enable NativeAOT publishing for the mobile app - #4

Merged
jfversluis merged 1 commit into
mainfrom
simonrozsival-native-aot-build
Oct 9, 2026
Merged

jfversluis merged 1 commit into
mainfrom
simonrozsival-native-aot-build

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Enable unconditional PublishAot=true in the app and IsAotCompatible=true in Core, leaving runtime selection to the SDK.
  • Add narrowly scoped package-source mapping for the pinned Android NativeAOT runtime on Microsoft's official .NET 11 feed; preserve the existing SDK and workload versions.
  • Publish the Android NativeAOT AAB in CI and document Release publishing and JDK 21 requirements.

Validation

  • All 23 Core tests passed with the pinned RC1 SDK.
  • Published an Android ARM64 NativeAOT APK and an ARM64/x64 AAB; confirmed their native payloads.
  • Installed and launched the Release APK on Samsung A16 (SM-A165F, Android 16), preserving app data; verified the home page rendered and the app remained running.
  • Verified home and agenda navigation on an ARM64 Android emulator.

Samsung A16 startup comparison

Measured ARM64 Release APKs on the same Samsung A16 running Android 16. Each configuration has 15 measured process-cold launches across three randomized blocks, with two warmups excluded per block. The metric is Android am start -W -S TotalTime to first frame, not reboot/storage-cache-cold startup or time to a fully populated agenda. App data was preserved and thermal status remained normal.

Configuration Median startup p90 startup Signed APK size
.NET 11 CoreCLR defaults (partial R2R) 2,042 ms 2,085 ms 23.73 MiB
.NET 11 CoreCLR full R2R 1,818 ms 1,854 ms 29.09 MiB
.NET 11 CoreCLR bundled + audited 20-second custom MIBC 1,597 ms 1,637 ms 23.97 MiB
.NET 10 Mono, default profiled AOT 1,332 ms 1,387 ms 21.35 MiB
.NET 11 Native AOT 873 ms 901 ms 22.72 MiB

The full-R2R, Mono, and NativeAOT rows above were measured together in a fresh randomized comparison. The defaults row comes from the initial experiment; the audited custom-MIBC row comes from a subsequent controlled profile comparison. The full-R2R control in that subsequent batch measured 1,797 ms, consistent with the earlier batch but not identical.

APK size is acceptable. The unresolved concern is CoreCLR startup performance relative to Mono. Full R2R remains approximately 36.5% slower than .NET 10 Mono in the same measurement batch. The audited custom MIBC improves startup but remains approximately 19.9% slower than Mono across the respective batches. We need to investigate this gap rather than treat these measurements as a settled runtime-selection result.

MIBC audit

  • Used MAUI CLI nightly 0.1.0-preview.12.26479.1 with maui profile startup --format mibc on the A16; the custom profile was added alongside the bundled MAUI profiles and its inclusion was verified in the actual crossgen2 inputs.
  • The initial five-second profile was a valid CoreCLR/Android/ARM64 MIBC containing 10,603 methods, including app construction, home initialization, and agenda loading. The non-JSON collector also reacted to stdin EOF as a manual-stop request; its actual recorded duration was approximately 5.35 seconds.
  • Recollected for approximately 20.19 seconds with stdin held open and explicit tiering/QuickJit/PGO settings for training only. Coverage increased to 14,668 methods and included tiered background-JIT activity. In a fresh comparison, the original-profile APK measured 1,835 ms median and the extended-profile APK measured 1,597 ms.
  • Neither profile contains instrumented block/edge-count data: these are method-list MIBCs, not weighted dynamic-PGO profiles. Duration, explicit training settings, and compiler/layout effects were not independently isolated, so the improvement must not be attributed to one factor without further investigation.

Comparison limitations

The Mono baseline uses an isolated .NET SDK 10.0.401, workload set 10.0.401.1, MAUI 10.0.110, and Mono runtime 10.0.12. Minimal compatibility changes were required for older XAML namespace handling, native Android handlers, status-bar APIs, tab badges, map APIs, back-button accessibility, and an optional JSON collection. The home content/data logic was retained and all 23 Core tests passed under .NET 10, but this is not a pure runtime-only comparison: MAUI/framework versions and some native presentation APIs differ. The isolated compatibility build does not change this PR's production .NET 11 pins or unconditional PublishAot=true setting.

Raw launch samples, APK byte counts/hashes, build commands, traces, MIBCs, and the Mono compatibility patch are retained in local session artifacts outside the repository; generated binaries and traces are not committed.

Outstanding

  • Investigate the CoreCLR-versus-Mono startup gap. Establish a matched source/handler baseline where practical, then separate runtime initialization, remaining JIT/generic compilation, R2R loading/coverage, and native UI/layout costs. Collect representative startup traces and repeat controlled measurements before drawing a causal conclusion. APK size is not the current optimization priority.
  • iOS NativeAOT publish is not verified locally: the pinned workload rejects the installed Xcode 27 and requires Xcode 26.6.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival marked this pull request as ready for review October 9, 2026 14:07
@jfversluis
jfversluis merged commit 4b20776 into main Oct 9, 2026
3 checks passed
@simonrozsival

Copy link
Copy Markdown
Collaborator Author

The slow startup on CoreCLR is likely caused by dotnet/maui#39315

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants