Skip to content

Android-CollectionView - MeasureFIrstItem breaks layout #21778

Closed

Description

@Alex-111

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.

image

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 #7562

Activity

  1. added
    t/bug
    on Apr 11, 2024
  2. self-assigned this
    on Apr 11, 2024
  3. added this to the Backlog milestone on Apr 11, 2024
  4. added
    s/verified
    s/triaged
    on Apr 12, 2024
  5. XamlTest commented on Apr 12, 2024

    @XamlTest

    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

  6. added
    area-controls-collectionview
    on Apr 30, 2024
  7. markusroessler commented on May 15, 2024

    @markusroessler

    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 #22270 ?

  8. vecalion commented on May 20, 2024

    @vecalion

    Experiencing the same issue after updating to 8.0.40.

  9. removed
    s/verified
    s/triaged
    on Jul 3, 2024
  10. PeWu09 commented on Jul 9, 2024

    @PeWu09

    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.

    image

  11. added
    s/verified
    s/triaged
    on Jul 10, 2024
  12. bcaceiro commented on Oct 7, 2024

    @bcaceiro

    I am also facing this: using MeasureFirstItem, the layout does not render correctly - I can see, ind ebug, and with hotreload, that it appears and then disappears, so :

    • Excess of layout measures / passes and the last one is making the elements disappear / getting cut.
      Using dotnet maui v8.0.91
  13. Domik234 commented on Oct 17, 2024

    @Domik234

    I am also facing saming similar.

    CollectionView.ItemSizingStrategy: MeasureFirstItem

    Only on Android this happens:
    https://github.com/user-attachments/assets/8e018a00-744f-49ad-8e60-287ea2cce9da

    Basically first item is measured wrong and oversizes to second item. All items after the first are measured the same size. Interacting with the first one (pressing on it invokes BackgroundColor change) leads to remeasuring and correcting the position. So then they are all aligned correctly but all of them (first to last) have some additional space that should not be there.

    On iOS this works correctly and background color on pressing fills whole bounds of view.

  14. removed their assignment
    on Dec 12, 2024
  15. added
    s/try-latest-version
    on Dec 12, 2024
  16. dotnet-policy-service commented on Dec 12, 2024

    @dotnet-policy-service
    Contributor

    Hi @Alex-111. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

    You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

    This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

  17. locked and limited conversation to collaborators on Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-controls-collectionviewplatform/androids/triageds/try-latest-versions/verifiedt/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions