Yes.
Yes.
Environment:
OS: macOS High Sierra 10.13.3
Node: 9.4.0
Yarn: 1.0.2
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: ^16.2.0 => 16.2.0
react-native: 0.53.0 => 0.53.0
Tested on Devices:
Using com.justsystems.atokmobile.tv.service custom keyboard then typing into a <TextInput secureTextEntry={true}> field yields the following crash:
13:16:19.098 4410-4410/com.example.dev E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.dev, PID: 4410
java.lang.IndexOutOfBoundsException: charAt: -1 < 0
at android.text.SpannableStringBuilder.charAt(SpannableStringBuilder.java:122)
at com.facebook.react.views.textinput.ReactEditTextInputConnectionWrapper.setComposingText(ReactEditTextInputConnectionWrapper.java:104)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:340)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5728)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
<TextInput>Issue isn't present with the Google AOSP keyboard. Seems to happen only with this keyboard and the secureTextEntry={true}.
This should work on all keyboards.

This looks to be as a result of the onKeyPress functionality which I worked on adding for 0.53. Seems related to this issue: https://github.com/facebook/react-native/issues/17974. I will have a look into this.
(As your stack trace suggests), specifically the problem is to do with this line: https://github.com/facebook/react-native/blob/0.53-stable/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditTextInputConnectionWrapper.java#L104. At the very least, this should be guarded against. I'm looking into why there seems to be a race condition. Will post updates.
I'm seeing this issue come up now, with React Native 0.53 and Android 6.0.1 Zebra tablets. Any time they press backspace the app is crashing.
@ccdwyer same stack trace?
@joshyhargreaves I'm not sure, I won't have access to one of the devices until Monday. I'm just hearing it from a co-worker that is on location (it's happening at a customer site). Any time they press backspace the app crashes. They are using the Google Keyboard English (US). Their Samsung Android 7.1.1 devices are working fine, though.
Thank you, I do suspect that it's the same stack trace.
I've pushed a fix to a branch on my react-native fork, if not too much trouble would you mind testing to see if it fixes your issues?
You can test in your projects by updating your package.json dependency for react-native to git+https://github.com/joshyhargreaves/react-native#89eaafe6aa9f98a32ae48a400ebfea8295918bb6, and running npm/yarn install
This is the 0.53 branch with this one additional commit.
I have just remembered that react-native is not built from source on Android. This can be fiddly to setup if you have no already set it up, but you can build react-native downloaded in node_modules by running the command ./gradlew :ReactAndroid:installArchives. I can push the built assets to the branch also to be helpful, and that would mean updating the NPM dependency would work as expected.
You weren't kidding about compiling being _fiddly_. Ran into this error: Could not get unknown property 'repositoryUrl' for project ':ReactAndroid' of type org.gradle.api.Project. and this other NDK error (have to use the exact android-ndk-r10e NDK version specified on React Native's docs).
Anyhow, I tested your commit and it seems to fix the Force Close issue I was having. Thanks!
@apparition47 thank you for checking this out and providing a detailed issue! I haven鈥檛 managed to reproduce this issue yet (on a simulator) but will try on a device as soon as I can.
So I don鈥檛 know much about the point release process, but I think this fix should be eligible to be merged into 0.53 (as well as master). I鈥檒l work on getting this done
I'm having the same issue since I've upgraded to RN 0.53. On Xperia, when I use the keyboard motion feature it crashes. If that can help here is the stack trace:
02-17 22:02:21.512 16850 16850 E AndroidRuntime: FATAL EXCEPTION: main
02-17 22:02:21.512 16850 16850 E AndroidRuntime: Process: net.cozic.joplin, PID: 16850
02-17 22:02:21.512 16850 16850 E AndroidRuntime: java.lang.IndexOutOfBoundsException: charAt: -1 < 0
02-17 22:02:21.512 16850 16850 E AndroidRuntime: at android.text.SpannableStringBuilder.charAt(SpannableStringBuilder.java:122)
02-17 22:02:21.512 16850 16850 E AndroidRuntime: at com.facebook.react.views.textinput.ReactEditTextInputConnectionWrapper.setComposingText(ReactEditTextInputConnectionWrapper.java:104)
02-17 22:02:21.512 16850 16850 E AndroidRuntime: at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:408)
02-17 22:02:21.512 16850 16850 E AndroidRuntime: at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:93)
02-17 22:02:21.512 16850 16850 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
02-17 22:02:21.512 16850 16850 E AndroidRuntime: at android.os.Looper.loop(Looper.java:241)
02-17 22:02:21.512 16850 16850 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6274)
02-17 22:02:21.512 16850 16850 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
02-17 22:02:21.512 16850 16850 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
02-17 22:02:21.512 16850 16850 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
The keyboard feature I'm using is like Swype where you swipe your finger to type words. So I'm not familiar with the source code but I'm guessing the action of swiping is triggering some event, but since the words is not fully written yet some variable doesn't have the expected value.
Maybe something to look at basically. I don't know if it can be tested in Android Simulator though.
I have addressed the crash in https://github.com/facebook/react-native/commit/b60a727adbcfa785e3d1b13bf069b766216e60f8 which is now in master. I will close this Issue and leave https://github.com/facebook/react-native/issues/17974 open until we know if the commit will make into the 0.54 release.
Thanks @joshyhargreaves. It would be nice if there was bug fix releases in RN though, because while this bug will be fixed in 0.54, I expect there will be new ones too, which means upgrade is never possible. I'm still at 0.49 because 0.51 had a crash in iOS, and 0.53 this crash in Android.
i have issue with onChangeText ...
when typing and delete texts app crash on real android but in emulator it's ok
Most helpful comment
(As your stack trace suggests), specifically the problem is to do with this line: https://github.com/facebook/react-native/blob/0.53-stable/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditTextInputConnectionWrapper.java#L104. At the very least, this should be guarded against. I'm looking into why there seems to be a race condition. Will post updates.