zhanghai / AndroidFastScroll

Fast scroll for Android RecyclerView and more
https://play.google.com/store/apps/details?id=me.zhanghai.android.fastscroll.sample
Apache License 2.0
703 stars 64 forks source link

java.lang.IndexOutOfBoundsException #41

Closed enricocid closed 2 years ago

enricocid commented 2 years ago

Just came accross this on play dev console. Actually, I don't know how to fix this or how to reproduce. Don't have empty list in my library.

Hope you can mitigate this issue in the lib itself.

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

java.lang.IndexOutOfBoundsException: |   |   |   |   -- | -- | -- | -- | -- at java.util.ArrayList.get (ArrayList.java:437) |   |   |   at androidx.recyclerview.widget.RecyclerView.dispatchOnScrollStateChanged (RecyclerView.java) at androidx.recyclerview.widget.RecyclerView.setScrollState (RecyclerView.java) |   at androidx.recyclerview.widget.RecyclerView.stopScrollersInternal (RecyclerView.java) |   at androidx.recyclerview.widget.RecyclerView.stopScroll (RecyclerView.java) |   at me.zhanghai.android.fastscroll.RecyclerViewHelper.scrollTo (RecyclerViewHelper.java) |   at me.zhanghai.android.fastscroll.FastScroller.scrollToThumbOffset (FastScroller.java) |   at me.zhanghai.android.fastscroll.FastScroller.onTouchEvent (FastScroller.java) |   at me.zhanghai.android.fastscroll.FastScroller$InternalSyntheticLambda$1$c3ba0337591b746a24a8e3c1726bb8f9d2ca41c1534fc77679212ad973b1a63d$3.test (FastScroller.java) at me.zhanghai.android.fastscroll.RecyclerViewHelper$3.onInterceptTouchEvent (RecyclerViewHelper.java:2) at androidx.recyclerview.widget.RecyclerView.findInterceptingOnItemTouchListener (RecyclerView.java:22) at androidx.recyclerview.widget.RecyclerView.dispatchToOnItemTouchListeners (RecyclerView.java) at androidx.recyclerview.widget.RecyclerView.onTouchEvent (RecyclerView.java) |   at android.view.View.dispatchTouchEvent (View.java:15076) |   |   at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3917) |   at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3581) |   |   at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3923) |   at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3597) |   |   at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3923) |   at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3597) |   |   at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3923) |   at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3597) |   |   at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3923) |   at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3597) |   |   at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3923) |   at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3597) |   |   at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3923) |   at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3597) |   |   at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3923) |   at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3597) |   |   at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3923) |   at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3597) |   |   at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3923) |   at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3597) |   |   at com.android.internal.policy.DecorView.superDispatchTouchEvent (DecorView.java:1015) at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1962) at android.app.Activity.dispatchTouchEvent (Activity.java:4265) |   |   at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:2) at com.android.internal.policy.DecorView.dispatchTouchEvent (DecorView.java:973) |   at android.view.View.dispatchPointerEvent (View.java:15335) |   |   at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:7794) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:7567) at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:6901) |   at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:6958) |   at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:6924) |   at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:7122) |   at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:6932) |   |   at android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:7179) |   at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:6905) |   at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:6958) |   at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:6924) |   at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:6932) |   |   at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:6905) |   at android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:10354) |   at android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:10202) |   at android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:10158) |   at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:10486) at android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:259) |   at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents (Native Method) |   at android.view.InputEventReceiver.consumeBatchedInputEvents (InputEventReceiver.java:239) at android.view.ViewRootImpl.doConsumeBatchedInput (ViewRootImpl.java:10434) |   at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run (ViewRootImpl.java:10575) at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1108) |   at android.view.Choreographer.doCallbacks (Choreographer.java:866) |   |   at android.view.Choreographer.doFrame (Choreographer.java:789) |   |   at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1092) at android.os.Handler.handleCallback (Handler.java:938) |   |   |   at android.os.Handler.dispatchMessage (Handler.java:99) |   |   |   at android.os.Looper.loopOnce (Looper.java:226) |   |   |   at android.os.Looper.loop (Looper.java:313) |   |   |   at android.app.ActivityThread.main (ActivityThread.java:8663) |   |   at java.lang.reflect.Method.invoke (Native Method) |   |   |   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:567) |   at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1135) |   |  

zhanghai commented 2 years ago

The crash happened in RecyclerView.stopScroll() which should never crash as long as it's called on main thread (which it is in this case), so I don't think it is an issue of this library. I believe this is more likely either an issue with RecyclerView, or your adapter (e.g. the way it handles data changes).