react-native: IndexOutOfBoundsException when using Google Indic Keyboard with RN 0.53.0
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
Environment: OS: macOS High Sierra 10.13.2 Node: 8.4.0 Yarn: 0.27.5 npm: 5.3.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
Target Platform: Android (6.0.1)
Steps to Reproduce
- Create and run a new project with RN 0.53.0, using
react-native init
. (Most likely exists for projects created using other methods as well, didn’t check.) - Switch the keyboard to Google Indic Keyboard from phone’s input settings
- Steps for reproducing the crash with emojis: a. Create a TextInput with no additional props (or switch to the master branch of the provided repo). a. Type an emoji and press the backspace twice.
- Steps for reproducing the crash with any character: a. Create a TextInput with autoCorrect={false} (or switch to the auto-correct branch of the provided repo). a. Type any character and press the backspace once.
Expected Behavior
The emojis and characters get cleared with no crashes
Actual Behavior
The app crashes on clearing the emojis, with no additional props set on the TextInput The app crashes on clearing the last character in case autoCorrect={false} is set
Reproducible Demo
https://github.com/SuhairZain/react-native-gindic-keyboard-crash
The master
branch crashes when deleting an emoji character
The auto-correct
branch crashes when deleting the last character in the input
The reason that I’ve created this issue here rather than on the Google Indic keyboard repo is that I can confirm that this bug does not exist with 0.47.1, which is the version our app was on before we upgraded. This is a bug that was introduced in one of the versions from then to 0.53.0.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 39 (29 by maintainers)
Commits related to this issue
- Fix crashes onKeyPress Android Summary: There appear to be two different types of crashes related to the recent addition of `onKeyPress` on Android introduce in `0.53`. This PR addresses the cause of... — committed to facebook/react-native by joshjhargreaves 6 years ago
- Fix crashes onKeyPress Android Summary: There appear to be two different types of crashes related to the recent addition of `onKeyPress` on Android introduce in `0.53`. This PR addresses the cause of... — committed to facebook/react-native by joshjhargreaves 6 years ago
- Fix crashes onKeyPress Android Summary: There appear to be two different types of crashes related to the recent addition of `onKeyPress` on Android introduce in `0.53`. This PR addresses the cause of... — committed to tracemeinc/react-native by joshjhargreaves 6 years ago
- Fix crashes onKeyPress Android Summary: There appear to be two different types of crashes related to the recent addition of `onKeyPress` on Android introduce in `0.53`. This PR addresses the cause of... — committed to inizio-inc/react-native by joshjhargreaves 6 years ago
- Fix crashes onKeyPress Android Summary: There appear to be two different types of crashes related to the recent addition of `onKeyPress` on Android introduce in `0.53`. This PR addresses the cause of... — committed to inizio-inc/react-native by joshjhargreaves 6 years ago
- Fix crashes onKeyPress Android Summary: There appear to be two different types of crashes related to the recent addition of `onKeyPress` on Android introduce in `0.53`. This PR addresses the cause of... — committed to triggr/react-native by joshjhargreaves 6 years ago
- Fix crashes onKeyPress Android Summary: There appear to be two different types of crashes related to the recent addition of `onKeyPress` on Android introduce in `0.53`. This PR addresses the cause of... — committed to triggr/react-native by joshjhargreaves 6 years ago
@joshyhargreaves Thanks! I built an APK with it and sent it over to my team.
@ccdwyer no problem, I will do this evening as currently AFK!
I’lll re-open until we know if this commit make it into the
0.54
release.@kelset I’ll put in a PR to master in a few hours. Hopefully @kmagiera won’t mind giving it a review!
Hey @kelset, thank you for the crash reports, I had actually suspected that their might be a few different ways that this bug could manifest itself. One of the main issues I’ve had actually, is I haven’t been able to repro it myself actually, but I will put in some more effort. I’m entirely sure, that the fix I posted wouldn’t result in any more indexOutOfBoundsExceptions.
Looking at your stack traces, I’m not actually that confident that that the fix I posted previously would fix these, as it seems like the reference to the wrapped InputConnection can turn null, but I will do a bit of thinking/researching over the next few hours.
I will absolutely put in a pull request for this, I think it may be a good idea also to only enable this codepath if using ‘onKeyPress’, and so I will have a look at that also!
Let’s just get this fixed, thanks again for the crash reports.
👋 @joshyhargreaves
I think that the issue OP posted is actually just one of the ways the bug can manifest itself (and #17922 is another) - this weekend we released the latest update to our app with RN 0.53 and I have 3 different crash reports that seems to be all related to the same root issue:
Sadly I can’t post much more of the stacktrace since it comes from the minified prod version; but I strongly believe the fix you linked earlier will solve these crashes too (I can’t dive deeper into creating a repro or doing a new release pointing at your branch because of higher prior tasks this week).
It’s still quite a small ‘surface’, since we are talking about a precise set of actions on a custom keyboard on Android (overall, we got less than 20 crashes reported by up to 6 users - which is a .00x% of our userbase) so no rush, but are you planning on doing a PR with it?
I don’t think, since it’s already late Feb, that it would be merged & cherry picked into a new 0.53.x release, but I think it would be possible to have it in 0.54 💪
(ps: ofc if there’s anything that I can do to help let me know!)
@joshyhargreaves It appears that the crash is gone for us with your change. Thanks!