Improve startup performance
See original GitHub issueIs your feature request related to a problem? Please describe.
Avalonia takes quite long to show a window. A simple hello world app takes 2.4 seconds on my machine. If I use PublishReadyToRun=true
the startup time decreases to 1.4 seconds. However, that’s still very long compared to Windows Forms which takes less 0.5 seconds. Launching an Avalonia application therefore feels unresponsive and slow.
Hand stopped | Avalonia 0.10.0-rc1 | .NET 5.0.1 | Intel Core i5 2400 | Samsung SSD 850 Evo
Describe the solution you’d like
- Make the startup process more efficient.
- Support fast launch of splash screens.
The latter would make Avalonia applications feel more responsive even if they take a few seconds to start. A splash screen could come as a separate window or like UWP as a start screen in the window itself.
Describe alternatives you’ve considered
Because I expect the vast majority of my applications users to use it on Windows, I implemented a splash screen with Windows Forms. I launch the splash screen on another thread and can close it again in Avalonia’s Window.Opened
event. In order to move the focus from the splash screen to the Avalonia window I have to use SetForegroundWindow
from User32.dll
because Window.Activate()
and Window.Focus()
don’t work when another thread has the focus.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
You may also take a look at CoreRT to build native binaries and get fast startup time: https://github.com/AvaloniaUI/Avalonia/issues/1476 Although it’s experimental and some features might not work (i.e. native file picker).
Thanks for the quick help, I will try/investigate it.