WASM performance is disappointing, what am I doing wrong? #18253
-
I've created a new "Avalonia Cross Platform Application (AvaloniaUI)" added ... I was disappointed: 5 seconds to load, 10 seconds of freezing during scroll down and then another 2 when scrolling up ... So what's wrong? Debug/Release doesn't seems to matter. I've tried to fiddle with Why Avalonia is so slow on web platform? ReproModify MainViewModel.cs: public class MainViewModel : ViewModelBase
{
public record Item(string Name, string Text);
public AvaloniaList<Item> Items { get; } = [];
public MainViewModel()
{
for (int i = 0; i < 100; i++)
Items.Add(new(i.ToString(), i.ToString()));
}
} Add in MainView.axaml: <ListBox ItemsSource="{Binding Items}"/> Versions:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Debug mode uses Mono interpreter. Since Avalonia does it's own layout, rendering and other stuff, that's rather taxing on the perf. Use AOT-published build for performance measurement. |
Beta Was this translation helpful? Give feedback.
-
I cannot use aot due to me using a lot of reflection but I looked into how the solitaire example runs so well with multithreaded. The solitaire example does not use aot either. And I'm not sure if this would even help with your issue. I found this to be something you may want to consider. If not, then just ignore my message. <ControlTheme x:Key="{x:Type BrowserThreads}" TargetType="BrowserThreads">
<Setter Property="Template">
<ControlTemplate>
<Border x:Name="PART_OuterBorder">
<ContentPresenter x:Name="PART_ContentPresenter"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</Border>
</ControlTemplate>
</Setter>
<ControlTheme.Animations>
<Animation Duration="0:1:0" IterationCount="Infinite" PlaybackDirection="Alternate">
<KeyFrame Cue="0%">
<Setter Property="BorderBrush" Value="Transparent" />
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="BorderBrush" Value="Transparent" />
</KeyFrame>
</Animation>
</ControlTheme.Animations>
</ControlTheme> /// <summary>
/// Just a hack to allow the browser to animate correctly?
/// </summary>
public class BrowserThreads : CornerstoneContentControl
{
} Then add this to your "mainview.xaml". <BrowserThreads /> I do not know why but this makes my browser app run butter smooth even with multithreading turned on. |
Beta Was this translation helpful? Give feedback.
Debug mode uses Mono interpreter. Since Avalonia does it's own layout, rendering and other stuff, that's rather taxing on the perf. Use AOT-published build for performance measurement.