maui
maui copied to clipboard
Android-CollectionView - MeasureFIrstItem breaks layout
Description
If I use a collectionview on Android with ItemSizingStrategy="MeasureFirstItem" then the layout of the items does not work as expected - see Repro
Steps to Reproduce
Just start the repro. I use a grid with fixed columns (3*,1*). but the CollectionView items did not respect that layout.
Link to public reproduction project repository
https://github.com/Alex-111/ReproCollectionViewFirstItem
Version with bug
8.0.20 SR4
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Did you find any workaround?
use MeasureAllItems, but this has a big impact of performance!
Relevant log output
No response
Maybe it is related to https://github.com/dotnet/maui/issues/7562
Verified on VS 17.10.0 Preview 3.0(8.0.20). Repro on Android 14.0-API34, not repro on iOS 17.2 with below Project: ReproCollectionViewFirstItem.zip
I started to notice this bug after updating from 8.0.21 to 8.0.40. Elements within the ItemTemplate's Grid start to overlap and elements within a VerticalStackLayout don't use all available width when setting ItemSizingStrategy="MeasureFirstItem". @PureWeen is this caused by https://github.com/dotnet/maui/pull/22270 ?
Experiencing the same issue after updating to 8.0.40.
In our case, where an item template contains several labels and canvas (which means it is not completely trivial) scrolling performance on Android with MeasureAllItems is utterly not acceptable - laggy and scrolling tends to stop at random points. On the other hand, MeasureFirstItems greatly improves performance, but then the layout is corrupted - some elements are only partially rendered, some disappears, etc.
Not reproducible on iOS. Tested on both 8.0.61 SR6.1 and 9.0.0-preview.5.24307.10.
Just take a look at android trace for initial displaying of collectionview/scrolling (looks quite familiar for both scenario). When I see something like that I am a bit sceptical about the performance. Despite some ordinary setup, every single list item is measured and layouted sequentially. Yea, we all know the concept of UI thread, but then final effect is what matters.