Repository navigation
Fix iOS Fabric unmount crash when pointer hover shifts child indices - #59857
Open
lorenc-tomasz wants to merge 22 commits into
Open
lorenc-tomasz wants to merge 22 commits into
lorenc-tomasz wants to merge 22 commits into
Conversation
UIKit can insert native hover-effect views alongside Fabric children, shifting the subview indices used during mounting and unmounting. Track Fabric children separately and insert them relative to their predecessor. Use that same list when toggling clipping so UIKit-owned views are not tracked as Fabric children. Add six native regression tests and an RNTester cursor example. Update existing clipping expectations and the unmount assertion comment to match the new child tracking behavior. Changelog: [IOS] [FIXED] - Fix Fabric child mounting and unmounting around pointer hover effects. Test Plan: - 56 native tests passed, including all six regression tests; five of the six failed before the fix. The unrelated paragraph test file was excluded because of an existing ComponentBuilder linkage issue; local include-path overrides were also needed to build the test suite. - RNTester Debug simulator build succeeded. Baseline hover crash confirmed on iPad mini (A17 Pro); fixed-build touch interaction passed. Fixed-build pointer hover still needs manual verification. - Targeted clang-format, Prettier, ESLint, and git diff --check passed. Refs react#55489
# Conflicts: # packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm
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.
Summary
Fixes #55489. Supersedes #58686 with the same code and tests.
In a Debug build on iPad, hover over a
Pressablestyled withcursor: 'pointer', then press it to remove a sibling. UIKit can insert a hover-effect view ahead of that sibling. Fabric still asks to unmount the correct child, butRCTViewComponentViewchecks its index against UIKit’ssubviewsand raises an assertion. A navigation header hit this with Fabric index 0 and UIKit index 1. Storybook reproduced it by collapsing a sidebar group. Debugger observations · Storybook reproducerRCTViewComponentViewnow keeps_reactSubviewsin Fabric mounting order. With clipping off, it inserts the first child at index zero and each subsequent child above its Fabric predecessor. Unmount checks the supplied index against that list and removes the entry on every unmount, including when clipping has already detached the child from its superview.Ownership and clipping
The previous review asked what releases the views when clipping changes. Enabling
removeClippedSubviewsuses the existing list, so UIKit effect views never enter it. Disabling clipping reattaches the tracked children in order. They stay in the list until Fabric unmounts them orprepareForRecycleresets the list. Original review · Follow-up lifetime testsThe trade-off for review is one additional strong reference per mounted Fabric child when clipping is off, plus the cost of maintaining the array. A prototype that moved the hover target into a wrapper also fixed the reproducer, but required changes to hit testing, shadows and recycling. Prototype and alternatives
Changelog
[IOS] [FIXED] - Fix a crash when a pointer hover effect is active and Fabric unmounts a sibling view.
Test Plan
ComponentBuilderlinkage issue. Four later weak-reference tests cover clipped unmount, repeated clipping toggles, removal of a UIKit-owned sibling, and recycling followed by reuse. The native suite was not rerun for this resubmission.