Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid duplicate measurements for children #46

Closed
thagikura opened this issue May 24, 2016 · 3 comments · Fixed by #514
Closed

Avoid duplicate measurements for children #46

thagikura opened this issue May 24, 2016 · 3 comments · Fixed by #514

Comments

@thagikura
Copy link
Contributor

thagikura commented May 24, 2016

In the onMeasure method, child.measure may be called more than once (e.g. Called first in the first loop to determine the number of flex lines, then called later to be expanded/shrank based on flexGrow/flexShrink attributes also maybe called to be stretched based on alignItems/alignSelf attributes).

This may cause performance issue especially the child is a nested ViewGroup.
It will be efficient to defer the child.measure as much as possible to reduce the number of measurements of the same child.

@jiasonwang
Copy link

Flexbox nested flexbox will cause performance degradation,too much measure

@aitorvs
Copy link

aitorvs commented Sep 25, 2019

Do you have any updates on this issue?

thagikura added a commit that referenced this issue Oct 24, 2019
This PR prevents the number of measure calls for the children of the
Flexbox.
If any items in a FlexLine don't have the flexGrow or flexShrink
attributes set, the children in the FlexLine don't have to be measured
in the FlexboxHelper#determineMainSize method.

Similarly, if the AlignItems attribute for the Flexbox is not equal to
AlignItems.STRETCH nor any items in a FlexLine don't have the
AlignSelf.STRETCH attributes, the items in the FlexLine don't have to be
measured in the FlexboxHelpers#stretchViews method.

Also this PR changes the default values of FlexboxLayout as follows:
- mAlignItems: STRETCH -> FLEX_START
- mAlignContent: STRETCH -> FLEX_START
thagikura added a commit that referenced this issue Oct 24, 2019
This PR prevents the number of measure calls for the children of the
Flexbox.
If any items in a FlexLine don't have the flexGrow or flexShrink
attributes set, the children in the FlexLine don't have to be measured
in the FlexboxHelper#determineMainSize method.

Similarly, if the AlignItems attribute for the Flexbox is not equal to
AlignItems.STRETCH nor any items in a FlexLine don't have the
AlignSelf.STRETCH attributes, the items in the FlexLine don't have to be
measured in the FlexboxHelpers#stretchViews method.

Also this PR changes the default values of FlexboxLayout as follows:
- mAlignItems: STRETCH -> FLEX_START
- mAlignContent: STRETCH -> FLEX_START
@thagikura
Copy link
Contributor Author

I think this can be now closed. #514 should remove the unnecessary measure calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants