Skip to content

Reduce Multi-Pass Text Sizing #148

Open
@garrettmoon

Description

@garrettmoon

From @Adlai-Holler on October 19, 2016 1:55

Text nodes often perform multiple string measurements per layout pass. After each measurement, the text node takes on the resulting size as its constrained size. I believe this is to ensure that the custom truncation is up-to-date for the final size that the node received.

This is extremely costly, so we should avoid it if possible. It may be required sometimes in the current slow-path but I don't believe it will ever be required in the fast path from #2392, since the string that we're measuring doesn't change (no custom truncation or scaling).

The first thing to do is to determine what conditions cause multiple measurements. We should first create a unit test that adds a text node into a hierarchy and asserts that calculateSizeThatFits: is only called once. I would be open to adding https://github.com/rbaumbach/Swizzlean into our Podfile for the unit tests, to make it easy to count the number of invocations.

Copied from original issue: facebookarchive/AsyncDisplayKit#2423

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions