react-native-gesture-handler: Android Crash: Fatal Exception: java.lang.IllegalArgumentException: pointerIndex out of range

Description

Fatal Exception: java.lang.IllegalArgumentException: pointerIndex out of range
       at android.view.MotionEvent.nativeGetAxisValue(MotionEvent.java)
       at android.view.MotionEvent.getY(MotionEvent.java:2416)
       at android.widget.ScrollView.onTouchEvent(ScrollView.java:866)
       at com.facebook.react.views.scroll.ReactScrollView.onTouchEvent(ReactScrollView.java:323)
       at android.view.View.dispatchTouchEvent(View.java:14309)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3112)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2785)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at com.swmansion.gesturehandler.react.RNGestureHandlerRootView.dispatchTouchEvent(RNGestureHandlerRootView.java:66)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2799)
       at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:488)
       at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1871)
       at android.app.Activity.dispatchTouchEvent(Activity.java:4125)
       at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
       at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:446)
       at android.view.View.dispatchPointerEvent(View.java:14568)
       at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:6022)
       at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5825)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5316)
       at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5373)
       at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5339)
       at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5491)
       at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5347)
       at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5548)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5320)
       at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5373)
       at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5339)
       at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5347)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5320)
       at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8086)
       at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8037)
       at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7998)
       at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:8209)
       at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:220)
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:335)
       at android.os.Looper.loop(Looper.java:183)
       at android.app.ActivityThread.main(ActivityThread.java:7660)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Steps To Reproduce

Unknown

Expected behavior

Graceful error handling

Actual behavior

Crash

Package versions

"react": "~17.0.2",
"react-native": "~0.66.0",
"react-native-gesture-handler": "~1.10.3",

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 22 (6 by maintainers)

Commits related to this issue

Most upvoted comments

I could replicate this crash on the following component by starting a pull-to-refresh with one finger, then adding a second finger during the pull -

The patch at https://github.com/facebook/react-native/issues/30320#issuecomment-875476422 did prevent the crash for me 😃

import {
  RefreshControl as RNRefreshControl,
  RefreshControlProps,
} from 'react-native';
import { FlatList as GestureHandlerFlatList } from 'react-native-gesture-handler';

const ReanimatedFlatList = Animated.createAnimatedComponent(
  GestureHandlerFlatList,
);

const RefreshControl = createNativeWrapper(RNRefreshControl);

const CustomRefreshControl = (props: RefreshControlProps) => (
  <RefreshControl {...props} />
);

...

<ReanimatedFlatList
        ref={flatListRef}
        onScroll={scrollHandler}
        onLayout={(evt: LayoutChangeEvent) => {
          listShellHeight.value = evt.nativeEvent.layout.height;
          if (typeof props.onLayout === 'function') {
            props.onLayout?.(evt);
          }
        }}
        refreshControl={
          <CustomRefreshControl
            refreshing={Boolean(props?.refreshing)}
            progressViewOffset={Number(props?.progressViewOffset ?? 0)}
            onRefresh={() => {
              setRefreshCount(val => val + 1);
              if (typeof onRefresh === 'function') {
                onRefresh();
              }
            }}
          />
        }
        {...props}
      />

@dmregister awesome, thank you so much for your feedback! @j-piasecki looks like your PR is working! Thank you for fixing it

I still having this issue in react-native-gesture-handler: 2.4.2, any update?

Here are a patch but I don’t know if this could generate another issue.

https://github.com/facebook/react-native/issues/30320#issuecomment-875476422