Files
react-native/packages
Samuel Susla 93ce46113c Combine iOS and Android optimisations (#37317)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37317

changelog: [internal]

This diff does three things:
1. Combines Android's mobile config `react_fabric:enable_text_measure_cache` with iOS mobile config `react_fabric:enable_nstextstorage_caching`. We will get into why later.
2. Fixes cache `ParagraphLayoutManager::cachedTextMeasurement_` invalidation logic for iOS and Android.
3. Fixes cache invalidation logic for `ParagraphLayoutManager::hostTextStorage_`.

Initially, Android's text measure cache (D44221170) and iOS's NSTextStorage (D43692171) were design as two separate optimisations. But they overlap and NSTextStorage actually needs some parts of text measure cache to work correctly. That's why I decided to merge them together.

Previously, `ParagraphLayoutManager::cachedTextMeasurement_` was only invalidated if maximum width for the node changed. But node can change in different ways, for example input string changes or attributes change. This diff accounts for that by computing a hash for AttributedString+ParagraphAttributes to check if anything has changed.

Previously, `ParagraphLayoutManager::hostTextStorage_` was not correctly invalidated if maximum width changed. To my surprise, this happens less frequently than one expects.

bypass-github-export-checks

Reviewed By: mdvacca

Differential Revision: D45637797

fbshipit-source-id: 1840b51cdb1423de0560a35fd17c24a71ad115e1
2023-05-09 15:25:38 -07:00
..