Skip to content

Low performance on ListView, DataGrid with virtualization and massive data #154

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

Open
6 tasks done
AuthorZiXi opened this issue Feb 9, 2025 · 11 comments
Open
6 tasks done
Labels
package: base Taking place in the iNKORE.UI.WPF.Modern project priority: 1 status: help-wanted Extra attention is needed

Comments

@AuthorZiXi
Copy link

AuthorZiXi commented Feb 9, 2025

[Auto-translated]

Describe the bug

I'm sorry to submit another issue in a hurry, and disturb all contributors again. This problem was actually discovered around November of the previous year. (That is, it also existed before

Cause: A file manager that was previously attempted to implement (the progress is irrelevant to the topic, so there is no need to explain it in detail.

After using the style, ListView has a large performance gap, and the situation here may be more extreme (not to mention that there are 3902 ogg files

Fault cause investigation: As long as the style is used, the same phenomenon will occur when trying to virtualize and replace it with datagrid

Specific phenomenon: It causes long-term UI thread jams

Reproduction

When I used the native style, the loading was relatively fast, but after using the style, the performance problem was obvious.

The original recorded video was too large, so I found an online website to compress it

The video is long, if you don't want to watch it, you can try to reproduce it locally. (The video shows the performance difference between ListView without and with styles

freecompress-.2025-02-09.215512.mp4

This is the ListView of my program file view

<ListView x:Name="FolderView" Background="Transparent" d:ItemsSource="{d:SampleData ItemCount=20}" ItemsSource="{Binding FolderViewItems}" MouseRightButtonUp="FolderView_MouseRightButtonUp"  MouseDoubleClick="FolderView_MouseDoubleClick">
    <ListView.View>
        <GridView x:Name="gridView" AllowsColumnReorder="True">
            <GridViewColumn DisplayMemberBinding="{Binding Name,Mode=OneTime}" Header="名称"/>
            <GridViewColumn Width="120" DisplayMemberBinding="{Binding Size, Mode=OneTime}" Header="大小" />
            <GridViewColumn Width="120" DisplayMemberBinding="{Binding Type, Mode=OneTime}" Header="类型" />
            <GridViewColumn Width="120" DisplayMemberBinding="{Binding ModifyTime, Mode=OneTime}" Header="修改" />
        </GridView>
    </ListView.View>
    <ListView.GroupStyle>
        <GroupStyle>
            <GroupStyle.HeaderTemplate>
                <DataTemplate>
                    <TextBlock Style="{DynamicResource {x:Static ui:ThemeKeys.TitleTextBlockStyleKey}}" Text="{Binding Name, Mode=OneTime}" />
                </DataTemplate>
            </GroupStyle.HeaderTemplate>
        </GroupStyle>
    </ListView.GroupStyle>
</ListView>

Suggested Solution

I don't know how to solve it, but can you provide some directions for investigation: Directory query and data generation will not take a long time, and the UI thread occupation is likely related to control generation (or template).

Can the original virtualization function be restored or re-implemented? Maybe you can try to use other methods instead?

Library Version

1.2.8

Operating System

Windows 11

Framework

.NET Core and .NET

Framework Version

8.0

Source of Package

NuGet.org (Package)

Additional Notes

In addition, the holiday is about to end, and I don’t have much time to give a timely reply (academic issues.

I hope everyone understands!

Validations

  • Check that there isn't already an issue that reports the same or similar problem.
  • Check that this is a bug in the library that should be fixed, not a feature, also this is not about the documentation. (Or please choose the right repo and template.)
  • This is one single problem, or a few problems with the same cause. (If you want to report multiple problems, please create one issue for every single problem.)
  • You've checked that this problem still exists in the latest version. (Keep in mind that we don't provide any support for old versions.)
  • You know that we can't guarantee that we will satisfy your request. This is not really our duty to do everything anyone asks for. Also, you will treat our staff, contributors, and other users with respect and kindness.
  • You're sure there's something wrong with the library itself, not how you're using it. (If you are having issues using it and need help, please go to discussion.)
@AuthorZiXi AuthorZiXi added the status: needs-triage Waiting to be triaged by our memebers label Feb 9, 2025
@NotYoojun
Copy link
Member

虚拟化没办法正常使用么?

@NotYoojun NotYoojun added status: help-wanted Extra attention is needed status: question Further information is requested package: base Taking place in the iNKORE.UI.WPF.Modern project and removed status: needs-triage Waiting to be triaged by our memebers labels Feb 9, 2025
@AuthorZiXi
Copy link
Author

AuthorZiXi commented Feb 9, 2025

采用了也存在卡顿问题,不知道为什么没有效果(已修订句意

@NotYoojun
Copy link
Member

这种模糊又找不到具体原因的问题几乎是很难修的。

@tmdakm
Copy link

tmdakm commented Feb 17, 2025

我这里是在添加数据的时候会卡,后面滚动都不会卡,我用WPFUI或者原生WPF库加载同样的数据没有问题
分批添加可以解决(用户滚动应该没那么快,一次添加一百条延时一会再添加

@mou-haz
Copy link
Contributor

mou-haz commented Mar 9, 2025

(from the video description)
I had similar problem , and i managed to fix it by changing the default style to this:

`

<Grid.RowDefinitions>



</Grid.RowDefinitions>

<local:ScrollViewerEx
Focusable="false"
Grid.Row="1"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
Padding="{TemplateBinding Padding}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
chelper:ScrollViewerHelper.AutoHideScrollBars="{TemplateBinding chelper:ScrollViewerHelper.AutoHideScrollBars}">

                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

                        </local:ScrollViewerEx>
                        <ContentPresenter
                            Content="{TemplateBinding chelper:ListViewHelper.Footer}"
                            ContentTemplate="{TemplateBinding chelper:ListViewHelper.FooterTemplate}"
                            Grid.Row="2"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch" />
                    </Grid>
            </Border>`

basically removing grid from scrollviewer content,
as this seems to make the virtualization panel viewport measure the viewport with height of infinity and it keeps realizing all items.

@NotYoojun
Copy link
Member

NotYoojun commented Mar 10, 2025

(from the video description) I had similar problem , and i managed to fix it by changing the default style to this:

basically removing grid from scrollviewer content, as this seems to make the virtualization panel viewport measure the viewport with height of infinity and it keeps realizing all items.

This grid is actually used for some animating stuff, which seems necessary, however, I gues it's worth a try to replace it with a Border. Maybe a Grid will cause extra layout calculating, well, or something.

Could you guys pls try the code in the test branch: bbfbefe, and see if this is fixed?

@NotYoojun NotYoojun changed the title 需要提高ListView,DataGrid等批量数据控件性能 Low performance on ListView, DataGrid with virtualization and massive data Mar 10, 2025
@NotYoojun
Copy link
Member

@AuthorZiXi 感谢您对本项目的认可和贡献!麻烦以后提交的时候请不要说中文,哪怕用咕噜咕噜翻译成英语也行啊

@mou-haz
Copy link
Contributor

mou-haz commented Mar 10, 2025

This grid is actually used for some animating stuff, which seems necessary, however, I gues it's worth a try to replace it with a Border. Maybe a Grid will cause extra layout calculating, well, or something.

Could you guys pls try the code in the test branch: bbfbefe, and see if this is fixed?

I am really sorry my previous reply was messy,

I tried the fix in the the in the test branch: bbfbefe, but it didn't work as it is modifying the ListViewItem style.

What i was suggesting was regarding the grid in the BaseListViewStyle , here is a commit with my suggestion:
65d41a, (I don't remove the grid i just move the ScrollViewer to wrap the ItemsPresenter, but this have the side effect of making the header and footer fixed and only the content scrollable)

** Also, please note that this doesn't eliminate the problem as having layouts with inifinte size like scrollviewer or stackpanel as parent in the visualtree will also cause the problem , but this happens even with the default wpf ListView style.

Here is a minimal project with the defualt iUWM style and my suggestion: VirtualTest

@Yue-cn
Copy link

Yue-cn commented Mar 20, 2025

pls use virtualization in right away... and you can have a try SnoopWPF..
可以试试Snoop...

Image

@NotYoojun NotYoojun added priority: 1 and removed status: question Further information is requested labels Mar 23, 2025
@NotYoojun
Copy link
Member

Hi, please check if the branch https://github.com/iNKORE-NET/UI.WPF.Modern/tree/fix-154 fixes your problem.
@AuthorZiXi @mou-haz @tmdakm

@NotYoojun NotYoojun added status: question Further information is requested and removed status: help-wanted Extra attention is needed labels Mar 24, 2025
@mou-haz
Copy link
Contributor

mou-haz commented Mar 24, 2025

@NotYoojun didn't work for me.

@NotYoojun NotYoojun added status: help-wanted Extra attention is needed and removed status: question Further information is requested labels Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: base Taking place in the iNKORE.UI.WPF.Modern project priority: 1 status: help-wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants