Open jonathanpeppers opened 2 years ago
I did a little research here, making a sample WinUI3 app without MAUI: App8.zip
The WinUI3 app does:
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<ResourceDictionary Source="ClassLibrary1/ResourceDictionary1.xaml" />
If I change it to be like dotnet/maui:
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
Resources.AddLibraryResources<XamlControlsResources>();
Resources.AddLibraryResources("foo", "ms-appx:///ClassLibrary1/ResourceDictionary1.xbf");
//...
Then I get additional time spent in:
The startup time before/after:
Average(ms): 183.09134
Average(ms): 191.48126
We should investigate if dotnet/maui can do something like this in templates:
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<ResourceDictionary Source="Microsoft.Maui/Platform/Windows/Styles/Resources.xaml" />
Description
Profiling a customer's app, I see time spent in:
With the stack trace of:
https://github.com/dotnet/maui/blob/f1c358800c5276bc16290164eaf98c60f92da9fe/src/Core/src/Hosting/MauiAppBuilder.cs#L72
https://github.com/dotnet/maui/blob/f1c358800c5276bc16290164eaf98c60f92da9fe/src/Core/src/Platform/Windows/ResourceDictionaryExtensions.cs#L29-L32
Can we port parts of this
.xaml
to be fully C# instead?https://github.com/dotnet/maui/blob/main/src/Core/src/Platform/Windows/Styles/Resources.xaml
I suspect this would improve startup times on Windows by some order of magnitude.
Public API Changes
None
Intended Use-Case
Save up to ~87ms of Windows startup time.