Skip to content

fix(ios): replace crash-causing RCTAssert with RCTLogWarn in touch handler#57696

Open
hryhoriiK97 wants to merge 1 commit into
react:mainfrom
hryhoriiK97:hryhoriiK97/fix-touch-registry-assert
Open

fix(ios): replace crash-causing RCTAssert with RCTLogWarn in touch handler#57696
hryhoriiK97 wants to merge 1 commit into
react:mainfrom
hryhoriiK97:hryhoriiK97/fix-touch-registry-assert

Conversation

@hryhoriiK97

Copy link
Copy Markdown

Summary:

On iOS 17+, UITextView's text selection gesture recognizer can deliver touchesMoved:/touchesEnded: to RCTSurfaceTouchHandler without a prior touchesBegan: for the same touch. This happens because UIKit's internal selection gesture claims the touch begin exclusively and only forwards subsequent phases to sibling gesture recognizers.

When this occurs, _activeTouches.find(touch) returns end(), and the RCTAssert fires — throwing an NSException that crashes the app in debug builds. The existing if (iterator == end) { continue; } guard already handles this case gracefully (and is the only code path exercised in release builds, where RCTAssert is a no-op).

This PR downgrades the assertion to RCTLogWarn, preserving the diagnostic signal while eliminating the debug-only crash.

This issue was discovered while investigating text selection crashes in react-native-enriched-markdown, where a custom UITextView-based Fabric component with rich text formatting (headings, paragraphs) consistently triggers the assertion during normal selection gestures.

Changelog:

[IOS] [FIXED] - Fix debug-only crash "Inconsistency between local and UIKit touch registries" in RCTSurfaceTouchHandler triggered by UITextView selection gestures on iOS 17+

Test Plan:

  1. Create a React Native app with a multiline <TextInput> or a custom UITextView-based Fabric component
  2. On iOS 17+ simulator or device, in a debug build:
    • Tap to place the cursor in a text block
    • Attempt to select text by long-pressing and dragging to a different paragraph
  3. Before this fix: App crashes with NSException: "Inconsistency between local and UIKit touch registries"
  4. After this fix: Selection works normally. A warning is logged to the console: "Inconsistency between local and UIKit touch registries"
  5. Verified that release builds are unaffected (RCTAssert was already a no-op in release)

@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 Jul 26, 2026
@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 Jul 26, 2026
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