Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nil check to RCTBaseInputTextView #1895

Merged
merged 5 commits into from
Aug 2, 2023

Conversation

lyzhan7
Copy link

@lyzhan7 lyzhan7 commented Aug 1, 2023

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos 馃憤
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos 馃憤
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Summary

Currently seeing a crash in RCTBaseInputTextView when attempting to change formatting via the touch bar (ex. changing colors). The crash is occurring somewhere in the textInputShouldChangeText method. Here is the crash stack:

Crashed thread: 0
uncaught ObjC exception, reason: *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]

Last Exception Backtrace:
0   CoreFoundation                      0x0000000183ff0650 __exceptionPreprocess + 176
1   merp                                0x000000010a87d49c MerpPreprocessObjCException + 44
2   libobjc.A.dylib                     0x0000000183ae9eb4 objc_exception_throw + 60
3   CoreFoundation                      0x0000000183f07f94 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 728
4   CoreFoundation                      0x0000000183f07c90 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 52
5   .......                             0x000000011bbbf1a8 -[RCTBaseTextInputView textInputShouldChangeText:inRange:] + 920

The crash looks like it's happening when we're creating a dictionary, and as far as I can tell this is the only dictionary being created in this method. The error message is specifically complaining about the first entry into the dictionary being nil, so I added a nil check here.

Changelog

Test Plan

The crash is only repro'ing in ship builds, and not debug builds, so will validate whether this change fixes the issue once the change makes it into the right build.

@lyzhan7 lyzhan7 requested a review from a team as a code owner August 1, 2023 17:09
Copy link
Collaborator

@Saadnajmi Saadnajmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also backport to 0.71-stable plz :)

Libraries/Text/TextInput/RCTBaseTextInputView.m Outdated Show resolved Hide resolved
@lyzhan7 lyzhan7 requested a review from Saadnajmi August 1, 2023 22:25
@Saadnajmi Saadnajmi enabled auto-merge (squash) August 2, 2023 00:32
@lyzhan7 lyzhan7 changed the title Attempt to fix crash in RCTBaseInputTextView - add nil check Add nil check to RCTBaseInputTextView Aug 2, 2023
@Saadnajmi Saadnajmi merged commit d249126 into microsoft:main Aug 2, 2023
18 of 19 checks passed
@lyzhan7 lyzhan7 deleted the add-nil-check branch August 2, 2023 02:07
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.

None yet

2 participants