Skip to content
This repository was archived by the owner on Jul 27, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
05e6019
add jitpack yml and needed changes
dratwas Jul 16, 2020
86c8b19
add needed dependencies
dratwas Jul 16, 2020
733fafa
Make Touchable* work with Detox 17 (#1104)
todorone Jul 16, 2020
9321a3b
Update expo links in the Example app (#1131)
adamgrzybowski Jul 17, 2020
b80e959
fix repositories
dratwas Jul 17, 2020
9da6177
Bump lodash from 4.17.11 to 4.17.19 in /Example (#1132)
dependabot[bot] Jul 21, 2020
0b987e4
Bump version to 1.7.0 (#1139)
jgonet Jul 22, 2020
70c9711
Bump lodash from 4.17.15 to 4.17.19 in /docs (#1135)
dependabot[bot] Jul 22, 2020
6718bf3
Update README.md (#1141)
jgonet Jul 22, 2020
d0b8f0c
Fix installation and documentation links (#1144)
kaueDM Jul 22, 2020
df5de67
Fix expo links in docs (#1145)
jgonet Jul 22, 2020
e7e1be9
Bump elliptic from 6.5.2 to 6.5.3 (#1153)
dependabot[bot] Aug 1, 2020
98ae77a
Bump elliptic from 6.5.2 to 6.5.3 in /docs (#1154)
dependabot[bot] Aug 2, 2020
d960294
Bump prismjs from 1.20.0 to 1.21.0 in /docs (#1161)
dependabot[bot] Aug 8, 2020
4e3dd05
Add issue templates (#1165)
jgonet Aug 11, 2020
a2f2186
Upgrade hoist-non-react-statics to 3.3+ (#995)
davidgovea Aug 11, 2020
f8df91b
Fix threading issue in RNGestureHandlerStateChangeEvent (#1171)
jgonet Aug 21, 2020
8e1174b
Fix thread safety of `RNGestureHandlerModule` methods (#1173)
jgonet Aug 24, 2020
486b65c
Removed website directory (#1174)
jgonet Aug 24, 2020
d300474
Increase MAX_POINTERS_COUNT to 12 (#1175)
jgonet Aug 24, 2020
1d23e20
Remove unused `PointerEvents*` enums (#1177)
jgonet Aug 25, 2020
e64d6fc
Fix RNGestureHandlerManager to use explicit imports (#1160)
PeteTheHeat Sep 1, 2020
79ad500
Update yarn.lock, remove fsevents resolutions, add release-it (#1140)
jgonet Sep 3, 2020
e32583d
Bump bl from 4.0.2 to 4.0.3 (#1182)
dependabot[bot] Sep 3, 2020
ecf90a4
Release 1.8.0
jgonet Sep 3, 2020
3639523
Update docs to 0.63 (#1185)
jgonet Sep 7, 2020
b19c218
Add note about `onGestureEvent` in docs (#1189)
jgonet Sep 9, 2020
7edb337
make PressGestureHandler web implementation to pass along the move ev…
connectdotz Sep 22, 2020
0f96ac3
Support RN headers in both namespaces on iOS (#1183)
geraintwhite Sep 30, 2020
e6f1164
Fix GestureHandler isWithinBounds top hitslop (#1202)
eeynard Oct 7, 2020
a94d065
Fix Xcode 12 compatibility (#1193)
radko93 Oct 19, 2020
f77326d
fix: move Swipeable and DrawerLayout type definition (#955)
Naturalclar Oct 19, 2020
8cffaca
Update Detox and XCode CI version to 12 (#1191)
jgonet Nov 3, 2020
7564162
Fix typings for enums (#1055)
iyegoroff Nov 6, 2020
1fc98b6
Add fbjs as dependency (#1226)
jgonet Nov 9, 2020
b8f0c8e
Allow two finger touchpad scrolling on iPadOS (#1128)
robertherber Nov 14, 2020
2fb54e4
Fix wrong github link (#1229)
sunnylqm Nov 15, 2020
bba5e90
Fix broken link in docs (#1230)
hehex9 Nov 17, 2020
196782c
Fix destructuring `ref.props` on the web (#1220)
hosseinmd Nov 17, 2020
19cddc5
Allow minDurationMs=0 in LongPressGestureHandler (#1216)
jacobp100 Nov 17, 2020
6070a36
Add sound to Touchables on Android (#1172)
jgonet Nov 23, 2020
fa96bb0
Release 1.9.0 (#1233)
jgonet Nov 23, 2020
a9c793f
DrawerLayout: add `onDrawerSlide()` (#999)
rorygarand Nov 24, 2020
677d900
Add optional `speed` parameter to open/closeDrawer (#1133)
jeremywho Nov 25, 2020
0b0fabc
Fix interactions with NativeViewGestureHandler (#1034)
ShaMan123 Nov 25, 2020
5696ecc
Resolve version of graceful-fs to ^4.2.4 in Example (#1237)
jgonet Nov 25, 2020
5168af2
Use weak reference for storing rootViews in iOS (#1217)
Norcy Nov 26, 2020
8809501
Organize folder structure (#1199)
jgonet Nov 26, 2020
d66f9b1
Bump handlebars from 4.1.2 to 4.7.6 in /examples/Example (#1240)
dependabot[bot] Nov 26, 2020
0a9fa3b
Update pan handler docs (#1241)
sakshya73 Nov 26, 2020
9e7e643
Remove question & feature request templates (#1259)
jgonet Dec 7, 2020
46e31f8
Bump ini from 1.3.5 to 1.3.7 (#1264)
dependabot[bot] Dec 11, 2020
9a13983
Update Pan & Fling GH's docs (#1252)
sakshya73 Dec 12, 2020
eb34014
Update link to examples in docs (#1271)
gabalafou Dec 12, 2020
190ff1c
Bump ini from 1.3.5 to 1.3.7 (#1272)
jgonet Dec 12, 2020
d2f82d7
Lint src/ directory (#1274)
jgonet Dec 14, 2020
2d7e860
Disable allowedScrollTypesMask in tvOS (#1278)
Dec 15, 2020
9219595
Update issue templates (#1283)
jgonet Dec 23, 2020
40b76ee
Clamp swipe animation in examples (#1290)
mhkeller Dec 28, 2020
1472d12
Improve handlers and state docs (#1289)
jtalz Jan 1, 2021
ddb4a15
Adjust PanGestureHandler docs (#1293)
jtalz Jan 5, 2021
db78d3c
Specify minimal SDK version for enableTrackpadTwoFingerGesture (#1301)
KenCorma Jan 8, 2021
5c9d1ef
Improve docs for TapGestureHandler (#1316)
jtalz Jan 22, 2021
cef917c
Improve wording and add defaults to TapHandler docs (#1325)
jtalz Feb 2, 2021
307c3ad
Improve wording in LongPressGH's docs (#1320)
jtalz Feb 2, 2021
b92df81
Organise docs structure (#1329)
jgonet Feb 5, 2021
080d41e
Fix broken docs links (#1330)
jgonet Feb 5, 2021
8eae2d8
Fix docs' CSS urls (#1331)
jgonet Feb 5, 2021
4d598c1
Update Wix RN Navigation integration steps (#1307)
danilobuerger Feb 5, 2021
8d67924
Rewrite to TS (#1327)
jgonet Feb 8, 2021
614a26b
Improve wording in RotationGH's docs (#1332)
jtalz Feb 8, 2021
b1f260d
Disable declarationMaps (#1333)
jgonet Feb 8, 2021
da75ad2
Release 1.10.0 (#1334)
jgonet Feb 8, 2021
a687733
Move jestSetup.js to root dir (#1337)
jgonet Feb 9, 2021
3a284be
Make release script not fail on no matches (#1339)
jgonet Feb 9, 2021
d6001c3
Use PropsWithChildren in TouchableWithoutFeedback (#1345)
jgonet Feb 10, 2021
34afd6e
Replace import React with import * as React (#1346)
jgonet Feb 10, 2021
d4ed1c6
Keep same extensions on different platforms (#1351)
jgonet Feb 12, 2021
9e84b7b
Fix gestureHandlerRootHOC types (#1347)
alpha0010 Feb 12, 2021
401dcf7
Relax gestureHandlerRootHOC constraint for generic param (#1355)
jgonet Feb 12, 2021
3f4b154
Export all compat *Properties types (#1356)
jgonet Feb 12, 2021
85443c1
Fix conflict markers in doc (#1358)
jgonet Feb 12, 2021
82d2dc6
Rename _handlerTag to handlerTag (#1357)
jgonet Feb 12, 2021
5a97589
Release 1.10.1 (#1359)
jgonet Feb 12, 2021
28b5b98
Adjust Platform constants import (#1211)
drewandre Feb 13, 2021
e7e7577
Lint unlinted files (#1362)
jgonet Feb 13, 2021
6437398
Add Bob (#1360)
jgonet Feb 16, 2021
231103a
Copy Directions enum to JS (#1366)
jgonet Feb 16, 2021
1e7d0b7
Merge branch 'feat/jitpack' of github.com:wordpress-mobile/react-nati…
dratwas Feb 22, 2021
3d08638
update dependencies
dratwas Feb 22, 2021
6c83188
Update to stable 0.64.0
cameronvoell May 13, 2021
e7b44cb
Update react-native mirror location from bintray to S3
cameronvoell May 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix threading issue in RNGestureHandlerStateChangeEvent (software-man…
…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.
  • Loading branch information
jgonet authored Aug 21, 2020
commit f8df91bcc2451569c53791f427a44deee92c568e
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.view.MotionEvent;
import android.view.View;

import com.facebook.react.bridge.UiThreadUtil;

import java.util.Arrays;

public class GestureHandler<T extends GestureHandler> {
Expand Down Expand Up @@ -104,7 +106,12 @@ public T setEnabled(boolean enabled) {
if (mView != null) {
// If view is set then handler is in "active" state. In that case we want to "cancel" handler
// when it changes enabled state so that it gets cleared from the orchestrator
cancel();
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
cancel();
}
});
}
mEnabled = enabled;
return (T) this;
Expand Down Expand Up @@ -326,6 +333,7 @@ public final void handle(MotionEvent origEvent) {
}

private void moveToState(int newState) {
UiThreadUtil.assertOnUiThread();
if (mState == newState) {
return;
}
Expand Down