maui
maui copied to clipboard
CollectionView in ios renders very slow when grouped.
Description
In IOS when the collection view is configured for grouping, updating the data in the collection is very slow. In the sample provided here the time to reload the collection in Android averages 0.0004 seconds, Windows averages 0.002 seconds and IOS averages 0.1 seconds. With so little data that seems ok, but in comparison IOS is 50 times slower than Windows and 250 times slower than Android. I my actual app (not this simple example) that difference makes IOS unusably slow. Reloading 100 items takes 8 seconds and gets longer with every refresh.
Steps to Reproduce
Link to public reproduction project repository
No response
Version with bug
8.0.61 SR6.1
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
ios 17.2
Did you find any workaround?
No
Relevant log output
No response
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:
- CollectionView with IsGrouped and GridItemsLayout performance issue with Images (#18881), similarity score: 0.75
- [iOS] Rendering of CollectionView takes too much time (#15204), similarity score: 0.75
- Grouped CollectionView content/items overlaps on iOS when data changes or when pull to refresh data (#20336), similarity score: 0.74
Closed similar issues:
- [Android] Performance issues with CollectionView using grouping and variable sizes (#22192), similarity score: 0.78
- [regression/8.0.0] Grouped CollectionView in NavigationPage on iOS recreates the grouped header view on every scroll event (#18421), similarity score: 0.74
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
@JPfahl can you upload your repro to a github account please?
I included a page in the attached zip that demonstrates the issue. My project is far too large and not open source so I can't share it.
@JPfahl Can you upload that page to a github repository? We can't work with zip files for security reasons.
@JPfahl I took the security risk on behalf of @PureWeen and your problem is you are breaking Virtualization of the page.
VerticalStackLayout and the contents in it don't have an intrinsic height (See this doc on changes between Forms and MAUI regarding StackLayout). Since your CollectionView is inside the VerticalStackLayout, and doesn't have a height, iOS/Catalyst is going to try and render the entire list and all of its contents. I believe that's also happening on Android too, but it, by happenstance is faster to render but it's going to use more memory when it doesn't need to.
A simple fix is to use a Grid instead. I changed your sample to use one. This loads thousands of items in your grouped list. Using your original code, it would take multiple seconds to load on iOS/Catalyst. With my change, it's instant.
https://github.com/drasticactions/MauiRepros/blob/main/GroupedTest/Sample.xaml
This does give CollectionView a height (Pinned to the bottom of the page) and that fixes Virtualization.
@PureWeen Does this sound correct?
I use a Grid for layout in my main application. I changed the sample I sent and it does not change the time used when the collection bound to the grid is changed causing a UI update. Sample.zip
This issue has been verified using Visual Studio 17.11.0 Preview 3.0(8.0.70 & 8.0.61). Can repro it. And using Grid for layout can reduces time.
https://github.com/drasticactions/MauiRepros/blob/main/GroupedTest/Sample.xaml
This is a critical issue for our application, the collectionview update is so slow it is unusable on ios. What is the timeline for this to be addressed?
Here are the two source files ( no zip) The issue is still a big problem even if the layout uses a grid.
We have done testing with DevExpress's CollectionView and it is hundreds (literally) of times faster rendering the list. You are clearly doing something very wrong.
This issue has been verified in Visual Studio Code 1.102.0 with MAUI version 9.0.100. It was reproduced on the iOS platform in both debug and release mode.
Debug mode:
| CV1 | CV2 |
|---|---|
Release mode:
| CV1 | CV2 |
|---|---|
@JPfahl I tested the attached sample with the latest NuGet (9.0.110). It did not take 100 milliseconds to load the three items; it currently takes around 30 milliseconds. Performance has improved in the latest NuGet.
As mentioned, I also tested with 100 items in each group, and with the latest NuGet it takes about 200 milliseconds in both CV1 and CV2, not more than 8 seconds as you mentioned. For reference, I have attached a video showing 100 items in release mode using CV2 on iOS 18.0.
https://github.com/user-attachments/assets/530df9c3-aa16-4adc-8b7e-a847e49010b4