Skip to content

[fabric] Fixed updating font size after system change - #53767

Closed
chrfalch wants to merge 1 commit into
mainfrom
chrfalch/fix-system-font-size-change
Closed

chrfalch wants to merge 1 commit into
mainfrom
chrfalch/fix-system-font-size-change

Conversation

@chrfalch

@chrfalch chrfalch commented Sep 14, 2025 •

Copy link
Copy Markdown
Collaborator

Summary:

When updating accessibility text size there is an issue in the current code that would cut the tree enumeration and not update all the shadownodes in the tree - causing the layout in parent elements (of the text element) to not update its layout.

This commit fixes this by simplifying the code a lot - we don't need any optimizations here - we can update the whole tree each time the system font size is changed.

Tested in RN Tester and Expo Go (with the enableFontScaleChangesUpdatingLayout feature flag enabled)

Closes #53286

Changelog:

[IOS] [FIXED] - Fixed updating layout in Fabric when the system text multiplier is updated

Test Plan:

Reproduce the error on iOS:

Failing.on.iOS.mp4

Expected output (output after this fix)

Fixed.on.iOS.mp4

When updating accessibility text size there is an issue in the current code that would cut the tree enumeration and not update all the shadownodes in the tree - causing the layout in parent elements (of the text element) to not update its layout.

This commit fixes this by simplifying the code a lot - we don't need any optimizations here - we can update the whole tree each time the system font size is changed.

Tested in RN Tester and Expo Go (with the `enableFontScaleChangesUpdatingLayout` feature flag enabled)
@chrfalch
chrfalch requested a review from j-piasecki September 14, 2025 16:24
@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 Sep 14, 2025
@facebook-github-bot facebook-github-bot added p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Sep 14, 2025
@chrfalch
chrfalch requested a review from cortinico September 14, 2025 16:26
void SurfaceHandler::dirtyMeasurableNodes(std::shared_ptr<const ShadowNode> node) const {
if (auto* layoutableNode = dynamic_cast<const YogaLayoutableShadowNode*>(node.get())) {
// Only cast away const where needed
const_cast<YogaLayoutableShadowNode*>(layoutableNode)->dirtyLayout();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if it's safe to dirty a potentially sealed node.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think this was what was done previously as well? I couldn't find a place where we checked for sealed or not in the previous code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Previously, the node was cloned before marking it as dirty - the new node is always unsealed.

You also can't really check if a node is sealed or not, since that information is preserved only in debug builds.

if (!nodeHasChildren && !isMeasurableYogaNode) {
return nullptr;
void SurfaceHandler::dirtyMeasurableNodes(std::shared_ptr<const ShadowNode> node) const {
if (auto* layoutableNode = dynamic_cast<const YogaLayoutableShadowNode*>(node.get())) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We might check the traits before trying the dynamic cast - I believe this would be faster than trying to call dynamic_cast if we'd like to optimize this further (I left optimization out since this is a thing that doesn't happen that often)

return nullptr;
void SurfaceHandler::dirtyMeasurableNodes(std::shared_ptr<const ShadowNode> node) const {
if (auto* layoutableNode = dynamic_cast<const YogaLayoutableShadowNode*>(node.get())) {
// Only cast away const where needed

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll remove this comment, it is not valid.

@chrfalch

chrfalch commented Nov 4, 2025

Copy link
Copy Markdown
Collaborator Author

This fix was wrong - started to mutate the shadow tree in the completely wrong way.

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. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text rendering cut off on Android 15 & 16 in both old and new architecture

3 participants