Skip to content
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

Android crash: java.lang.IllegalArgumentException: pointerIndex out of range #2689

Closed
bahinskamariia opened this issue Dec 6, 2023 · 6 comments
Labels
Close when stale The issue will be closed automatically if it remains inactive Platform: Android This issue is specific to Android

Comments

@bahinskamariia
Copy link

Description

We have a crash on Android, the stacktrace is provided below.

This patch has already merged as changes to the new version but the issue is still reproducible.

react-native-gesture-handler+2.12.0.patch

Stacktrace

java.lang.IllegalArgumentException: pointerIndex out of range
at android.view.MotionEvent.nativeGetAxisValue(MotionEvent.java)
at android.view.MotionEvent.getY(MotionEvent.java:2445)
at android.widget.ScrollView.onTouchEvent(ScrollView.java:895)
at com.facebook.react.views.scroll.ReactScrollView.onTouchEvent(ReactScrollView.java:460)
at com.swmansion.gesturehandler.core.NativeViewGestureHandler.onHandle(NativeViewGestureHandler.java:113)
at com.swmansion.gesturehandler.core.GestureHandler.handle(GestureHandler.java:374)
at com.swmansion.gesturehandler.core.GestureHandlerOrchestrator.deliverEventToGestureHandler(GestureHandlerOrchestrator.java:276)
at com.swmansion.gesturehandler.core.GestureHandlerOrchestrator.deliverEventToGestureHandlers(GestureHandlerOrchestrator.java:231)
at com.swmansion.gesturehandler.core.GestureHandlerOrchestrator.onTouchEvent(GestureHandlerOrchestrator.java:45)
at com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper.dispatchTouchEvent(RNGestureHandlerRootHelper.java:97)
at com.swmansion.gesturehandler.react.RNGestureHandlerRootView.dispatchTouchEvent(RNGestureHandlerRootView.java:35)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3173)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2823)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3173)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2823)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3173)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2823)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3173)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2823)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3173)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2823)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3173)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2823)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:502)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1890)
at android.app.Activity.dispatchTouchEvent(Activity.java:4195)
at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:70)
at com.dynatrace.android.window.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:79)
at com.contentsquare.android.sdk.cf.dispatchTouchEvent(cf.java:4)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:460)
at android.view.View.dispatchPointerEvent(View.java:14837)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:6617)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:6392)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5866)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5923)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5889)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:6054)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5897)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:6111)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5870)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5923)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5889)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5897)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5870)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8931)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8871)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:8828)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:9063)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:259)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:335)
at android.os.Looper.loopOnce(Looper.java:161)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7888)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)

Steps to reproduce

Possible steps are described here: #1679 (comment)

Snack or a link to a repository

Unknown

Gesture Handler version

2.13.4

React Native version

0.72.6

Platforms

Android

JavaScript runtime

None

Workflow

React Native (without Expo)

Architecture

None

Build type

Release mode

Device

Real device

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Platform: Android This issue is specific to Android Missing repro labels Dec 6, 2023
Copy link

github-actions bot commented Dec 6, 2023

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@bahinskamariia
Copy link
Author

@github-actions
The example provided here:
#1679 (comment)

@m-bert
Copy link
Contributor

m-bert commented Dec 7, 2023

Hi @bahinskamariia! Could you provide more information about device that you're using? This problem should already be fixed by #2551 and it is hard to reproduce it without more information.

@bahinskamariia
Copy link
Author

Hi @m-bert, we faced this issue on production on such devices:
Pixel 7 Pro, Pixel 6, Pixel 6a, Pixel 6 Pro and some others.

@m-bert
Copy link
Contributor

m-bert commented Dec 14, 2023

Hi @bahinskamariia! I've just checked that on Pixel 6 and it works fine - nothing crashes. Also I've checked that on the commit before the solution was merged and it did crash.

Given that, we can't do much unless we get reproduction that actually crashes.

@m-bert m-bert added the Can't repro We can't reproduce this issue label Dec 14, 2023
@latekvo
Copy link
Contributor

latekvo commented Aug 6, 2024

Hello,

we took a look at this issue and it looks NativeViewGestureHandler component which wraps the FlatList is unnecessary, and is the reason for this crash.

Removing it should fix the issue.

Code:

Reproduction code
import React, { useMemo, useState } from 'react';
import {
  Modal,
  StyleSheet,
  Text,
  Pressable,
  View,
  Dimensions,
} from 'react-native';
import Animated from 'react-native-reanimated';
import {
  FlatList,
  GestureHandlerRootView,
  NativeViewGestureHandler,
} from 'react-native-gesture-handler';

const Item = ({ title }: { title: string }) => {
  return (
    <View>
      <Text style={styles.title}>{title}</Text>
    </View>
  );
};

const windowHeight = Dimensions.get('window').height;
export default function Example() {
  const [modalVisible, setModalVisible] = useState(false);

  const data: { id: number; title: string }[] = useMemo(() => {
    const newData = [];

    for (let i = 0; i < 100; i++) {
      newData.push({ id: i, title: `hello - ${i}` });
    }

    return newData;
  }, []);

  return (
    <View style={styles.centeredView}>
      <Modal animationType="slide" transparent={true} visible={modalVisible}>
        <GestureHandlerRootView style={styles.rootContainer}>
          <Animated.View style={styles.animatedContainer}>
            {/* <NativeViewGestureHandler> */}
            <FlatList
              data={data}
              renderItem={({ item }) => <Item title={item.title} />}
              keyExtractor={(item) => item.id.toString()}
            />
            {/* </NativeViewGestureHandler> */}
          </Animated.View>
        </GestureHandlerRootView>
      </Modal>

      <Pressable
        style={[styles.button, styles.buttonOpen]}
        onPress={() => setModalVisible(true)}>
        <Text style={styles.textStyle}>Show Modal</Text>
      </Pressable>
    </View>
  );
}

const styles = StyleSheet.create({
  centeredView: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    marginTop: 22,
  },
  rootContainer: {
    width: '100%',
    height: '100%',
  },
  animatedContainer: {
    backgroundColor: 'white',
    overflow: 'hidden',
    flexShrink: 1,
    width: '100%',
    opacity: 1,

    height: windowHeight / 2,
  },
  button: {
    borderRadius: 20,
    padding: 10,
    elevation: 2,
  },
  buttonOpen: {
    backgroundColor: '#F194FF',
  },
  textStyle: {
    color: 'white',
    fontWeight: 'bold',
    textAlign: 'center',
  },
  title: {
    color: 'white',
    backgroundColor: 'black',
  },
});

@m-bert m-bert added Close when stale The issue will be closed automatically if it remains inactive and removed Can't repro We can't reproduce this issue labels Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Close when stale The issue will be closed automatically if it remains inactive Platform: Android This issue is specific to Android
Projects
None yet
Development

No branches or pull requests

3 participants