Skip to content

Don't clone zeroed out display: none subtrees on every layout pass (#2055) - #59777

Merged
cipolleschi merged 1 commit into
react:mainfrom
javache:export-D129010903
Nov 3, 2026
Merged

cipolleschi merged 1 commit into
react:mainfrom
javache:export-D129010903

Conversation

@javache

@javache javache commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary:
zeroOutLayoutRecursively runs for every display: none child on every
layout pass of its parent, and called cloneChildrenIfNeeded() at every
level of the hidden subtree. When the subtree is shared with an earlier
tree, the clone callback fired for every hidden node on every pass, even
though zeroing it out again changed nothing. In React Native each of
those callbacks is a ShadowNode clone.

Skip cloning and recursing into children whose subtree is already zeroed
out. configVersion is ignored in that check: it only validates the
layout cache, which is empty after zeroing out, and embedders such as
React Native set it again when they give a cloned node its config.

Reviewed By: javache

Differential Revision: D129010903

…eact#2055)

Summary:
zeroOutLayoutRecursively runs for every display: none child on every
layout pass of its parent, and called cloneChildrenIfNeeded() at every
level of the hidden subtree. When the subtree is shared with an earlier
tree, the clone callback fired for every hidden node on every pass, even
though zeroing it out again changed nothing. In React Native each of
those callbacks is a ShadowNode clone.

Skip cloning and recursing into children whose subtree is already zeroed
out. configVersion is ignored in that check: it only validates the
layout cache, which is empty after zeroing out, and embedders such as
React Native set it again when they give a cloned node its config.

Reviewed By: javache

Differential Revision: D129010903
@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 Nov 3, 2026
@meta-codesync

meta-codesync Bot commented Nov 3, 2026

Copy link
Copy Markdown

@javache has exported this pull request. If you are a Meta employee, you can view the originating Diff in D129010903.

@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Nov 3, 2026
@cipolleschi
cipolleschi enabled auto-merge (squash) November 3, 2026 11:33
@cipolleschi
cipolleschi merged commit daf96d4 into react:main Nov 3, 2026
100 of 101 checks passed
@javache
javache deleted the export-D129010903 branch November 3, 2026 21:19
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 Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants