Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call reactSetFrame on affected layouts bottom-up #41608

Closed
wants to merge 1 commit into from

Conversation

NickGerleman
Copy link
Contributor

Summary:
Fixes #41545

RN lays out the descendants of a root view using Yoga, then recurses to make a list of ShadowNodes which have new layout updates.

iOS Paper uses that list directly for ordering of calling reactSetFrame which informs UIViews of their dimensions.

As part of aligning Paper to Fabric's model of top-down onLayout events, 3168055 changed the ordering of the list from being pseudo-random, to always top-down.

After the change, we can deterministically see a case of infinite recursion where:

  1. We set the frame of the rootview
  2. This triggers safeAreaInsetsDidChange of RCTSafeAreaView, which doesn't have a frame yet
  3. RCTSafeAreaView triggers sync relayout of root view

Assigning frames bottom up (and is also what Android Paper does) ensures we lay out the RootView last, which avoids the issue, while keeping a deterministic order.

Changelog:
[iOS][Fixed] - Call reactSetFrame on affected layouts bottom-up

Differential Revision: D51534209

Summary:
Fixes facebook#41545

RN lays out the descendants of a root view using Yoga, then recurses to make a list of ShadowNodes which have new layout updates.

iOS Paper uses that list directly for ordering of calling `reactSetFrame` which informs UIViews of their dimensions.

As part of aligning Paper to Fabric's model of top-down onLayout events, facebook@3168055 changed the ordering of the list from being pseudo-random, to always top-down.

After the change, we can deterministically see a case of infinite recursion where:
1. We set the frame of the rootview
2. This triggers `safeAreaInsetsDidChange` of `RCTSafeAreaView`, which doesn't have a frame yet
3. `RCTSafeAreaView` triggers sync relayout of root view

Assigning frames bottom up (and is also what Android Paper does) ensures we lay out the RootView last, which avoids the issue, while keeping a deterministic order.

Changelog:
[iOS][Fixed] - Call `reactSetFrame` on affected layouts bottom-up

Differential Revision: D51534209
@facebook-github-bot facebook-github-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 Nov 22, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D51534209

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. fb-exported p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.73.rc iOS oldarch - infinite recursion with -[RCTUIManager setNeedsLayout]
2 participants