Skip to content

Fix Fabric reusing nodes with a stale font scale (#57246)#57246

Open
j-piasecki wants to merge 1 commit into
react:mainfrom
j-piasecki:@jpiasecki/dirty-yoga-cache-on-font-scale-change
Open

Fix Fabric reusing nodes with a stale font scale (#57246)#57246
j-piasecki wants to merge 1 commit into
react:mainfrom
j-piasecki:@jpiasecki/dirty-yoga-cache-on-font-scale-change

Conversation

@j-piasecki

@j-piasecki j-piasecki commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary:
Fixes #52895

The original solution to this issue approached this by comparing the font scale used to lay out respective root nodes and re-cloning measurable nodes in the entire tree when it was different. This didn't work when a node within the tree was cloned from a node with an obsolete font scale stored (with root having the correct one). The new node would use the obsolete value in that pass.

This PR changes this approach - instead of comparing font scale in SurfaceHandler::constraintLayout (only when it changes), it moves the comparison to happen as part of configureYogaTree, similarly to pointScaleFactor. This way, nodes with an obsolete value stored get re-cloned using the correct one on each commit instead of only on the first one.

Changelog:

[GENERAL][FIXED] - Fixed Fabric reusing nodes with a stale font scale

Test Plan:
Issue reproducer

Before After
Android
Screen.Recording.2026-06-10.at.11.18.28.mov
Screen.Recording.2026-06-10.at.11.15.46.mov
iOS
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-06-10.at.11.19.05.mov
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-06-10.at.11.16.37.mov

Differential Revision: D108877387

Pulled By: j-piasecki

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 17, 2026
@facebook-github-tools facebook-github-tools Bot added p: Software Mansion Partner: Software Mansion Partner p: Facebook Partner: Facebook labels Jun 17, 2026
@meta-codesync

meta-codesync Bot commented Jun 17, 2026

Copy link
Copy Markdown

@j-piasecki has imported this pull request. If you are a Meta employee, you can view this in D108877387.

Summary:
Fixes react#52895

The original solution to this issue approached this by comparing the font scale used to lay out respective root nodes and re-cloning measurable nodes in the entire tree when it was different. This didn't work when a node within the tree was cloned from a node with an obsolete font scale stored (with root having the correct one). The new node would use the obsolete value in that pass.

This PR changes this approach - instead of comparing font scale in `SurfaceHandler::constraintLayout` (only when it changes), it moves the comparison to happen as part of `configureYogaTree`, similarly to `pointScaleFactor`. This way, nodes with an obsolete value stored get re-cloned using the correct one on each commit instead of only on the first one.

## Changelog:

[GENERAL][FIXED] - Fixed Fabric reusing nodes with a stale font scale


Test Plan:
Issue reproducer

||Before|After|
|-|-|-|
|Android|<video src="https://github.com/user-attachments/assets/0b30ca95-76e9-4ce9-8d8f-418f9d827bea" />|<video src="https://github.com/user-attachments/assets/009be13c-c3b5-4af0-8be1-b44c94ac0496" />|
|iOS|<video src="https://github.com/user-attachments/assets/b861b622-a2ea-4cc4-a8db-0e3ad4cae5e7" />|<video src="https://github.com/user-attachments/assets/ec4d6f6e-7558-4430-813b-61a6e911c3b0" />|

Differential Revision: D108877387

Pulled By: j-piasecki
@meta-codesync meta-codesync Bot changed the title Fix Fabric reusing nodes with a stale font scale Fix Fabric reusing nodes with a stale font scale (#57246) Jun 17, 2026
@j-piasecki j-piasecki force-pushed the @jpiasecki/dirty-yoga-cache-on-font-scale-change branch from 2454c01 to bcabdf3 Compare June 17, 2026 12:53
@meta-codesync

meta-codesync Bot commented Jun 17, 2026

Copy link
Copy Markdown

@j-piasecki has exported this pull request. If you are a Meta employee, you can view the originating Diff in D108877387.


if (child.yogaTreeHasBeenConfigured_ &&
childLayoutMetrics.pointScaleFactor == pointScaleFactor &&
childLayoutMetrics.fontSizeMultiplier == fontSizeMultiplier &&

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the floatEquality test here as well - just for consistency?

Suggested change
childLayoutMetrics.fontSizeMultiplier == fontSizeMultiplier &&
floatEquality(childLayoutMetrics.fontSizeMultiplier == fontSizeMultiplier) &&

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported p: Facebook Partner: Facebook p: Software Mansion Partner: Software Mansion Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[New Arch][Android] The text gets cut off when the system font size/weight is increased

2 participants