Skip to content

Trigger remeasure when constraints on CV changes#22270

Merged
PureWeen merged 6 commits into
mainfrom
fix_21967
May 9, 2024
Merged

Trigger remeasure when constraints on CV changes#22270
PureWeen merged 6 commits into
mainfrom
fix_21967

Conversation

@PureWeen
Copy link
Copy Markdown
Member

@PureWeen PureWeen commented May 7, 2024

Description of Change

When the constraints of a RecyclerView change, the items don't get recreated so we have to re-evaluate the cached sizes being used to measure each of the items. The way the code was setup it would only set the static size once and then reuse that no matter what the change are.

My current overall thinking here is that ItemSizingStrategy is somewhat pointless on android as it relates to performance. The only reason to use it would be if you want the first item to set the measure for the rest of your cells. Generally, if you want the best performance, and you want all the cells to be the same size, then just set a specific height/width on your cells.

For example, if you just remove all of our custom measuring code inside ItemContentView and just rely on the "LayoutParams" to size the elements it all measures naturally.

I think there are some additional issues related to messages getting propagated to the handlers
#22271

But we'll look at that as part of SR6

Issues Fixed

Fixes #21967

}

_reportMeasure?.Invoke(new Size(pixelWidth, pixelHeight));
_reportMeasure = null; // Make sure we only report back the measure once
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't really set this to null because if the constraints on the CV change we need to report a new measure.

@jsuarezruiz jsuarezruiz added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label May 7, 2024
@PureWeen PureWeen requested a review from rmarinho May 7, 2024 19:21
@jsuarezruiz jsuarezruiz added t/bug Something isn't working platform/android labels May 8, 2024
Copy link
Copy Markdown
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debugging, the output call my attention:
issue-21967-perf-II

Should not being in this loop without interact with the UI (like, scrolling etc). Taking a look to the HWUI rendering:
issue-21967-perf


button.Clicked += (_, _) =>
{
if (cv.WidthRequest == 200)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we update the sample to use the Page Width? In this way, we can validate with an UITest the UI rotating the device.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, that's caused by this unfortunately
#22271

@jsuarezruiz
Copy link
Copy Markdown
Contributor

Debugging, the output call my attention: issue-21967-perf-II issue-21967-perf-II

Should not being in this loop without interact with the UI (like, scrolling etc). Taking a look to the HWUI rendering: issue-21967-perf issue-21967-perf

Ok, have done more tests and can reproduce the same without the changes. So, we can create a new issue and review this problem in another PR.

@PureWeen PureWeen merged commit f76ea52 into main May 9, 2024
@PureWeen PureWeen deleted the fix_21967 branch May 9, 2024 14:13
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CollectionView causes invalid measurements on Android rotation

3 participants