alwx / react-native-photo-view

Pinch-to-zoom view for React Native (both iOS and Android)
MIT License
817 stars 435 forks source link

Android app crashes due to the exception: java.lang.IllegalArgumentException: pointerIndex out of range #15

Open xzdev opened 8 years ago

xzdev commented 8 years ago

Does anyone has the crash problem on Android. Here is my error log:

E/InputEventReceiver(25713): Exception dispatching input event.
E/MtaSDK  (25713): 
E/MtaSDK  (25713): java.lang.IllegalArgumentException: pointerIndex out of range pointerIndex=-1 pointerCount=1
E/MtaSDK  (25713):  at android.view.MotionEvent.nativeGetAxisValue(Native Method)
E/MtaSDK  (25713):  at android.view.MotionEvent.getX(MotionEvent.java:2023)
E/MtaSDK  (25713):  at android.support.v4.view.MotionEventCompatEclair.getX(MotionEventCompatEclair.java:32)
E/MtaSDK  (25713):  at android.support.v4.view.MotionEventCompat$EclairMotionEventVersionImpl.getX(MotionEventCompat.java:110)
E/MtaSDK  (25713):  at android.support.v4.view.MotionEventCompat.getX(MotionEventCompat.java:462)
E/MtaSDK  (25713):  at android.support.v4.view.ViewPager.onInterceptTouchEvent(ViewPager.java:1987)
E/MtaSDK  (25713):  at com.facebook.react.views.viewpager.ReactViewPager.onInterceptTouchEvent(ReactViewPager.java:149)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1951)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
E/MtaSDK  (25713):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
E/MtaSDK  (25713):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2345)
E/MtaSDK  (25713):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1708)
E/MtaSDK  (25713):  at android.app.Dialog.dispatchTouchEvent(Dialog.java:807)
E/MtaSDK  (25713):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2306)
E/MtaSDK  (25713):  at android.view.View.dispatchPointerEvent(View.java:8483)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4291)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4157)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3662)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3715)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3681)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3791)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3689)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3848)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3662)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3715)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3681)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3689)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3662)
E/MtaSDK  (25713):  at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5978)
E/MtaSDK  (25713):  at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5952)
E/MtaSDK  (25713):  at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5923)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6081)
E/MtaSDK  (25713):  at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
E/MtaSDK  (25713):  at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
E/MtaSDK  (25713):  at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
E/MtaSDK  (25713):  at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6039)
E/MtaSDK  (25713):  at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6148)
E/MtaSDK  (25713):  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:793)
E/MtaSDK  (25713):  at android.view.Choreographer.doCallbacks(Choreographer.java:606)
E/MtaSDK  (25713):  at android.vi
E/AndroidRuntime(25713): FATAL EXCEPTION: main
E/AndroidRun

This could be the same Android ViewPager issue. The proposed way is to override onInterceptTouchEvent to catch the exception.

vandervidi commented 8 years ago

@xzdev I get the same crash :( Did you fix this?

alwx commented 8 years ago

@xzdev @vandervidi need to see your code to understand the problem.

waleedarshad-vf commented 8 years ago

Same problem +1

waleedarshad-vf commented 8 years ago

on zooming in and out it just crashed randomly :(

zsajjad commented 8 years ago

Same issue on zooming out to maximum!

juanmanuelarze commented 7 years ago

same here

edencakir commented 7 years ago

same

loiclouvet commented 7 years ago

Same issue

GuillaumeMunsch commented 7 years ago

Same here

Borisboky commented 7 years ago

+1

douglasjunior commented 7 years ago

Same here, only for two Samsung devices.

JonoH commented 6 years ago

+1

JiboStore commented 6 years ago

me too, any solution?

I found this: https://github.com/chrisbanes/PhotoView/issues/293

But I'm not sure how to apply, pretty new to react-native here...

EDIT: probably related to this too: https://github.com/alwx/react-native-photo-view/issues/22 but again, I'm not sure how to apply, it seems to suggest using another component

EDIT2: Figured out the exception was due to bug inside android api and the common accepted workaround was to surround onInterceptTouchEvent with try-catch block. A couple of pull-requests on react-native code base has been done, but none has been accepted yet. Current solution might need to fork the react-native code base, apply the fix, and rebuild.

. https://github.com/facebook/react-native/pull/13166 . https://github.com/facebook/react-native/pull/12085 . https://github.com/facebook/react-native/pull/17167 . https://facebook.github.io/react-native/docs/android-building-from-source.html

carstenhag commented 3 years ago

See https://issuetracker.google.com/issues/143448308, they won't fix it. ViewPager (1) is now also deprecated so move to ViewPager2.