-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Android crash: Animated events must have event data. #976
Android crash: Animated events must have event data. #976
Comments
This is also reproducible on |
Great ! Works like a charm thank you !
ᐧ
Le ven. 28 févr. 2020 à 21:55, Valeria <[email protected]> a écrit :
… @ezechielk <https://github.com/ezechielk> I fixed it *temporarily* in my
fork: https://github.com/valeriashpiner/react-native-tab-view
It's one line change there.
You could try it.
I checked it on a few real devices and it seems that everything works well.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#976>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKNG5ZKQJA5D5RMQDIFU3UDRFF24BANCNFSM4K46LQ2A>
.
|
@valeriashpiner I don't use this library, And I got the same error 🤷♂️ Maybe related on |
You could use my fork: https://github.com/valeriashpiner/react-native-tab-view if you need It's one line change there exactly in |
@valeriashpiner Sadly I used |
@anastely Are you able to solve it? Please explain if you have done it. |
@shehzabcodecraft you could use my fork, I fixed it there. |
https://github.com/osdnk/rntv-976 cannot repro. Please provide an example. |
@osdnk I just reproduced it on your repo and recorded video. To reproduce you should scroll the last screen to the right side (to next screen which obviously not exists) and vice versa. It will exist everywhere because it exists in the original example. |
What I'm doing wrong? |
It appears on the real device. It happened with me and also with another ppl in this thread. What the point of proving that you can't reproduce it if I already recorded video from your project that it exists there? @osdnk |
I have no problem with saying that the bug exists. But I’d like to fix it as well and stack trace is not sufficient for debugging |
Okay, @osdnk, sorry for misunderstanding: Steps to reproduce:
Maybe @ezechielk can help to explain more. |
I defined swipeEnabled as false.. so this issue got a workaround |
same problem |
@osdnk It's reproduced by constantly swiping to the left on first tab or to the right on last tab, but I can reproduce it only on prod version of build. So would be nice if you can try to reproduce and maybe fix it |
same here |
You can disable the swipe option. "swipeEnabled" component as false will solve the crash. But after that, you cant swipe between tabs. Instead, you need to tap on the options to open tabs. |
Hi, is there currently a workaround that still allows swiping between tabs? For example, is there a way to catch the erroneous swipes with react-native-gesture-handler? :) |
@avlonder This workaround works, and still allows swiping: I copied it from another fork that fixed it on an older version of react-native-gesture-handler |
Hi guys, @valeriashpiner, @melkayam92, @anastely, @EugeneDraitsev, @svenlombaert can you guys check if this issue still exists on [email protected] and Gesture [email protected]? |
@jakub-gonet oh, I am without android device now (it's not reproducible on a simulator). I hope someone here could help! |
I don't have an android device either, but I reproduced it on [email protected] and [email protected]. From the commits I see in both patches, it would be highly unlikely it got fixed. |
I reproduced it on [email protected] and [email protected]. |
i am still facing this issue, any news? |
I am still facing this issue reproduced in issue with [email protected], [email protected], and [email protected] |
Yes me too.. |
still same issue |
@chgsilva, @raj-upadhyay, @pradnesh-amin, @drb1 this issue is probably related to gesture handler, would really appreciate some reproduction examples. |
As a temporary fix you can replace the pager component with an entirely native one: https://github.com/software-mansion-labs/react-native-tab-view-viewpager-adapter . Thus bypassing the gesture-handler itself. |
hi! |
any updates on this? |
Same issue here. I still did not get the pattern but I have two nested createMaterialTopTabNavigator |
I reproduce on android 10 but not on 9 and lower (physical device with expo and release build). If it helps :'( but #976 (comment) works <3 |
This bug should be fixed in react native gesture handler. This is my patch package file in order to fix the android crash. Hope it will be a useful workaround until they fix it. |
Needs to be fixed. Same issue here |
+1. I hope I'll notice when they patch this. |
In IOS the keyboard opens and closes automatically but works fine if i remove it but for android I should add this as this is working. How should i deal with IOS? |
+1 |
+1 still happening |
## Description This commit fixes a threading issue connected with `enabled` property of gesture handlers. Changing this property in JS called `updateGestureHandler` in the RNGH Java module which in turn called `setEnabled`. `setEnabled` cancels handler by using `cancel()` method if it was in an active state previously. This method was mistakenly called directly from the native modules thread - state transition methods are intended to be called from the UI thread. This made GH orchestrator call `handler.dispatchStateChange()` on the wrong thread. This caused event listeners to receive the event on a non-UI thread (`NodeManager.onEventDispatch()` from Reanimated) via `EventDispatcher`. Reanimated handles non-UI events in `onEventDispatch` (e.g. `onLayout` event) by adding them to the internal queue and posting frame callback if it wasn't posted previously (`onAnimationFrame()` wasn't called). Then any queued event is handled on UI thread in the next frame. Problem is, `EventDispatcher` first calls `onEventDispatch()` of any registered listeners and then runs `maybePostFrameCallbackFromNonUI()` which tries to post frame callback dispatching and disposing events from JS thread. So there was a possibility that we: 1. queue event in `NodeManager.onEventDispatch` in native modules thread 2. handle and **dispose** event in `EventDispatcher`, setting extra data to `null` 3. take the event from the queue and try handling it in the `NodeManager.onAnimationFrame`, raising exception. The solution to that problem is to always run `cancel()` (and any other `stateChange` method) on UI thread. - Fixes react-navigation/react-navigation/issues/6403 - Fixes satya164/react-native-tab-view/issues/976 - Fixes software-mansion/react-native-reanimated/issues/704 ## Test plan Huge thanks to the @midoushitongtong who provided small enough code example which reproduced this issue. ```jsx import * as React from 'react'; import { View, StyleSheet, Dimensions, Text } from 'react-native'; import { TabView, SceneMap } from 'react-native-tab-view'; const FirstRoute = () => ( <View style={[styles.scene, { backgroundColor: '#ff4081' }]}> <Text>aaaaa</Text> <Text>aaaaa</Text> <Text>aaaaa</Text> <Text>aaaaa</Text> <Text>aaaaa</Text> </View> ); const initialLayout = { width: Dimensions.get('window').width }; const InnerTab = () => { const [index, setIndex] = React.useState(0); const [routes] = React.useState([{ key: 'first', title: 'First' }]); const renderScene = SceneMap({ first: FirstRoute, }); return ( <TabView lazy navigationState={{ index, routes }} renderScene={renderScene} onIndexChange={setIndex} initialLayout={initialLayout} /> ); }; export default () => { const [index, setIndex] = React.useState(0); const [routes] = React.useState([ { key: 'a', title: 'a' }, { key: 'b', title: 'b' }, { key: 'c', title: 'c' }, ]); const renderScene = SceneMap({ a: InnerTab, b: InnerTab, c: InnerTab, }); return ( <TabView lazy navigationState={{ index, routes }} renderScene={renderScene} onIndexChange={setIndex} initialLayout={initialLayout} /> ); }; const styles = StyleSheet.create({ scene: { flex: 1, }, }); ``` When swiping rapidly in the first or last tab app crashed. After running `cancel()` on UI thread it stopped crashing. Also made sure that the Example app still works correctly.
I disabled swipe and worked: |
This should be resolved by software-mansion/react-native-gesture-handler#1171 |
This issue is closed, but if I trace the PR from gesture-handler correctly, it was first introduced in version 1.8, while react-native-tab-view currently uses 1.6. |
you can specify the version yourself in the
|
@c-goettert tab-view uses 1.6 but for development (in devDependencies section). RNGH version is actually ruled by your project dependency, as it's listed in peer dependencies. |
@HugoGresse @jakub-gonet thanks for pointing that out! I'll try update gesture handler then. :) |
…sion#1171) ## Description This commit fixes a threading issue connected with `enabled` property of gesture handlers. Changing this property in JS called `updateGestureHandler` in the RNGH Java module which in turn called `setEnabled`. `setEnabled` cancels handler by using `cancel()` method if it was in an active state previously. This method was mistakenly called directly from the native modules thread - state transition methods are intended to be called from the UI thread. This made GH orchestrator call `handler.dispatchStateChange()` on the wrong thread. This caused event listeners to receive the event on a non-UI thread (`NodeManager.onEventDispatch()` from Reanimated) via `EventDispatcher`. Reanimated handles non-UI events in `onEventDispatch` (e.g. `onLayout` event) by adding them to the internal queue and posting frame callback if it wasn't posted previously (`onAnimationFrame()` wasn't called). Then any queued event is handled on UI thread in the next frame. Problem is, `EventDispatcher` first calls `onEventDispatch()` of any registered listeners and then runs `maybePostFrameCallbackFromNonUI()` which tries to post frame callback dispatching and disposing events from JS thread. So there was a possibility that we: 1. queue event in `NodeManager.onEventDispatch` in native modules thread 2. handle and **dispose** event in `EventDispatcher`, setting extra data to `null` 3. take the event from the queue and try handling it in the `NodeManager.onAnimationFrame`, raising exception. The solution to that problem is to always run `cancel()` (and any other `stateChange` method) on UI thread. - Fixes react-navigation/react-navigation/issues/6403 - Fixes satya164/react-native-tab-view/issues/976 - Fixes software-mansion/react-native-reanimated/issues/704 ## Test plan Huge thanks to the @midoushitongtong who provided small enough code example which reproduced this issue. ```jsx import * as React from 'react'; import { View, StyleSheet, Dimensions, Text } from 'react-native'; import { TabView, SceneMap } from 'react-native-tab-view'; const FirstRoute = () => ( <View style={[styles.scene, { backgroundColor: '#ff4081' }]}> <Text>aaaaa</Text> <Text>aaaaa</Text> <Text>aaaaa</Text> <Text>aaaaa</Text> <Text>aaaaa</Text> </View> ); const initialLayout = { width: Dimensions.get('window').width }; const InnerTab = () => { const [index, setIndex] = React.useState(0); const [routes] = React.useState([{ key: 'first', title: 'First' }]); const renderScene = SceneMap({ first: FirstRoute, }); return ( <TabView lazy navigationState={{ index, routes }} renderScene={renderScene} onIndexChange={setIndex} initialLayout={initialLayout} /> ); }; export default () => { const [index, setIndex] = React.useState(0); const [routes] = React.useState([ { key: 'a', title: 'a' }, { key: 'b', title: 'b' }, { key: 'c', title: 'c' }, ]); const renderScene = SceneMap({ a: InnerTab, b: InnerTab, c: InnerTab, }); return ( <TabView lazy navigationState={{ index, routes }} renderScene={renderScene} onIndexChange={setIndex} initialLayout={initialLayout} /> ); }; const styles = StyleSheet.create({ scene: { flex: 1, }, }); ``` When swiping rapidly in the first or last tab app crashed. After running `cancel()` on UI thread it stopped crashing. Also made sure that the Example app still works correctly.
@jakub-gonet Will updating gesture-handler version in package.json fix the crash in production also? |
Yes, it'll fix this issue both in the development and release versions of your app. |
Current behaviour
Android crashes when I scroll to the end of tabs.
It happens all the time on Android.
You scroll to the end and then you try to scroll the last item more and more few times, but it's the last item so app just crashed after few scrolls.
Expected behaviour
Android doesn't have crash when I scroll.
Screenshots (if applicable)
It's only your library in my project which uses reanimated and react-native-gesture-handler together, and it happens on react-native-tab-view components. So I believe, it's related to your library.
What have you tried
I updated react-native-tab-view to 2.13.0.
I updated reanimated to 1.7.0.
I put import 'react-native-gesture-handler' at the top of root file index.js.
Releated issue here
Your Environment
The text was updated successfully, but these errors were encountered: