Skip to content

Fix iOS Fabric unmount assertions for zero-sized recycled views - #59628

Open
theeket wants to merge 1 commit into
react:mainfrom
theeket:fix/ios-fabric-unmount-container-reconciliation
Open

theeket wants to merge 1 commit into
react:mainfrom
theeket:fix/ios-fabric-unmount-container-reconciliation

Conversation

@theeket

@theeket theeket commented Oct 29, 2026

Copy link
Copy Markdown

Summary:

Related to #59166. This change addresses the unmount comparison; it does not reset container state during recycling.

Unmounting a zero-sized recycled View can fail with Attempt to unmount a view which is mounted inside a different view, even when the exception reports the parent's own tag as the existing parent.

A previous owner can leave the native view with a clipping container, for example when using overflow: 'hidden' with an outline. Fabric can mount descendants before applying the recycled parent's new props. If those props no longer require the container and the view has zero bounds, layer invalidation returns without migrating the children back.

currentContainerView performs that migration lazily. The unmount assertion compares childComponentView.superview == self.currentContainerView, so evaluation can read the child's old superview before the getter moves it. By the time the exception message is formatted, the child can already belong to the expected parent.

Resolve the container in a separate statement before reading superview in the assertions. The reconciliation also runs when assertions are disabled. Existing ownership and index checks remain unchanged.

01

Changelog:

[IOS] [FIXED] - Reconcile recycled view containers before checking child ownership during Fabric unmount.

Test Plan:

Added native regression tests for:

  • A clipping-container owner being recycled, receiving a new child before its props update, and then being unmounted at zero size after the container is no longer required. The test checks that unmount does not assert, detaches the child, and removes the stale container.
  • A child that actually belongs to another parent still producing an ownership assertion.

The lifecycle sequence above is constructed directly with RCTViewComponentView; it is not an end-to-end JavaScript/Fabric reproduction. Its assertion behavior can depend on operand evaluation order before the fix.

The RCTViewComponentViewUnmountTests.mm passed.
Real application tested on react-native 0.88.1 with iOS 27.2 device, Xcode 27.1.

@meta-cla

meta-cla Bot commented Oct 29, 2026

Copy link
Copy Markdown

Hi @theeket!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@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 Oct 29, 2026
@meta-cla

meta-cla Bot commented Oct 29, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 29, 2026

This branch has not been deployed

No deployments
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. 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.

1 participant