Open Larhei opened 3 weeks ago
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!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
Tested also without Hotreload and in Release. Applying Border like in first similar issue did not solve the issue :-(
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.
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
@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.
Changing to Grid did not do the trick
Memory still over 300mb
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.
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.
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
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