react-native
react-native copied to clipboard
TextInput is causing app to hang in Samsung devices with Android 13
Description
Our app is throwing ANRs when users with Samsung devices with Android 13 are typing in input fields. We had a similar issue for Samsung users with Android 12 and we ended up disabling auto-correct for those users to fix this issue. Now it looks like is the suggestions setting that is causing ANRs in Android 13 so we are setting the keyboardType
as visible-password
to avoid suggestions.
Version
0.69.3
Output of npx react-native info
System:
OS: macOS 12.5.1
CPU: (10) arm64 Apple M1 Pro
Memory: 1.36 GB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.5.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.12.1 - /opt/homebrew/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8609683
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
Java: 11.0.12 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: Not Found
react-native: Not Found
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps to reproduce
1 - Clone the repo https://github.com/JuanAlejandro/keyboard-issue-samsung
2 - Run yarn install
3 - Test release
variant in a Samsung S22
4 - Start typing until you reach 3-4 lines of text.
Expected result:
- The app works properly when the user types
Actual result:
- The app hangs
Snack, code example, screenshot, or link to a repository
GitHub repo: https://github.com/JuanAlejandro/keyboard-issue-samsung
Video: https://user-images.githubusercontent.com/11820379/199054761-5bd9d015-488f-4528-bf5e-4992f02e41c0.mp4
I'm having a similar ANR but with Pixel phones. And it's only happening in Android 13.
I have the same issue with samsung Android 13
Our users are experiencing the same thing. Can you confirm that suggestions are causing the hanging? How did you guys workaround it?
Our users are experiencing the same thing. Can you confirm that suggestions are causing the hanging? How did you guys workaround it?
We set the keyboardType
to visible-password
. This will not bring up the text suggestions menu up so it will not cause the hang.
Subscribing
Currently we are setting autoCorrect
to false for android version 12 and 13 and for samsung devices, do we need to set keyboardType
to visible-password
as well? @JuanAlejandro
Looks like it might not just be related to react-native, https://support.google.com/pixelphone/thread/181332682/keyboard-freezing-after-android-13-update?hl=en
Currently we are setting
autoCorrect
to false for android version 12 and 13 and for samsung devices, do we need to setkeyboardType
tovisible-password
as well? @JuanAlejandro
Yes @Saad-Bashar. This is an ugly hack but better to have that than the app freezing every time they are typing.
Looks like it might not just be related to react-native, https://support.google.com/pixelphone/thread/181332682/keyboard-freezing-after-android-13-update?hl=en
I wouldn't say this is related to this issue since there are not enough data to say this is happening to all devices with Android 13 (I have a Google Pixel 4 XL and I have not experienced any issue with the keyboard).
@JuanAlejandro hi! i downloaded your repo today. but, i cannot reproduce the problem. there are only expected results - "The app works properly when the user types". i followed your step - "Steps to reproduce". and did not to change for code. and i builded on 'galaxy 22, plus, ultra'. all results are same. in your local or emulator not applied to your solution, is the problem still occured?
Hi @rudenick0309! Does your Samsung device has Android 13?
I just updated the steps to include "Samsung S22 with Android 13" in the 3rd step.
You can see how this issue is repro in the video below
https://user-images.githubusercontent.com/11820379/201818480-9ff2baf7-989a-414c-9d2e-bc8253897275.mp4
@JuanAlejandro thank your answer! but, i have device like you. exactly samsung 22, 22+, 22ultra with android 13. i dont know why i cannot reproduce this problem. am i lucky? :)
By the way, did you solve it by putting " keyboardType={'visible-password'} " in the TextInput tag? i have made a simple realtime chat app using 'TextInput'. so i want to prevent textInput this problem.
@rudenick0309 just one last thing... are you using the default keyboard of Samsung? There are a handful of users that prefer to have the Gboard. I don't know if the issue still persists with a different keyboard, but it might be a possibility.
And yes, I solved it by putting the keyboardType='visible-password'
to the TextInput
. But I wouldn't do it in your app if you haven't received complaints or your ANRs are increasing.
@JuanAlejandro thank you for your advice. you are right. i have not received any complaints or ANRs. i will do more consider. thanks to your support, if i meet these case, i will solve more quickly! thank you
@JuanAlejandro @rudenick0309 Our customers have the same issue with Android 13 on Samsung and Pixel devices (both Samsung Keyboard and Gboard). Just typing a sentence, the application will throw the ANR pop-up and must be forced close. We can't turn off the predictive or spell check due to production requirements. Do you have any suggestions, we have received many complaints about that day by day.
Unfortunately, our case is the same. One of the key functionality of our apps is writing text in the TextInput. The majority of our android users are using Samsung. We are getting so many crashes every day :(
Same here! The solution keyboardType='visible-password'
works for normal inputs, but won't work for multiline inputs as it will always be 1 line without the return key as a new line ( while you can still scroll if the text it long enough )
Same here! The solution
keyboardType='visible-password'
works for normal inputs, but won't work for multiline inputs
Do you mean you still get the crashes for multiline inputs? Because we have multiline inputs. Thanks.
@Saad-Bashar No I mean the input will be narrowed to one line, so you can't have TextArea-like inputs
So it will always be 1 line without the return key as a new line ( while you can still scroll if the text is long enough )
So, in our use case, I was able to identify the issue and it's actually a bug in the android framework (issue only happens on android version 13 for us)
You can find more details here: https://github.com/facebook/react-native/issues/35350#issuecomment-1323399593
@Saad-Bashar No I mean the input will be narrowed to one line, so you can't have TextArea-like inputs So it will always be 1 line without the return key as a new line ( while you can still scroll if the text is long enough )
We used returnKeyType=none
, then it works fine for multiline.
@hannojg can we change any lines on the native or android framework to fix this problem?
@Phong-TH If you don't use rotation anywhere in your react-native code, you can try commenting the rotation lines:

If the issue is with the usage of an inverted FlatList I recommend manually inverting the FlatList. If you guys are interested I can post an example
@hannojg by rotation you mean orientation change, right?
@hannojg Thanks for your implementation but I do not use FlatList, just a screen have a TextInput with multiline={true} and predictive causes the ANR, so I don't think the inverted prop causes the error 😕
Same here, we are not using any FlatList. Just TextInput. It hangs on Android 13.
So, in our use case, I was able to identify the issue and it's actually a bug in the android framework (issue only happens on android version 13 for us)
You can find more details here: #35350 (comment)
@hannojg there are two issues:
- One related to FlatList and the inverted prop that causes ANRs in all Android devices with system version 13.
- The other one is related to the TextInput that affects only Samsung devices with Android 13.
Oh yeah I see, good separation! Sorry for any caused confusion 😄
If you got multiple TextInput in your app, the fastest way to temporally fix the issue is to put this in your index.js
file:
import { Platform, TextInput } from "react-native";
TextInput.defaultProps = {
...TextInput.defaultProps,
autoCorrect: Platform.OS === "ios",
keyboardType: Platform.OS === "android" ? "visible-password" : "default",
returnKeyType: Platform.OS === "android" ? "none" : "default",
spellCheck: Platform.OS === "ios",
};
~ps. Be careful though if you got different keyboard types eg. numeric
, number
or email-address
, it will override them.~
While applying visible-password
the TextInput is treated as a single line, it won't autoresize when long text is entered