Skip to content

fix(keyboard): don't dispatch a nil keyboard event for dead keys - #3191

Draft
Saad Najmi (Saadnajmi) wants to merge 1 commit into
microsoft:mainfrom
Saadnajmi:fix-dead-key-crash
Draft

Saad Najmi (Saadnajmi) wants to merge 1 commit into
microsoft:mainfrom
Saadnajmi:fix-dead-key-crash

Conversation

@Saadnajmi

@Saadnajmi Saad Najmi (Saadnajmi) commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary:

On the legacy architecture, typing a dead key (for example ´ on a Spanish layout) into a TextInput crashes the app on the JS thread with strlen(NULL) in -[RCTCxxBridge enqueueJSCall:method:args:completion:].

+[RCTViewKeyboardEvent keyEventFromEvent:reactTag:] returns nil for dead keys, because charactersIgnoringModifiers is empty. -[RCTView handleKeyboardEvent:] then passes that nil to -[RCTEventDispatcher sendEvent:], which queues an event ID with no event. When the queue flushes, dispatchEvent:nil sends nil module and method names to the bridge, and [nil UTF8String] reaches std::string.

Before the 0.81 keyboard rework, handleKeyboardEvent: only dispatched a non-nil event, and RCTScrollView still does. This restores that check. The new architecture doesn't use RCTViewKeyboardEvent here, so it isn't affected.

Paste doesn't crash because it doesn't go through keyDown:.

Backport to 0.81: #3192

Test Plan:

  • xcrun clang -fsyntax-only -x objective-c -fobjc-arc -fmodules on React/Views/RCTView.m, with the repository's headers on the include path: no errors.
  • Not run: RNTester-macOS on the legacy architecture with a Spanish keyboard layout. Expected: typing ´ then o inserts ó instead of crashing.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant