question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(Android) crash on TextInput onKeyPress when inputting an emoji via auto-complete

See original GitHub issue

On 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 .

screenshot_1521183883

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:9
  • Comments:31 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
nickofthymecommented, May 16, 2018

Are there any updates on this issue? Thanks

Update: Still present in 0.55.3

3reactions
akalin-keybasecommented, Mar 16, 2018

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:

[258,"topKeyPress",{"key":"�"}]

(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#L32

so it looks like JSC_JSStringCreateWithUTF8CString is having problems with the emoji character.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found