Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve startup performance #5242

Closed
daniel-lerch opened this issue Jan 1, 2021 · 5 comments
Closed

Improve startup performance #5242

daniel-lerch opened this issue Jan 1, 2021 · 5 comments

Comments

@daniel-lerch
Copy link
Contributor

Is 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

  1. Make the startup process more efficient.
  2. 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.

@maxkatz6
Copy link
Member

maxkatz6 commented Jan 1, 2021

You may also take a look at CoreRT to build native binaries and get fast startup time:
#1476
Although it's experimental and some features might not work (i.e. native file picker).

@stax76
Copy link

stax76 commented Jan 26, 2023

I measured 1 second startup using a i5-8400 CPU and fast SSD drive, for most types of apps, that's fine, but some types of apps need to start faster, like a text editor or video player.

I want to port my mpv.net video player project to Linux and macOS, currently it uses WinForms in the main dialog and WPF in all other dialogs, it starts fast. There are users that start a video player dozens of times per day, so it has to start fast.

@maxkatz6
Copy link
Member

This problem was tracked in another issue - #5666
Startup time is greatly improved in the 11.0 previews and current master, so this issue can be closed.

@stax76 great to hear that you are interested in porting mpv.net!
Feel free to ask any questions about Avalonia.
For instance, recently we had merged lower-level API to allow users to integrate their directx/opengl/vulkan rendering code into the rendering pipeline of the Avalonia, which should be useful with media rendering. As an alternative to embedding native controls. See #9925 for details.

@maxkatz6
Copy link
Member

Also, Avalonia 11.0 previews now support NativeAOT, which also greatly improves startup time.
See https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/

@stax76
Copy link

stax76 commented Jan 26, 2023

Thanks for the quick help, I will try/investigate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants