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: pointerIndex out of range #30320

Closed
luatnd opened this issue Nov 5, 2020 · 17 comments
Closed

Android: pointerIndex out of range #30320

luatnd opened this issue Nov 5, 2020 · 17 comments
Labels

Comments

@luatnd
Copy link

luatnd commented Nov 5, 2020

Description

All I get is crashlytics log, it appears on some users

Fatal Exception: java.lang.IllegalArgumentException: pointerIndex out of range
       at android.view.MotionEvent.nativeGetAxisValue(MotionEvent.java)
       at android.view.MotionEvent.getY(MotionEvent.java:2382)
       at android.widget.ScrollView.onTouchEvent(ScrollView.java:866)
       at com.facebook.react.views.scroll.ReactScrollView.onTouchEvent(ReactScrollView.java:313)
       at android.view.View.dispatchTouchEvent(View.java:13463)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3107)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2763)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView.dispatchTouchEvent(RNGestureHandlerEnabledRootView.java:39)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3113)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2777)
       at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:517)
       at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1869)
       at android.app.Activity.dispatchTouchEvent(Activity.java:3993)
       at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
       at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:475)
       at android.view.View.dispatchPointerEvent(View.java:13727)
       at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5670)
       at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5459)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4958)
       at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5011)
       at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4977)
       at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5117)
       at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4985)
       at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5174)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4958)
       at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5011)
       at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4977)
       at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4985)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4958)
       at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7782)
       at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7751)
       at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7702)
       at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7922)
       at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:188)
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:336)
       at android.os.Looper.loop(Looper.java:174)
       at android.app.ActivityThread.main(ActivityThread.java:7447)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)

React Native version:

System:
    OS: macOS 11.0
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 120.19 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.6.0 - ~/.nvm/versions/node/v12.6.0/bin/node
    Yarn: 1.23.0-20200615.1917 - ~/.yarn/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v12.6.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.1, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
    Android SDK:
      API Levels: 23, 25, 26, 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom_64
      Android NDK: 19.2.5345600
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 12.1/12A7403 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_171 - /usr/bin/javac
    Python: 2.7.17 - /usr/local/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: mobiletechvn/react-native#v0.63.2.fix-shadow-node => 0.63.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

I cannot guess how to reproduce the error

Expected Results

No crash happen

Snack, code example, screenshot, or link to a repository:

N/A

@sudsingh438
Copy link

Facing same issue for past few releases

@AkashBabu
Copy link

BUMP

@ysfzrn
Copy link

ysfzrn commented Mar 11, 2021

+1

@Anujmoglix
Copy link

+1 any update ?

@jcavendish14
Copy link

+1

@ghost
Copy link

ghost commented Jul 7, 2021

Have the same issue, there is a mistake in getY when doing pinch-to-zoom, let me check if I could fix that

@ysfzrn
Copy link

ysfzrn commented Jul 7, 2021

We resolved this issue via writing a patch for react native gesture handler.

"react-native": "0.62.2",
"react-native-gesture-handler": "^1.10.2",

diff --git a/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java b/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java
index 0a39034..257d343 100644
--- a/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java
+++ b/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java
@@ -33,10 +33,17 @@ public class RNGestureHandlerEnabledRootView extends ReactRootView {
 
   @Override
   public boolean dispatchTouchEvent(MotionEvent ev) {
-    if (mGestureRootHelper != null && mGestureRootHelper.dispatchTouchEvent(ev)) {
-      return true;
+    try {
+      if (mGestureRootHelper != null && mGestureRootHelper.dispatchTouchEvent(ev)) {
+        return true;
+      }
+      if (super.dispatchTouchEvent(ev)) {
+        return true;
+      }
+    } catch (IllegalArgumentException e) {
+      e.printStackTrace();
     }
-    return super.dispatchTouchEvent(ev);
+    return false;
   }
 
   /**

Screen Shot 2021-07-07 at 12 27 19

@ghost
Copy link

ghost commented Jul 7, 2021

that's a workaround rather then a fix :)

@ysfzrn
Copy link

ysfzrn commented Jul 7, 2021

yes it is a workaround, temporary solution :(

@gdoudeng
Copy link

+1

@RodolfoGS
Copy link
Contributor

Anyone could fix this issue?

@mrigo
Copy link

mrigo commented Dec 6, 2021

Any news?

felginep added a commit to parti-renaissance/espace-militant that referenced this issue Dec 6, 2021
felginep added a commit to parti-renaissance/espace-militant that referenced this issue Dec 6, 2021
@andrecrimb
Copy link

Having the same issue in production

@RodolfoGS
Copy link
Contributor

RodolfoGS commented Jun 29, 2022

Update:
Sorry, seems that they fixed pointerCount must be at least 1, not pointerIndex out of range

The issue continues.


This issue was fixed in react-native-gesture-handler 2.4.0

Release notes: https://github.com/software-mansion/react-native-gesture-handler/releases/tag/2.4.0
PR: software-mansion/react-native-gesture-handler#1982

@RodolfoGS
Copy link
Contributor

I leave here the patch for react-native-gesture-handler: 2.5.0

react-native-gesture-handler+2.5.0.patch

diff --git a/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt b/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt
index da3098f..4307e18 100644
--- a/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt
+++ b/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt
@@ -34,9 +34,14 @@ class RNGestureHandlerRootView(context: Context?) : ReactViewGroup(context) {
   }
 
   override fun dispatchTouchEvent(ev: MotionEvent) =
-    if (_enabled && rootHelper!!.dispatchTouchEvent(ev)) {
-      true
-    } else super.dispatchTouchEvent(ev)
+    try {
+      if (_enabled && rootHelper!!.dispatchTouchEvent(ev)) {
+        true
+      } else super.dispatchTouchEvent(ev)
+    } catch (e: IllegalArgumentException) {
+      e.printStackTrace()
+      false
+    }
 
   override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {
     if (_enabled) {

@github-actions
Copy link

github-actions bot commented Sep 3, 2023

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Sep 3, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

@Abbondanzo Abbondanzo reopened this Dec 5, 2024
@Abbondanzo Abbondanzo removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests