Verified
Status Update
Comments
am...@google.com <am...@google.com>
am...@google.com <am...@google.com> #2
Hi,
We have passed this defect on to the development team and will update this issue with more information as it becomes available.
Thanks
We have passed this defect on to the development team and will update this issue with more information as it becomes available.
Thanks
yb...@google.com <yb...@google.com>
ta...@gmail.com <ta...@gmail.com> #3
Thought I should mention for posterity, a temporary workaround is:
mStaggeredGridLayoutManager.setItemPrefetchEnabled(false);
mStaggeredGridLayoutManager.setItemPrefetchEnabled(false);
am...@google.com <am...@google.com> #4
[Comment deleted]
go...@gmail.com <go...@gmail.com> #5
The bug is reproduced on physical device.
1. RecyclerView with GridLayoutManager (3 column)
2. All items has span = 3 (grid look like simple list)
3. Scrolling up and down is working fine
4. Insert items in the middle of the list (All inserted items has span 3 too)
5. call to notifyDataChanged()
6. Grid is expanded with animation
6. Scrolling up and down is failed.
Problem is found after adding android:animateLayoutChanges="true" into a parent layout.
Bug reproducing is stable.
1. RecyclerView with GridLayoutManager (3 column)
2. All items has span = 3 (grid look like simple list)
3. Scrolling up and down is working fine
4. Insert items in the middle of the list (All inserted items has span 3 too)
5. call to notifyDataChanged()
6. Grid is expanded with animation
6. Scrolling up and down is failed.
Problem is found after adding android:animateLayoutChanges="true" into a parent layout.
Bug reproducing is stable.
go...@gmail.com <go...@gmail.com> #6
Bug reproduced id add "android:animateLayoutChanges="true" to list item layout:
RecycleView
--Root Item view layout is: RelativeLayout
----LinearLayout
--------ViewPager
----------Page0: is <LinearLayout... "android:animateLayoutChanges="true".../> <-- this attr is the bug reason
RecycleView
--Root Item view layout is: RelativeLayout
----LinearLayout
--------ViewPager
----------Page0: is <LinearLayout... "android:animateLayoutChanges="true".../> <-- this attr is the bug reason
yb...@google.com <yb...@google.com> #7
You cannot use android:animateLayoutChanges with RecyclerView.
It will try to animate children of the RecyclerView and conflict with the ItemAnimator.
You can still use TransitionManager directly (which that attribute uses) but make sure to exclude RecyclerView's children.
It will try to animate children of the RecyclerView and conflict with the ItemAnimator.
You can still use TransitionManager directly (which that attribute uses) but make sure to exclude RecyclerView's children.
ta...@gmail.com <ta...@gmail.com> #8
Hi, original reporter here. I did not use animateLayoutChanges. See example project in original report.
yb...@google.com <yb...@google.com> #9
sorry for the confusion, i've re-opened the ticket.
pr...@gmail.com <pr...@gmail.com> #10
I face same problem , no solution till now ?
yb...@google.com <yb...@google.com> #11
it is fixed internally, so in the next release it should be fine.
jo...@gmail.com <jo...@gmail.com> #12
public class MyStaggerLayoutManager extends StaggeredGridLayoutManager {
public MyStaggerLayoutManager(int spanCount, int orientation) {
super(spanCount, orientation);
}
public MyStaggerLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public void collectAdjacentPrefetchPositions(int dx, int dy, RecyclerView.State state, LayoutPrefetchRegistry layoutPrefetchRegistry) {
try {
super.collectAdjacentPrefetchPositions(dx, dy, state, layoutPrefetchRegistry);
} catch (IllegalArgumentException e) {
LogUtils.e("catch IllegalArgumentException");
}
}
}
i fixed it by using custom LayoutManager
public MyStaggerLayoutManager(int spanCount, int orientation) {
super(spanCount, orientation);
}
public MyStaggerLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public void collectAdjacentPrefetchPositions(int dx, int dy, RecyclerView.State state, LayoutPrefetchRegistry layoutPrefetchRegistry) {
try {
super.collectAdjacentPrefetchPositions(dx, dy, state, layoutPrefetchRegistry);
} catch (IllegalArgumentException e) {
LogUtils.e("catch IllegalArgumentException");
}
}
}
i fixed it by using custom LayoutManager
st...@googlemail.com <st...@googlemail.com> #13
We have the same problem with version 25.1.0 and made the decision to go back to 25.0.1
am...@google.com <am...@google.com> #14
Issue has been fixed and released in 25.1.1 support lib
ta...@gmail.com <ta...@gmail.com> #15
Version 25.1.1 doesn't seem to solve the issue for me.
My use case could be a little different (maybe easier) from OP's.
1. StaggeredGridLayoutManager with multiple columns (eg. 2)
2. Single item view type - ImageView wrapped in CardView (both layout_width="match_parent", layout_height="wrap_content", ImageView:adjustViewBounds="true")
3. Load 1,000 items, performs image loading with Glide (All images stored on device storage)
4. Flinging the list up and down.
Same exception will be thrown randomly.
PS: As OP suggested, I do StaggeredGridLayoutManager.setItemPrefetchEnabled(false); to prevent the issue from happening.
My use case could be a little different (maybe easier) from OP's.
1. StaggeredGridLayoutManager with multiple columns (eg. 2)
2. Single item view type - ImageView wrapped in CardView (both layout_width="match_parent", layout_height="wrap_content", ImageView:adjustViewBounds="true")
3. Load 1,000 items, performs image loading with Glide (All images stored on device storage)
4. Flinging the list up and down.
Same exception will be thrown randomly.
PS: As OP suggested, I do StaggeredGridLayoutManager.setItemPrefetchEnabled(false); to prevent the issue from happening.
sk...@googlemail.com <sk...@googlemail.com> #16
We still have the problem with 25.1.1 using RecyclerView
java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110) at android.support.v7.widget.LinearLayoutManager.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:1202) at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110) at android.support.v7.widget.LinearLayoutManager.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:1202) at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
cc...@android.com <cc...@android.com> #17
Reopening to investigate repros in 25.1.1
[Deleted User] <[Deleted User]> #18
Another report: we got the same thing on support library 25.1.1
Here is the crash log:
Fatal Exception: java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.GridLayoutManager.collectPrefetchPositionsForLayoutState(GridLayoutManager.java:514)
at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5237)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
Here is the crash log:
Fatal Exception: java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.GridLayoutManager.collectPrefetchPositionsForLayoutState(GridLayoutManager.java:514)
at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5237)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
cc...@android.com <cc...@android.com> #19
#19 and #21 are slightly different from the original issue, since they're from LinearLayoutManager and GridLayoutManager. I see how this may be occurring, and will put in a fix.
As to the case in #18, I'm not sure how StaggeredGridLayoutManager could have these issues in 25.1.1, looking at the code (and scrolling around manually in a 2 column staggered grid), I'm not seeing the issue. Are you sure you're both on 25.1.1, and seeing StaggeredGridLayoutManager in the stack trace?
As to the case in #18, I'm not sure how StaggeredGridLayoutManager could have these issues in 25.1.1, looking at the code (and scrolling around manually in a 2 column staggered grid), I'm not seeing the issue. Are you sure you're both on 25.1.1, and seeing StaggeredGridLayoutManager in the stack trace?
bf...@gmail.com <bf...@gmail.com> #20
Getting the same stacktrace with RecyclerView for support library 25.1.1
Fatal Exception: java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.LinearLayoutManager.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:1202)
at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Fatal Exception: java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.LinearLayoutManager.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:1202)
at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
yu...@gmail.com <yu...@gmail.com> #21
[Comment deleted]
em...@gmail.com <em...@gmail.com> #22
I have the same crash using support lib 25.2.0. Is there a different issue to track this crash from a LinearLayoutManager, looks like it was opened for the StaggeredGridLayoutManager
Pixel distance must be non-negative
java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.LinearLayoutManager.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:1202)
at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Pixel distance must be non-negative
java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.LinearLayoutManager.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:1202)
at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
xl...@gmail.com <xl...@gmail.com> #23
got the same crash with 25.1.1 annd 25.2.0.
here you can find the demo project to reproduce this issue:https://github.com/longerian/VlayoutDemo
here you can find the demo project to reproduce this issue:
bf...@gmail.com <bf...@gmail.com> #24
Faced the same issue with 25.1.1. Fixed it using
StaggeredGridLayoutManager.setItemPrefetchEnabled(false);
or
LinearLayoutManager.setItemPrefetchEnabled(false);
StaggeredGridLayoutManager.setItemPrefetchEnabled(false);
or
LinearLayoutManager.setItemPrefetchEnabled(false);
xl...@gmail.com <xl...@gmail.com> #25
am...@google.com <am...@google.com> #26
The issue is fixed in latest support libraries. If you come across the issue again, please let us know by raising a new issue along with the sample code which reproduces the issue.
Thanks.
Thanks.
Description
Version used: 25.1.0
Theme used: Theme.AppCompat.Light.DarkActionBar
Devices/Android versions reproduced on: Android API 23 AVD emulator, Android 5.1 user devices
- Relevant code to trigger the issue.
The important parts of the code:
1. Uses StaggeredGridLayoutManager with multiple columns.
2. Some of the items are full span: `StaggeredGridLayoutManager.LayoutParams.setFullSpan(true)`
3. Call `RecyclerView.Adapter.notifyItemChanged()` on UI thread (e.g. post delayed Handler)
When running the example app, try flinging the RecyclerView up and down several times. It will eventually force close.
- Stack trace:
java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.StaggeredGridLayoutManager.collectAdjacentPrefetchPositions(StaggeredGridLayoutManager.java:2109)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)