You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IndexOutOfBoundsException when using Google Indic Keyboard with RN 0.53.0 #17974
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
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.
Reacted by Lorenzo Sciandra, Henry Tran and Arpit Awasthi
@joshyhargreaves This is a device. I tried to reproduce it on an emulator but it didn't have the Indic keyboard. If it'd help you, I'll try to install the keyboard on an emulator and see.
@SuhairZain I installed the Indic keyboard on an emulator by downloading the APK and installing with adb however no crash for me on the emulator itself; I will try on a device.
Could you try the fix that I just pushed to a branch, you can either update your react-native dependency in your package.json or initialise a new project with react-native init fixedOnKeyPress --version joshyhargreaves/react-native#89eaafe6aa9f98a32ae48a400ebfea8295918bb6
@joshyhargreaves I was unable to reproduce it on an emulator as well. I think you wouldn't be able to reproduce this on a device either. Seems like I'm running an old version of Google Indic keyboard on my device, even though I have auto-updates on. The version I have on the emulator is 3.2.5.164561151-x86, whereas on my device it's 3.2.1.127799310-armeabi-v7a.
I think it'd be wise for me to not upgrade to the latest version of the keyboard on the device since it may be difficult to revert to the old version. What do you suggest?
But this issue doesn't appear on the older version of RN, at least as far
as 0.47.1. It's very likely that some change since then had something to do
with this edge case. Is it worth looking at?
@SuhairZain, I know what the issue was as I who introduced it while implementing onKeyPress for Android. If you look at my earlier comment you can pull the fix from my branch and test it.
@joshyhargreaves I'm unable to build a new project created using the code you posted above. Getting the following error:
Scanning folders for symlinks in /Users/suhairzain/Documents/fixedOnKeyPress/node_modules (16ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library
:app:prepareComAndroidSupportRecyclerviewV72301Library
:app:prepareComAndroidSupportSupportV42301Library
:app:prepareComFacebookFrescoDrawee081Library
:app:prepareComFacebookFrescoFbcore081Library
:app:prepareComFacebookFrescoFresco081Library
:app:prepareComFacebookFrescoImagepipeline081Library
:app:prepareComFacebookFrescoImagepipelineOkhttp081Library
:app:prepareComFacebookReactReactNative0201Library
:app:prepareOrgWebkitAndroidJscR174650Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:generateDebugResValues
:app:generateDebugResources
> Building 57% > :app:mergeDebugResources^C
➜ fixedOnKeyPress react-native run-android
Scanning folders for symlinks in /Users/suhairzain/Documents/fixedOnKeyPress/node_modules (12ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComFacebookFrescoDrawee081Library UP-TO-DATE
:app:prepareComFacebookFrescoFbcore081Library UP-TO-DATE
:app:prepareComFacebookFrescoFresco081Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipeline081Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineOkhttp081Library UP-TO-DATE
:app:prepareComFacebookReactReactNative0201Library UP-TO-DATE
:app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
:app:bundleDebugJsAndAssets SKIPPED
:app:processDebugManifest
:app:processDebugResources
warning: string 'catalyst_debugjs' has no default translation.
warning: string 'catalyst_element_inspector' has no default translation.
warning: string 'catalyst_jsload_error' has no default translation.
warning: string 'catalyst_jsload_message' has no default translation.
warning: string 'catalyst_jsload_title' has no default translation.
warning: string 'catalyst_reloadjs' has no default translation.
warning: string 'catalyst_settings' has no default translation.
warning: string 'catalyst_settings_title' has no default translation.
:app:generateDebugSources
:app:incrementalDebugJavaCompilationSafeguard
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/Users/suhairzain/Documents/fixedOnKeyPress/android/app/src/main/java/com/fixedonkeypress/MainApplication.java:5: error: cannot find symbol
import com.facebook.react.ReactApplication;
^
symbol: class ReactApplication
location: package com.facebook.react
/Users/suhairzain/Documents/fixedOnKeyPress/android/app/src/main/java/com/fixedonkeypress/MainApplication.java:6: error: cannot find symbol
import com.facebook.react.ReactNativeHost;
^
symbol: class ReactNativeHost
location: package com.facebook.react
/Users/suhairzain/Documents/fixedOnKeyPress/android/app/src/main/java/com/fixedonkeypress/MainApplication.java:14: error: cannot find symbol
public class MainApplication extends Application implements ReactApplication {
^
symbol: class ReactApplication
/Users/suhairzain/Documents/fixedOnKeyPress/android/app/src/main/java/com/fixedonkeypress/MainApplication.java:16: error: cannot find symbol
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
^
symbol: class ReactNativeHost
location: class MainApplication
/Users/suhairzain/Documents/fixedOnKeyPress/android/app/src/main/java/com/fixedonkeypress/MainApplication.java:36: error: cannot find symbol
public ReactNativeHost getReactNativeHost() {
^
symbol: class ReactNativeHost
location: class MainApplication
/Users/suhairzain/Documents/fixedOnKeyPress/android/app/src/main/java/com/fixedonkeypress/MainApplication.java:16: error: cannot find symbol
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
^
symbol: class ReactNativeHost
location: class MainApplication
/Users/suhairzain/Documents/fixedOnKeyPress/android/app/src/main/java/com/fixedonkeypress/MainApplication.java:35: error: method does not override or implement a method from a supertype
@Override
^
/Users/suhairzain/Documents/fixedOnKeyPress/android/app/src/main/java/com/fixedonkeypress/MainActivity.java:5: error: MainActivity is not abstract and does not override abstract method getPackages() in ReactActivity
public class MainActivity extends ReactActivity {
^
8 errors
:app:compileDebugJavaWithJavac FAILED
You can build react-native in-place in node_modules by running the command: ./gradlew :ReactAndroid:installArchives. Thanks let me know how you get on!
Hey, thanks for the clarification.
Yes I think replicating the fix as it has been done in the PR linked could be a good 'first approach' to have something that will prevent the crash. I believe that on the PR eventually there can be a discussion if this is the best approach or another road should be taken.
Activity
joshjhargreaves commentedon Feb 15, 2018
@SuhairZain can you post the stack trace?
SuhairZain commentedon Feb 15, 2018
@joshyhargreaves Here's all the data that I have about the crash:
{ "client": { "clientUrl": "https://github.com/MindscapeHQ/raygun4android", "name": "Raygun4Android", "version": "3.0.0" }, "context": { "identifier": "xxxxxxxxxxxxxxxxx" }, "environment": { "architecture": "armeabi-v7a", "availablePhysicalMemory": 620, "availableVirtualMemory": 0, "board": "msm8937", "brand": "Xiaomi", "currentOrientation": "Portrait", "deviceCode": "land", "deviceName": "Redmi 3S", "diskSpaceFree": 5861, "locale": "en_US", "oSVersion": "6.0.1", "osSDKVersion": "23", "processorCount": 8, "totalPhysicalMemory": 2843, "totalVirtualMemory": 0, "utcOffset": 5.0, "windowsBoundHeight": 1280, "windowsBoundWidth": 720 }, "error": { "className": "java.lang.IndexOutOfBoundsException", "message": "IndexOutOfBoundsException: charAt: -1 < 0", "stackTrace": [ { "className": "android.text.SpannableStringBuilder", "fileName": "SpannableStringBuilder.java", "lineNumber": 117, "methodName": "charAt" }, { "className": "com.facebook.react.views.textinput.ReactEditTextInputConnectionWrapper", "fileName": "ReactEditTextInputConnectionWrapper.java", "lineNumber": 104, "methodName": "setComposingText" }, { "className": "com.android.internal.view.IInputConnectionWrapper", "fileName": "IInputConnectionWrapper.java", "lineNumber": 340, "methodName": "executeMessage" }, { "className": "com.android.internal.view.IInputConnectionWrapper$MyHandler", "fileName": "IInputConnectionWrapper.java", "lineNumber": 78, "methodName": "handleMessage" }, { "className": "android.os.Handler", "fileName": "Handler.java", "lineNumber": 102, "methodName": "dispatchMessage" }, { "className": "android.os.Looper", "fileName": "Looper.java", "lineNumber": 157, "methodName": "loop" }, { "className": "android.app.ActivityThread", "fileName": "ActivityThread.java", "lineNumber": 5555, "methodName": "main" }, { "className": "java.lang.reflect.Method", "fileName": "Method.java", "lineNumber": -2, "methodName": "invoke" }, { "className": "com.android.internal.os.ZygoteInit$MethodAndArgsCaller", "fileName": "ZygoteInit.java", "lineNumber": 745, "methodName": "run" }, { "className": "com.android.internal.os.ZygoteInit", "fileName": "ZygoteInit.java", "lineNumber": 635, "methodName": "main" } ] }, "machineName": "Redmi 3S", "request": { "iPAddress": [ "xxxxxxxxxxxxx" ], "networkConnectivityState": "Connected - WiFi" }, "tags": [ "UnhandledException" ], "user": { "identifier": "xxxxxxxxxxx" }, "version": "xxxxxxxxxxx", "OccurredOn": "2018-02-14T04:27:24Z" }joshjhargreaves commentedon Feb 15, 2018
@SuhairZain are you able to reproduce on a simulator? Or is this a device?
SuhairZain commentedon Feb 15, 2018
@joshyhargreaves This is a device. I tried to reproduce it on an emulator but it didn't have the Indic keyboard. If it'd help you, I'll try to install the keyboard on an emulator and see.
joshjhargreaves commentedon Feb 15, 2018
@SuhairZain I installed the Indic keyboard on an emulator by downloading the APK and installing with
adbhowever no crash for me on the emulator itself; I will try on a device.Could you try the fix that I just pushed to a branch, you can either update your react-native dependency in your
package.jsonor initialise a new project withreact-native init fixedOnKeyPress --version joshyhargreaves/react-native#89eaafe6aa9f98a32ae48a400ebfea8295918bb6SuhairZain commentedon Feb 15, 2018
@joshyhargreaves I was unable to reproduce it on an emulator as well. I think you wouldn't be able to reproduce this on a device either. Seems like I'm running an old version of Google Indic keyboard on my device, even though I have auto-updates on. The version I have on the emulator is 3.2.5.164561151-x86, whereas on my device it's 3.2.1.127799310-armeabi-v7a.
I think it'd be wise for me to not upgrade to the latest version of the keyboard on the device since it may be difficult to revert to the old version. What do you suggest?
joshjhargreaves commentedon Feb 15, 2018
@SuhairZain could you build your repo-project for your device with the changes I just pushed and let me know if it still crashes on your device?
joshjhargreaves commentedon Feb 15, 2018
I greatly suspect it will have fixed the issue. For the
onKeyPressAPI perspective, it should still make sense.SuhairZain commentedon Feb 15, 2018
joshjhargreaves commentedon Feb 15, 2018
@SuhairZain, I know what the issue was as I who introduced it while implementing onKeyPress for Android. If you look at my earlier comment you can pull the fix from my branch and test it.
SuhairZain commentedon Feb 15, 2018
@joshyhargreaves I'm sorry. I was replying via email and didn't see your 1st comment. I'll check right away.
SuhairZain commentedon Feb 15, 2018
@joshyhargreaves I'm unable to build a new project created using the code you posted above. Getting the following error:
joshjhargreaves commentedon Feb 15, 2018
@SuhairZain sorry, that's my bad, I forgot that android needs to be built from source.
SuhairZain commentedon Feb 15, 2018
@joshyhargreaves In that case, I'll build it from source and try tomorrow. I see that it'll take some time.
joshjhargreaves commentedon Feb 15, 2018
You can build react-native in-place in
node_modulesby running the command:./gradlew :ReactAndroid:installArchives. Thanks let me know how you get on!19 remaining items
kelset commentedon Feb 26, 2018
Hey, thanks for the clarification.
Yes I think replicating the fix as it has been done in the PR linked could be a good 'first approach' to have something that will prevent the crash. I believe that on the PR eventually there can be a discussion if this is the best approach or another road should be taken.
joshjhargreaves commentedon Feb 26, 2018
@kelset I'll put in a PR to master in a few hours. Hopefully @kmagiera won't mind giving it a review!
Fix crashes onKeyPress Android
joshjhargreaves commentedon Feb 27, 2018
This should be addressed in, so I will close: b60a727. Please re-open if the problem somehow persists.
joshjhargreaves commentedon Feb 27, 2018
I'lll re-open until we know if this commit make it into the
0.54release.grabbou commentedon Mar 1, 2018
I'll close it as I am cherry picking it right now.
Fix crashes onKeyPress Android
Fix crashes onKeyPress Android