question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DataGrid with Fluent theme and lots of columns is 10x slower removing from view

See original GitHub issue

Describe the bug

When the Fluent theme is used, a DataGrid with lots of columns (20+) is very slow when removed from the UI. (about 20x slower than adding) Using the base Light theme is about 70x faster when removing the control.

To Reproduce

  1. Clone https://github.com/garyhertel/AvaloniaDataGridPerfTest.git
  2. Start App
  3. Click “Toggle” button to toggle DataGrid on and off
  4. Look at the Debug output for times
  5. You can switch the theme in the App.xaml

A few notes:

  • Hardcoding or resizing the MainWindow Width cuts the performance hit by 10x, but this is still significantly slower than the base theme. My app also relies on the DataGrid autosizing itself so I’m not sure this can be permanently hard coded.
  • I’m using a widescreen monitor so the default window width is ~2800 pixels

Expected behavior

Using the Fluent theme and lots of DataGrid columns, the DataGrid removal should match the performance of the base light theme.

Alternatively, some workaround to speed up removal would help. (although other people will probably run into this problem too)

Screenshots

image

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Version: Avalonia 0.10.15

Additional context

Timings for the sample app using using different themes:

Width=2864

Light Theme, resized and half of columns showing

DataGrid added, [time = 52ms ]
DataGrid removed, [time = 56ms ]

DataGrid added, [time = 0ms ]
DataGrid removed, [time = 40ms ]

DataGrid added, [time = 0ms ]
DataGrid removed, [time = 71ms ]

Light Theme, all columns showing

DataGrid added, [time = 57ms ]
DataGrid removed, [time = 152ms ]

DataGrid added, [time = 0ms ]
DataGrid removed, [time = 137ms ]

DataGrid added, [time = 0ms ]
DataGrid removed, [time = 134ms ]

Fluent Light, resized and half of columns showing

DataGrid added, [time = 58ms ]
DataGrid removed, [time = 669ms ]

DataGrid added, [time = 0ms ]
DataGrid removed, [time = 662ms ]

DataGrid added, [time = 0ms ]
DataGrid removed, [time = 661ms ]

Fluent Light, all columns showing

DataGrid added, [time = 57ms ]
DataGrid removed, [time = 9876ms ]

DataGrid added, [time = 0ms ]
DataGrid removed, [time = 9788ms ]

DataGrid added, [time = 0ms ]
DataGrid removed, [time = 9789ms ]

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
grokyscommented, Jul 2, 2022

Seems that the reason the above method is showing up so prominently in profiling is that the Window.DottedLineFocusAdorner :is(Control) style is adding thousands of handlers to Classes.CollectionChanged:

image

There are nearly 8000 class listeners being added to the window’s Classes collection:

image

0reactions
garyhertelcommented, Jul 3, 2022

Thanks for all the quick fixes everyone! This was the biggest blocker for the Fluent upgrade, so hopefully I can get that updated soon!

Read more comments on GitHub >

github_iconTop Results From Across the Web

WPF DataGrid is very slow to render
I have a Surface Pro 3 on which my datagrid, with about 200 rows and 10 columns, was really slow at scrolling, jerky...
Read more >
Telerik WPF DataGrid - Deep Dive
Dive deep into the key features of Telerik's WPF DataGrid and learn how to load data, optimize performance, style and customize the control....
Read more >
Sizing Options in the DataGrid Control - WPF .NET ...
In this article. Sizing the DataGrid; Sizing Rows and Row Headers; Sizing Columns and Column Headers; See also. Various options are available to ......
Read more >
Re: Datagrid component performance slow
I set my datagrid.dataProvider to the DataProvider object. There are 13 columns, and approximately 40 rows. Scrolling the datagrid, and resizing columns has ......
Read more >
What's New in v19.2 | DevExpress
The new Badge API allows you to display badges over any control or UI element, be it a data grid column or Toolbar/Ribbon...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found