Skip to content

TextInput is causing app to hang in Samsung devices with Android 13 #35155

Description

@JuanAlejandro

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 with Android 13
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

Activity

  1. lucasuracosta commented on Nov 1, 2022

    @lucasuracosta

    I'm having a similar ANR but with Pixel phones. And it's only happening in Android 13.

  2. Dlpan commented on Nov 3, 2022

    @Dlpan

    I have the same issue with samsung Android 13

  3. justindi15 commented on Nov 3, 2022

    @justindi15

    Our users are experiencing the same thing. Can you confirm that suggestions are causing the hanging? How did you guys workaround it?

  4. JuanAlejandro commented on Nov 4, 2022

    @JuanAlejandro
    Author

    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.

  5. rikur commented on Nov 11, 2022

    @rikur

    Subscribing

  6. Saad-Bashar commented on Nov 14, 2022

    @Saad-Bashar

    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

  7. Saad-Bashar commented on Nov 14, 2022

    @Saad-Bashar
  8. JuanAlejandro commented on Nov 14, 2022

    @JuanAlejandro
    Author

    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

    Yes @Saad-Bashar. This is an ugly hack but better to have that than the app freezing every time they are typing.

  9. JuanAlejandro commented on Nov 14, 2022

    @JuanAlejandro
    Author

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

  10. rudenick0309 commented on Nov 15, 2022

    @rudenick0309

    @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?

  11. JuanAlejandro commented on Nov 15, 2022

    @JuanAlejandro
    Author

    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

    video-repro-s22-android-13.mp4
  12. rudenick0309 commented on Nov 15, 2022

    @rudenick0309

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

  13. 81 remaining items

  14. Nasseratic commented on Jan 6, 2023

    @Nasseratic

    Does the above even work for a multiline textinput?

    @swrobel
    See this #35155 (comment)

  15. gkasireddy202 commented on Jan 6, 2023

    @gkasireddy202

    @mglobel - Great.
    I had a sample class component using TextInput.
    How to resolve this issue without using mobx?
    import React, { Component } from "react";
    import { View, TextInput ,Text} from 'react-native';
    class Loginpage extends Component {
    constructor(props) {
    super(props);
    this.state = {
    message: ''
    }
    }

    render() {
        return (
            <View style={{ flex: 1 }}>
                <View style={{ flex: 1 }}>
                </View>
                <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center', margin: 30 }}>
                    <TextInput style={{ height: 70, width: '100%', borderWidth: 1, borderColor: 'grey' }}
                        placeholder="message"
                        numberOfLines={5}
                        multiline={true}
                        returnKeyType="done"
                        blurOnSubmit={true}
                        // defaultValue=""
                        value={this.state.message}
                        onChangeText={(text)=>this.setState({message:text})}>
    
                    </TextInput>
                    <Text>{this.state.message}</Text>
                </View>
                <View style={{ flex: 1 }}>
                </View>
            </View>
        )
    }
    

    }

  16. mglobel commented on Jan 6, 2023

    @mglobel

    @mglobel - Great. I had a sample class component using TextInput. How to resolve this issue without using mobx? import React, { Component } from "react"; import { View, TextInput ,Text} from 'react-native'; class Loginpage extends Component { constructor(props) { super(props); this.state = { message: '' } }

    render() {
        return (
            <View style={{ flex: 1 }}>
                <View style={{ flex: 1 }}>
                </View>
                <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center', margin: 30 }}>
                    <TextInput style={{ height: 70, width: '100%', borderWidth: 1, borderColor: 'grey' }}
                        placeholder="message"
                        numberOfLines={5}
                        multiline={true}
                        returnKeyType="done"
                        blurOnSubmit={true}
                        // defaultValue=""
                        value={this.state.message}
                        onChangeText={(text)=>this.setState({message:text})}>
    
                    </TextInput>
                    <Text>{this.state.message}</Text>
                </View>
                <View style={{ flex: 1 }}>
                </View>
            </View>
        )
    }
    

    }

    @gkasireddy202 There was one place where we don't actually have mobx and used another solution. We simply added a variable on the class component instead of using state and updated it directly. Normally we don't do this because we want to use state to take advantage of React's DOM re-rendering. But in this case it seems to be hurting us.

    So in your constructor function:

    constructor(props) { 
      super(props); 
      this.message = ""
    }
    

    And then onChangeText:

    onChangeText={(text)=> this.message = text}>
    

    And then you can actually remove the value={this.state.message} prop from your <TextInput> component. <TextInput> will maintain its own value state, using the value prop is only necessary in certain scenarios. You'll notice in the react native docs they don't have a value prop: https://reactnative.dev/docs/handling-text-input.

  17. insanemal commented on Jan 9, 2023

    @insanemal

    For anyone dealing with this issue, the freezing only seems to be happening using the default Samsung keyboard. We've been able to recommend to our users to install Google's Keyboard and the freezing does not happen.

    https://play.google.com/store/apps/details?id=com.google.android.inputmethod.latin&hl=en_US&gl=US

    Not a great long term solution, but hopefully can help provide some relief while this is investigated.

    I still get ANRs and all the other issues on the latest Samsung firmware with react-native based apps when using Google Keyboard

    Much like the goggles, this does nothing

  18. welch174 commented on Jan 12, 2023

    @welch174

    I would like to help some people here with chat views that are freezing. There are two issues at play here

    • This issue is the Samsung Android 13 Keyboard.
    • There is also an issue with Inverted FlatLists with text views performing very poorly. 35350

    The inverted flat list issue has a work around that involves drawing it upside down and then drawing the contents upside down.

    This issue has a "work around" of switching the text input type to visible password.

  19. ruairioliverwv commented on Jan 12, 2023

    @ruairioliverwv

    Adding inputType textNoSuggestions in react-native to disable the autocomplete functionality. https://stackoverflow.com/a/1992201/7295772

    android:inputType="textNoSuggestions"
    

    https://github.com/facebook/react-native/blob/76a14454d7f1f2b2ba8f5a79c2f640fafb42de6d/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java#L1153-L1168

    I will test and publish a PR tomorrow.

    Actually this did come in useful in the end for me as a temporary measure. At least I can keep emojis for my input and I'm just losing autocomplete and autocorrect. So I'm just setting keyboardType: "no-suggestions" for Samsung Android 13 and leaving every other device and OS as normal

  20. pierroo commented on Jan 12, 2023

    @pierroo

    @ruairioliverwv what keyboardType is the "no suggestions" you are talking about?
    the "visible-password"?
    It does lose the multiline ability unfortunately as mentioned above (and in spite of the "hacks" around it)

    It is beyond me how such a huge issue can remain pending and obscure after all these months...
    Non-react-native apps are not facing this issue with inputs, so I do believe it's in react-native team's hands but I'm not sure if they are aware of it? or if there is any way to raise this issue's priority? Since it literally kills any chatting app that heavily relies on multiline + text suggestions.

  21. ruairioliverwv commented on Jan 12, 2023

    @ruairioliverwv

    @pierroo you'd need to build react-native from source I think and use the changes here to add the no-suggestions keyboard type. Once done though the outcome is nicer than visible-password which is the best we have without this change. At least users can use emojis again with this

    https://github.com/facebook/react-native/pull/35691/files#diff-9a8e69138cf9cdf44b42d6593d0eba921cedf195288448b13984747336bd5dba

  22. pierroo commented on Jan 12, 2023

    @pierroo

    Thank you for your answer;
    do you also keep the multiline with it, unlike visible-password? or is the emoji the only difference?

  23. gkasireddy202 commented on Jan 12, 2023

    @gkasireddy202

    Any solution without disabling the no-suggestions keyboard.

  24. ruairioliverwv commented on Jan 12, 2023

    @ruairioliverwv

    Multiline is fine for me with visible-password and no-suggestions but need to set the returnKeyType to none.

    So this is the function I'm using to get my extra input props.

    
    const getExtraInputProps = () => {
        if (
            Platform?.constants?.Manufacturer === "samsung" &&
            Platform?.constants?.Release === "13"
        ) {
            return {
                keyboardType: "no-suggestions",
                returnKeyType: "none"
            };
        }
        return {};
    };
    
  25. lunaleaps commented on Jan 12, 2023

    @lunaleaps
    Contributor

    Closing issue as we're addressing in #35590 (comment)

  26. gkasireddy202 commented on Jan 13, 2023

    @gkasireddy202

    Please suggest any accurate solution to resolve this issue.
    I am getting more ANR crash reports from bugsnag.

  27. locked and limited conversation to collaborators on Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions