react-native-keyboard-controller: iOS crash when native alert is shown while keyboard is visible
Describe the bug iOS crashes when using a native alert while the keyboard is shown, I can confirm this only happens if the app is wrapped in the KeyboardProvider, removing the Keyboard provider from the snippet below will avoid the crash on ios.
Code snippet
import { Alert, Button, TextInput, View } from "react-native";
import { KeyboardProvider } from "react-native-keyboard-controller";
export function App() {
return (
<KeyboardProvider>
<TestView />
</KeyboardProvider>
);
}
function TestView() {
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<TextInput placeholder="PLACHOLDER TEXT" />
<Button
onPress={() => {
Alert.alert("Hello");
}}
title="Show Alert"
/>
</View>
);
}
Repo for reproducing No repo provided as the code sample is simple enough to paste into a running env without having to checkout and build another repo.
To Reproduce Steps to reproduce the behavior:
- Select placeholder text to expose keyboard
- press show alert button
- see crash
Expected behavior Alerts should not crash the app when the keyboard is shown
Screenshots If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
- Desktop OS: MacOS 13.4 (22F66)
- Device: iPhone 13 pro
- OS: 16.5
- RN version: 0.71.8 - Expo SDK 48.0.18
- RN architecture: old arch
- JS engine: hermes
- Library version: 1.5.6
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (10 by maintainers)
@kirillzyusko I can confirm this fixes the issue, nice work.
sure here is the repo, and the video below showing the crash only when the keyboard is visible.
https://github.com/owinter86/keyboard-crash-rn
https://github.com/kirillzyusko/react-native-keyboard-controller/assets/2920419/f3dab2de-6561-4de9-b6b4-4216dc4fd0c2
@owinter86 One thing that I can suggest is to try to call
setupKVObserver/removeKVObserverin different lifecycle methods. Try to replaceKeyboardMovementObserverwith this content:Maybe itβll help π
I have created a new project and its not crashing, but is crashing with a specific project with just that simple example as the entry point. So I guess there is a third party package that is conflicting, lets close this for now and I will look into it more and give a more detailed issue if I find the clash/cause.
The errors I get in sentry are not helpful either
C++ Exception - UISystemKeyboardDockController