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

ArrayIndexOutOfBoundsException in preLayoutChildren() #52

Closed
jenzz opened this issue Feb 12, 2014 · 3 comments · Fixed by #53
Closed

ArrayIndexOutOfBoundsException in preLayoutChildren() #52

jenzz opened this issue Feb 12, 2014 · 3 comments · Fixed by #53
Assignees
Milestone

Comments

@jenzz
Copy link
Contributor

jenzz commented Feb 12, 2014

It looks like when the tops are copied into the bottom,
there is a mismatch in size between
the array src (mColumnTops) and the array dest (mColumnBottoms).

02-11 14:10:48.628  3518  6271 E AndroidRuntime: Caused by: java.lang.ArrayIndexOutOfBoundsException: src.length=3 srcPos=0 dst.length=0 dstPos=0 length=3
02-11 14:10:48.628  3518  6271 E AndroidRuntime:    at java.lang.System.arraycopy(Native Method)
02-11 14:10:48.628  3518  6271 E AndroidRuntime:    at com.etsy.android.grid.StaggeredGridView.preLayoutChildren(StaggeredGridView.java:341)
02-11 14:10:48.628  3518  6271 E AndroidRuntime:    at com.etsy.android.grid.StaggeredGridView.layoutChildren(StaggeredGridView.java:326)
02-11 14:10:48.628  3518  6271 E AndroidRuntime:    at com.etsy.android.grid.ExtendableListView.onLayout(ExtendableListView.java:507)
02-11 14:10:48.628  3518  6271 E AndroidRuntime:    at com.etsy.android.grid.ExtendableListView.updateEmptyStatus(ExtendableListView.java:2040)
02-11 14:10:48.628  3518  6271 E AndroidRuntime:    at com.etsy.android.grid.ExtendableListView.access$1000(ExtendableListView.java:59)
02-11 14:10:48.628  3518  6271 E AndroidRuntime:    at com.etsy.android.grid.ExtendableListView$AdapterDataSetObserver.onChanged(ExtendableListView.java:2078)
02-11 14:10:48.628  3518  6271 E AndroidRuntime:    at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:37)
02-11 14:10:48.628  3518  6271 E AndroidRuntime:    at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
@denizmveli
Copy link
Contributor

@jenzz does PR #53 fix this issue? Can you provide some notes on how you created this error?

@jleidgens
Copy link

We also have this issue in our app. Except for this crash I really like your StaggeredGrid.

Our Stacktrace looks like this:

0   java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
1   at com.etsy.android.grid.StaggeredGridView.getChildTop(StaggeredGridView.java:571)
2   at com.etsy.android.grid.ExtendableListView.fillGap(ExtendableListView.java:1259)
3   at com.etsy.android.grid.ExtendableListView.moveTheChildren(ExtendableListView.java:1233)
4   at com.etsy.android.grid.ExtendableListView.scrollIfNeeded(ExtendableListView.java:1056)
5   at com.etsy.android.grid.ExtendableListView.startScrollIfNeeded(ExtendableListView.java:1020)
6   at com.etsy.android.grid.ExtendableListView.onInterceptTouchEvent(ExtendableListView.java:776)
7   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2060)
8   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
9   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
10  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
11  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
12  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
13  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
14  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
15  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
16  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
17  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
18  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
19  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
20  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
21  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
22  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
23  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
24  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
25  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
26  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2139)
27  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1476)
28  at android.app.Activity.dispatchTouchEvent(Activity.java:2487)
29  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2087)
30  at android.view.View.dispatchPointerEvent(View.java:7535)
31  at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3415)
32  at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3347)
33  at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4456)
34  at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4434)
35  at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4538)
36  at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
37  at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
38  at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:163)
39  at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4506)
40  at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4557)
41  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
42  at android.view.Choreographer.doCallbacks(Choreographer.java:555)
43  at android.view.Choreographer.doFrame(Choreographer.java:523)
44  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
45  at android.os.Handler.handleCallback(Handler.java:615)
46  at android.os.Handler.dispatchMessage(Handler.java:92)
47  at android.os.Looper.loop(Looper.java:137)
48  at android.app.ActivityThread.main(ActivityThread.java:4921)
49  at java.lang.reflect.Method.invokeNative(Native Method)
50  at java.lang.reflect.Method.invoke(Method.java:511)
51  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
52  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
53  at dalvik.system.NativeStart.main(Native Method)

It happens on screen rotation on tablets I suspect it only happens if not enough items are available to fill the screen. But I can't reproduce this always.

@jenzz
Copy link
Contributor Author

jenzz commented Feb 18, 2014

@denizmveli #53 seems to fix the issue. I haven't seen the crash again since using that fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants