Skip to content
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

[Windows] UI Virtualization broken in Listviews #24343

Open
Larhei opened this issue Aug 20, 2024 · 8 comments
Open

[Windows] UI Virtualization broken in Listviews #24343

Larhei opened this issue Aug 20, 2024 · 8 comments
Labels
area-controls-listview ListView and TableView platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@Larhei
Copy link

Larhei commented Aug 20, 2024

Description

I´m not an expert on this topic but from my experience in other xaml stacks this is looking fishy to me.

When using a ListView or Collectionview on Windows bound to a collection of 1000 items i observe the folowing.
When scrolling this itemscollections fast i end up with 3000+ instances of a contentview used in the Datatemplate.
In addition to 300+ instances of Microsoft.UI.Xaml.Controls.ListViewItem on the native side of things.
Beside the fact that the Cachelength of the ItemsStackpanel is 4 and my ViewportHeight is 500 and each Item has a Height of 100.
There should be round about 8 Instances of ListViewItem from my understanding and maybe also less instances of my Datatemplate on the Maui Side. Over 500 MB for an App only showing two Lists with an empty View just looks wrong to me.

Steps to Reproduce

  1. Check out Sample on WIndows.
  2. Run Sample on Windows.
  3. Scroll the Listview a view times up and down. Watch the output while scrolling.
  4. Scroll the Collectionview up and down. Watch the output while scrolling.
  5. Take a few Snapshots in order to kick GC
  6. Compare Baseline to Last Snapshot

Link to public reproduction project repository

https://github.com/Larhei/Maui-Issues/tree/main/ListVirtualisation

Version with bug

8.0.80 SR8

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

windows10.0.19041

Did you find any workaround?

Nope

Relevant log output

None
@Larhei Larhei added the t/bug Something isn't working label Aug 20, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@Larhei
Copy link
Author

Larhei commented Aug 20, 2024

Tested also without Hotreload and in Release.
Applying Border like in first similar issue did not solve the issue :-(

@MitchBomcanhao
Copy link

are you putting your listview inside a stack layout? somehow I recall reading somewhere that you shouldn't do that because it'd not contain the list controls and would force the listview to initialise everything, resulting in what you're complaining about.
use a grid instead of a stack layout.

@MitchBomcanhao
Copy link

MitchBomcanhao commented Aug 21, 2024

asked copilot:

Yes, placing a ListView inside a StackLayout in Xamarin.Forms can indeed break virtualization.
This is because the StackLayout measures its children with an infinite height, causing the ListView 
to load all its items at once instead of virtualizing them. 
This can lead to performance issues, especially with large data sets.

To maintain virtualization, you can use a Grid or AbsoluteLayout instead of a StackLayout

@Larhei
Copy link
Author

Larhei commented Aug 21, 2024

@MitchBomcanhao
Well i specify a Height to my ListViews and Collectionview. So the native side should know my the viewport height... But I will change my layout and see what i come up with.

@Larhei
Copy link
Author

Larhei commented Aug 21, 2024

Changing to Grid did not do the trick
image
image
image

Memory still over 300mb

@MitchBomcanhao
Copy link

MitchBomcanhao commented Aug 21, 2024

yes, when taking snapshots I also see the number of objects increasing when using a grid.
oddly enough, when adding Border around my control (which was just a label), it made the presentation noticeably slower, with viewcells taking much longer to draw.

@kevinxufei kevinxufei added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Aug 22, 2024
@kevinxufei
Copy link

This issue has been verified using Visual Studio 17.12 Preview 1 (8.0.80 & 8.0.72). Can repro on windows platform with sample project.

@samhouts samhouts added the area-controls-listview ListView and TableView label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-listview ListView and TableView platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants