(Android) crash on TextInput onKeyPress when inputting an emoji via auto-complete
See original GitHub issueOn 0.53.0 and later, including 0.54.2, if I input an emoji into a TextInput via auto-complete, the app crashes.
I’ve tracked down the root cause; I’ll put more details in a follow-up comment.
Environment
Environment:
OS: macOS High Sierra 10.13.3
Node: 9.7.1
Yarn: 1.5.1
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: Not Found
Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.53.3 => 0.53.3
Expected Behavior
No crash!
Actual Behavior
Crash stack:
Error calling RCTEventEmitter.receiveEvent
Failed to create Value from JSON:
run
NativeRunnable.java
handleCallback
Handler.java:790
dispatchMessage
Handler.java:99
dispatchMessage
MessageQueueThreadHandler.java:31
loop
Looper.java:164
run
MessageQueueThreadImpl.java:194
run
Thread.java:764
Steps to Reproduce
Fortunately, this repros with the example project from https://github.com/facebook/react-native/issues/18262 .
- Clone and run this repo https://github.com/lxcid/ReactNative-AndroidKeyPress
- Make sure you have an Android device attached for debugging.
- react-native run-android
- select the TextInput
- type ‘potato’
- tap the potato emoji that shows up in autocomplete.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:31 (11 by maintainers)
Top Results From Across the Web
Android 8.0 Oreo crash on focusing TextInputEditText
When we go to android Settings -> System -> Languages & input -> Advanced -> Auto-fill service -> None , then focusing on...
Read more >Create an input method - Android Developers
An input method editor (IME) is a user control that enables users to ... IMEs to display autofill suggestions inline, instead of using...
Read more >Emoji selector crashes the message editor in Android / Chrome
The double events cause a crash due to the way our autocomplete library is designed. So the library listens to both keydown and...
Read more >keydown and keyup events do not have proper keyCode (it's ...
Steps to reproduce: 1. Load the attached HTML file in Chrome for Android. 2. Click on the input element. 3.
Read more >Microsoft SwiftKey Android Support Forums – SwiftKey
I'd be able to use space for input word which I have used previously but it's losing its accuracy. Autocomplete injecting words. 0...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Are there any updates on this issue? Thanks
So the "Failed to create value from JSON: " exception is thrown from: https://github.com/facebook/react-native/blob/0ee502d1254b828efb119cc06bcd213c3d843269/ReactCommon/jschelpers/Value.cpp#L74 (i.e., it’s trying to parse JSON from an empty string)
Debugging this code, this is called from: https://github.com/facebook/react-native/blob/0ee502d1254b828efb119cc06bcd213c3d843269/ReactCommon/jschelpers/Value.cpp#L98
The conversion to JSON produces the string:
(I’m not 100% sure if the �, which is supposed to be the potato emoji, is messed up because of the JSON conversion messing up or my debugging output.)
It is the
String(ctx, json.c_str())
conversion that is failing and returning an empty string. This leads to the line https://github.com/facebook/react-native/blob/0ee502d1254b828efb119cc06bcd213c3d843269/ReactCommon/jschelpers/Value.h#L32so it looks like
JSC_JSStringCreateWithUTF8CString
is having problems with the emoji character.