Conversation
Contributor
|
Please add a test which covers this scenario. |
Contributor
Author
|
@javache thanks, I added the test |
…oves When a view flattens in the same commit in which its parent unflattens, a child with a negative zIndex is sorted before the view that contains it. The final loop of calculateShadowViewMutationsFlattener then took it for a new or removed view, because the nested recursion matched it through a different ShadowViewNodePair. Skip candidates the recursion recorded in the sub-visited map. Also stop keeping a pointer to a loop-local copy in unvisitedRecursiveChildPairs. Fixes react#58647 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pawicao
force-pushed
the
@pawicao/fix-differ-zindex-nested-flatten
branch
from
September 23, 2026 13:40
b41cf31 to
d4b9539
Compare
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.
Fixes #58647
Summary:
When a view flattens in the same commit in which its parent unflattens, and one of its children has a negative
zIndex, the differ creates that child again while it's still mounted, or deletes it even though it only moves.On iOS this crashes in
RCTComponentViewRegistry(Debug) or with a SIGSEGV inRCTMountingManager(Release). ThezIndexsorts the child before the view that contains it, and the nested recursion then matches it through a differentShadowViewNodePair, soinOtherTree()stayed false on the candidate.I made the final create/delete loop in
calculateShadowViewMutationsFlatteneralso skip candidates whose tag the recursion recorded in the sub-visited map. I also fixedunvisitedRecursiveChildPairsstoring a pointer to a loop-local copy.Changelog:
[GENERAL] [FIXED] - Fix the differ creating a mounted view again, or deleting a moved view, when a child with a negative
zIndexmoves in a nested flatten/unflattenTest Plan:
The reproducer from #58647 no longer crashes on iOS with React Native built from source with this change; without it, it crashes on the first swap.