-
Describe the bugIn my application there's the window with a side menu and a main content page. This main content page loads various UserControls using a ContentControl. Currently this content control loads a specific user control when the application first loads, but when I click on a button to change to another user control the application freezes for about half a second and then shows me desired user control. When I then try to change user controls again they load fine, it only happens the first time. I've tried to instantiate all user controls on startup so they don't have to be created on demand but it doesn't seem to make a difference. I wonder how can I fix this performance issue to enhance my application user experience. Here are some code snippets from the project I am currently developing: Main Window:
The UserControl that's lagging:
User Control View Model:
To ReproduceSimply create a project 3 views:
Then make Content Control load User Control 1 on startup. When you go and change to User Control 2 the application will freeze for ~half a second. Expected behaviorI expected the User Control to load seamlessly on the first time as it was already instantiated at startup, both the view and the viewmodel. Avalonia version11.2.1 OSLinux Additional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You should use a stopwatch to measure what takes time to load. Probably your Data is heavy. Or you use StackPanels where you should not use them. DataGrid needs limited size to work best. In any case I don't see how this is an Avalonia bug. |
Beta Was this translation helpful? Give feedback.
-
It's likely a JIT time needed to process your code and compile for the current machine. |
Beta Was this translation helpful? Give feedback.
It's likely a JIT time needed to process your code and compile for the current machine.
Look into R2R and AOT compilation options.