FluentAvalonia icon indicating copy to clipboard operation
FluentAvalonia copied to clipboard

NavigationView makes ItemsRepeater extremely slow

Open Leon99 opened this issue 1 year ago • 2 comments

Describe the bug Even in a simple repro app loading and scrolling are visibly slow. In a more complex app can take from a few seconds to a minute+ to load/scroll, depending on the number of items.

Desktop/Platform (please complete the following information):

  • OS: 11
  • FluentAvalonia Version: 2.0
  • Avalonia Version: 11.0.2

Additional context Works fine if there's no NavigationView.

Debug output constantly shows something like

[Layout]Layout cycle detected. Item 'Avalonia.Controls.StackPanel' was enqueued '10' times.(LayoutQueue`1 #12819582)
[Layout]Layout cycle detected. Item 'Avalonia.Controls.TextBlock' was enqueued '10' times.(LayoutQueue`1 #12819582)
[Layout]Layout cycle detected. Item 'Avalonia.Controls.Presenters.ContentPresenter' was enqueued '10' times.(LayoutQueue`1 #12819582)

Leon99 avatar Aug 01 '23 09:08 Leon99

I'm not really sure what's happening here but I'm pretty sure this is something wrong with the Avalonia ItemsRepeater implementation. Specifically, something with its virtualization handling. I've been working on my own port of the ItemsRepeater that I plan to add here at some point soon (no time frame) and I can't repro this issue using my version. Unfortunately, I don't have the profiling tools to be able to dig deeper to figure out where the slow down occurs.

The layout cycle thing is something I've been seeing too since 11.0 (in my IR port and some other custom items stuff), so something got messed up in the layout system for 11.0 but I don't know much about the layout manager to know why there's a layout cycle occurring

A couple suggestions:

  • You could try increasing the VerticalCacheLength on the ItemsRepeater. It still stuttered a bit, but was a bit better - of course, this increases the number of realized items so there's less virtualization going on.
  • You could try using a regular ItemsControl with VirtualizingStackPanel which also does not exhibit this issue

amwx avatar Aug 06 '23 02:08 amwx

Many thanks for the investigation @amwx! VirtualizingStackPanel is a decent workaround for the time being.

Leon99 avatar Aug 06 '23 04:08 Leon99