r/AvaloniaUI • u/bktnmngnn • 5h ago
An update on a project I rebuilt for performance: Avalonia 12 and Native AOT
An update on an Avalonia project I rebuilt to run on Native AOT. This is a live keys rig. Think: SundayKeys App, Camelot Pro, Ableton, Mainstage, GigPerformer. But for android primarily, and windows.
I thought I wouldn't be able to make it work fast enough. I had a beta build publicly available, loading times leave much to be desired, and fps dropped frequently. Avalonia 12 releases, I finally migrated and forced myself to work on getting things running with Native AOT.
After months of work it paid off. load times are just as fast as any native app, no more fps drops, navigation is almost instant, and performance is great considering my test device is a very low-end tablet with 4gigs of ram and a unisoc T606.
It might be an unusual stack for this type of project, but it works well. It might've taken a bit more work than just going full on kotlin or the usual frameworks for these types of apps, but its a good enough trade off for me to keep using a stack that I am experienced and comfortable with.
Still smoothing out the rough edges (basically just improving the UI)
Some added context:
- The beta (before this rebuild) was on Avalonia 11.3, no Native AOT
- The engine itself is now mostly in C++, but a chunk of the logic (persistence, ui logic) still lives in C#
- It was desktop-first before so the Native AOT was not really a consideration since it already ran well. Moving into a mobile-first priority (for personal reasons, mainly portability on my part) and how it runs on a mobile device exposed those ugly parts which added to the realization that i really need Native AOT despite it being a stricter environment.

