dotnet / maui-samples

Samples for .NET Multi-Platform App UI (.NET MAUI)
https://dot.net/maui
MIT License
3.11k stars 1.28k forks source link

Support for native-aot? #59

Closed queequac closed 3 years ago

queequac commented 3 years ago

Could not find any reference or statement, but will Xamarin for .NET 6 support Native-AOT?

jonathanpeppers commented 3 years ago

This isn't complete yet, but this is being worked on here: https://github.com/xamarin/xamarin-android/pull/5539

queequac commented 3 years ago

Is that one related to dotnet's upcoming Native-AoT? (Formerly known as CoreRT, committed for dotnet 6 and developed in https://github.com/dotnet/runtimelab/tree/feature/NativeAOT) Not sure about this after reading through the referenced item, since it mentions MonoAOT and comparable several times.🤔

jonathanpeppers commented 3 years ago

I think this will be based on Mono's AOT -- specific for iOS and Android.

queequac commented 3 years ago

I see, thanks for the clarification. Is there some documenttion or additional material? Would be interesting to have a comparison of both AOT approaches... and why iOS and Android won't make use of the same native AOT compiler that will ship with .NET6+.

jonathanpeppers commented 3 years ago

iOS and Android will use the Mono runtime instead of CoreCLR, and so that is why they would also use the Mono AOT compiler.

I don't know when CoreCLR would be able to run on iOS or Android -- or if that will even happen at all.

If there are docs, you might check the dotnet/runtime repo, one I found:

https://github.com/dotnet/runtime/blob/master/src/mono/nuget/Microsoft.NET.Runtime.MonoAOTCompiler.Task/README.md

queequac commented 3 years ago

I see, thanks for pointing this out.

To be honest, I was hoping for "CoreRT" (now called NativeAOT for dotnet6 and not relying on CoreCLR), which is really rocking fast, especially wrt to cold start. But of course it would lack all native bindings for Android, which could be one of the most costly parts when trying to bring this to Android.

hez2010 commented 3 years ago

Mono aot is slow at both startup speed and runtime performance, really hope that MAUI can make use of NativeAOT (previously named CoreRT) instead of mono aot in the future.

chucker commented 3 years ago

Native-AoT? (Formerly known as CoreRT, committed for dotnet 6

I don't think it's committed for anything; the project lists it as an an "experimental fork".

.NET 6 mobile (née Xamarin) still uses Mono's runtime (albeit now with .NET 6's BCL instead of Mono's).

jonathanpeppers commented 3 years ago

iOS has had AOT in .NET 6 for a while, because it is required for devices.

We just landed Android AOT, which should ship in .NET 6 Preview 7: https://github.com/xamarin/xamarin-android/pull/5539

You use the <RunAOTCompilation>true</RunAOTCompilation> for a Release build to try it out. This enables the <MonoAOTCompiler/> MSBuild task.

I think that solves the original question? Closing, thanks.

trampster commented 3 years ago

The original question was about NativeAOT (was CoreRT), which is vastly better than Android AOT. NativeAOT is full AOT solution that massively reduces the deployment size. Andorid AOT makes your deployment bigger.

I think the answer however is no because in NativeAOT is an experiment and is not support on arm yet let alone Android. And Maui still uses the mono runtime even in .Net 6