unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
9.06k stars 735 forks source link

Windows (WindowsAppSDK 1.6) with Uno MVUX/Navigation crashes when using the new Native AOT feature. #18177

Open Fabi opened 2 months ago

Fabi commented 2 months ago

Current behavior

I did not open the issue under a different repo due to this possibly being related to non merged WindowsAppSDK 1.6 things. Otherwise it should go to toolkit/extensions

Currently when using Native AOT that is supported by WindowsAppSDK 1.6 with the MVUX/Uno navigation it will result in a crash inside Microsoft.UI.Xaml.dll

I intentionally included a very minimal repo using a little WinUI project as base to have as less files included as possible regarding that issue.

WinUI_MVUX_Nav_NAOT_Repo.zip

Expected behavior

It should not crash when navigating.

How to reproduce it (as minimally and precisely as possible)

The repo already includes a ready to use project that sets PublishAot to true for all builds. Means just launching it should result in the crash.

Workaround

Set PublishAot to false

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

No response

Affected platforms

Windows (WinAppSDK)

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

I did not dig in too much into that because I am not sure if that is caused by the latest SDK not being merged into Uni yet.

I only know it happens when navigating and when the call var services = await window.AttachServicesAsync(host.Services); in ServiceProviderExtensions.BuildAndInitializeHostAsync happens.

Fabi commented 2 months ago

Tested with latest dev builds again, but the same still happens there. C# Discord people said most likely some outdated projections