flexbox-layout: RecyclerView crashing in some circumstances
I have been experimenting with “com.google.android:flexbox:0.3.0-alpha2” with a view to adding it to my photo app as an alternative way of displaying photos. I appreciate that this version is not yet fully stable.
I experience a crash in certain circumstances and report it here in the hope that your testing / debugging can resolve it.
I display a grid of photos and have buttons that enable the user to zoom in or out of the grid. These vary to height of each row. I get a crash on zoom in when the bottom photos are pushed out of view. I’m thinking that there is a confusion between being detached and being recycled. This crash also follows a warning message from View’s requestLayout(). Here’s the log:
03-29 11:47:42.833 21953-21953/com.dpw.photoplayer W/View: requestLayout() improperly called by android.support.v7.widget.AppCompatTextView{3c009ebc V.ED..C. ......ID 6,306-359,363 #7f100199 app:id/photo_text} during layout: running second layout pass
03-29 11:47:42.833 21953-21953/com.dpw.photoplayer W/View: requestLayout() improperly called by android.support.v7.widget.AppCompatTextView{3e090e45 V.ED.... ......ID 170,6-194,63 #7f100197 app:id/photo_count} during layout: running second layout pass
03-29 11:47:42.833 21953-21953/com.dpw.photoplayer W/View: requestLayout() improperly called by android.support.v7.widget.AppCompatImageView{3a92499a V.ED.... ......ID 6,6-552,366 #7f100193 app:id/photo_image} during layout: running second layout pass
03-29 11:47:42.833 21953-21953/com.dpw.photoplayer W/View: requestLayout() improperly called by android.support.v7.widget.AppCompatTextView{9d272cb V.ED..C. ......ID 110,306-448,363 #7f100199 app:id/photo_text} during layout: running second layout pass
03-29 11:47:42.833 21953-21953/com.dpw.photoplayer W/View: requestLayout() improperly called by android.support.v7.widget.AppCompatTextView{2196eaa8 V.ED.... ......ID 267,6-291,63 #7f100197 app:id/photo_count} during layout: running second layout pass
03-29 11:47:42.979 21953-21953/com.dpw.photoplayer E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dpw.photoplayer, PID: 21953
java.lang.IllegalArgumentException: Tmp detached view should be removed from RecyclerView before it can be recycled: ViewHolder{11587ca3 position=3 id=-776809114, oldPos=-1, pLpos:-1 tmpDetached no parent}
at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:5692)
at android.support.v7.widget.RecyclerView.removeAnimatingView(RecyclerView.java:1279)
at android.support.v7.widget.RecyclerView$ItemAnimatorRestoreListener.onAnimationFinished(RecyclerView.java:11518)
at android.support.v7.widget.RecyclerView$ItemAnimator.dispatchAnimationFinished(RecyclerView.java:12018)
at android.support.v7.widget.SimpleItemAnimator.dispatchRemoveFinished(SimpleItemAnimator.java:265)
at android.support.v7.widget.DefaultItemAnimator$4.onAnimationEnd(DefaultItemAnimator.java:209)
at android.support.v4.view.ViewPropertyAnimatorCompatJB$1.onAnimationEnd(ViewPropertyAnimatorCompatJB.java:51)
at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1116)
at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1171)
at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:722)
at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:738)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:549)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
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:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
`
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 2
- Comments: 26 (9 by maintainers)
I appreciate the difficulty. However, I have some good news. I have been continuing to investigate and experiment and have found a way to avoid crashes. To make sure that I get the animations I was using:
notifyItemRangeChanged(0, getItemCount())but have changed to use:notifyDataSetChanged()My app no longer crashes on zoom in, presumably because the way that changes are processed is different. I still get animated changes because I have set:setHasStableIds(true)I still think there is an issue somewhere because I still get the:requestLayout() improperly calledmessage.In my researches I came across the following where another recyclerView layout manager developer was experiencing a similar issue. It’s possible, if you haven’t seen it before, that the discussion may give you some pointers. https://issuetracker.google.com/issues/37098293
I would be happy to let you have access to my app code but in view of the above I suggest the following.
How does that sound?
Glad to be of help!
Yes, the built in layout managers do not crash and do not have the request layout warning.
Don’t hesitate to come back to me if or when you want.