-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConcurrentModificationException crash on Android #5822
Comments
Hi @Vepsur, thanks for reporting this issue. It looks like something related to |
Here are a few updates about the behavior of the crash:
And I will try to create a separate reproduction repository for that issue |
Here are a few updates about the behavior of the crash:
|
Hi, I posted PR (#5918) that should fix that. Let me know if it helps. |
I checked it in the repo repository and in our project, it seems like it resolved this issue. Thanks! |
## Summary Fixes #5822 To keep track of all listeners we use hash map, and notify changes on all of them. When quickly opening flat list with components that use useAnimatedKeyboard and focus on some keyboard, the flat list is still adding new components (adding new listeners), while listeners are notified in the loop about the changes to the keyboard height. Changing HashMap to ConcurrentHashMap seems to fix the issue. |Before|After| |-|-| |<video src="https://github.com/software-mansion/react-native-reanimated/assets/11800297/66d26b5e-3e81-492b-b692-50d63bc4ca0e" />|<video src="https://github.com/software-mansion/react-native-reanimated/assets/11800297/bca99310-d4e1-4cfa-a83b-de3872c93f47" />| ## Test plan <details> <summary>Test component</summary> ```jsx import React from 'react'; import { FlatList, SafeAreaView, StyleSheet, TextInput, View, } from 'react-native'; import {useAnimatedKeyboard} from 'react-native-reanimated'; function Card() { useAnimatedKeyboard(); return ( <View style={StyleSheet.flatten({ width: '100%', height: 100, backgroundColor: 'black', marginVertical: 4, })} /> ); } export default function ProfileScreen() { const array = Array(1000).fill(0); const renderHeader = () => ( <View> <TextInput numberOfLines={10} placeholder="text input" style={StyleSheet.flatten({width: '100%', height: 500, borderWidth: 2})} /> </View> ); return ( <SafeAreaView style={StyleSheet.flatten({padding: 16})}> <FlatList keyboardShouldPersistTaps="always" data={array} renderItem={() => <Card />} ListHeaderComponent={renderHeader} /> </SafeAreaView> ); } ``` </details>
Description
I got a crash error in my Sentry in the production version of the app on Android
Sentry report:
ConcurrentModificationException java.util.HashMap$HashIterator in nextNode
mechanism: UncaughtExceptionHandler
Stack trace:
I faced this bug in the dev environment. I solved it in debug mode on my Android via the created async hook, which waits while the keyboard closes and only then navigates to another screen.
But I got the error in my Sentry after releasing a new version with fixes, so I missed something.
P.S. I also suggest that can be related to react-native-keyboard-controller or react-native-screens enableFreeze(true) and will continue my investigation
22-mar updates:
5-apr updates:
useAnimatedKeyboard
hook inside the items ofFlatList
Steps to reproduce
Tap on the
Navigate to profile
buttonImmediately after navigation, tap on text input
The app should crash most of the time
Tap on the
Navigate to profile
buttonAfter navigation, tap on text input
While the keyboard is open, try scrolling
FlatList
The app should crash often enough
Snack or a link to a repository
reanimated-android-crash-example
Reanimated version
3.8.0
React Native version
0.72.6
Platforms
Android
JavaScript runtime
Hermes
Workflow
React Native
Architecture
Paper (Old Architecture)
Build type
Release app & production bundle
Device
Real device
Device model
No response
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: