Skip to content

Slow performance of auto dimensions #1785

@Hexlord

Description

@Hexlord

We found out that defining at least one of the dimensions to be 100%, instead of keeping them both auto, improves performance a lot. We were able to achieve 3x frame time improvement (12ms -> 4ms) by going through every style we have and setting width to 100% when it does not break the UI (it mostly never does for auto-auto cases).

It would be nice though if the algorithm would be able to detect these scenarios better (of when 100% width gives the same result as auto) and avoid the expensive auto dimension resolve recursion / whatever in the process costs so much.

For now we changed the default values for style's dimensions to be 100% width and 100% height, so the user explicitly sets it to auto, with the goal being preserving as much performance as possible.

Speaking without knowledge, perhaps the algorithm could try to select a dimension according to current flex direction, usually width, and see that if there is only one relative child with flexGrow > 0, it could treat its {auto, auto} dimensions as {100%, auto} instead, for less algorithmic complexity but hopefully guaranteed same result?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions