Repository navigation
Conversation
Two Fabric paragraphs with the same source text can reuse a measurement even when they lay out differently. On iOS, an uppercase paragraph can reuse the lowercase paragraph's width and clip. On Android, `onTextLayout` can report the lowercase line while the view draws uppercase text. Compare `textTransform`, `baseWritingDirection`, `lineBreakStrategy`, `lineBreakMode`, `layoutDirection`, and `textEffects` in both cache keys. These attributes can change the measured size, line frames, line text, or inline attachment positions. Keys that differ only in these fields share a hash and compare unequal, so each measurement gets a separate entry. The oldest omission dates to the original size cache in 0.62. The line cache reused the same comparison when it shipped in 0.76. Passed the Fantom ReactCommon text layout tests and manual RNTester checks on iOS 27.0 and Android 16. Each row of the table-driven regression fails for both keys when its comparison is removed. The benchmark measures equality for one- and four-fragment keys on Apple silicon.
Text measurement keys can compare equal and hash differently when their float values are close. On libc++, neighboring font sizes occupy separate entries even though the keys compare equal. An infinite font limit also prevents the LRU from erasing the corresponding map entry because the key does not compare equal to itself. Compare key floats exactly and canonicalize NaN hashes, including the coordinates of a present shadow offset. Keep the existing attribute comparisons for renderer updates. Compare lineBreakMode in the prepared key because its display hash includes that field. The Fantom text layout and attributed string suites cover adjacent floats, unset values, an infinite font limit, prepared shadow offsets and line break modes. The Android text unit tests pass.
ide
marked this pull request as ready for review
December 2, 2026 12:20
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #60457; review the last commit.
Summary:
The Fabric text keys compare font sizes, paragraph font limits and pixel scales within an epsilon. The hash uses the original values. With libc++, neighboring values can compare equal and still occupy separate entries. An infinite font limit also exposes an eviction failure. The key compares unequal to itself, so the LRU drops its list entry while the map retains it.
Use exact comparison for cache floats and canonicalize their NaN hashes. Prepared keys also handle NaN shadow offsets accepted by Fabric. Exact comparison keeps neighboring finite inputs distinct and makes an infinite limit reusable. Quantizing would merge distinct inputs, which can fall on opposite sides of a measurement boundary. Dropping floats from the hash would leave the epsilon comparison nontransitive. Prepared keys also compare
lineBreakMode, which their hash already includes.Changelog:
[INTERNAL] [FIXED] - Make Fabric text measurement cache equality agree with hashing.
Test Plan:
The regression tests detect restoring epsilon equality, hashing raw NaNs, using raw shadow coordinates and omitting
lineBreakModefrom prepared equality. The C++ probe records the values returned by the cache and the number of entries erased on eviction.Apple Clang
-O3, Apple M6. Median retired instructions per full key comparison or hash, over five warmed repetitions. The comparison uses two equal copies of each key on the #60457 parent and on this branch. The size and line keys use the shared Fantom C++ types.The repository's
TextAttributesHashBenchmark.cppfixtures retired 171.03–249.04 instructions per layout hash before and 189.49–265.06 after. Display hashes retired 324.05–495.07 before and 354.66–543.50 after.