open class NoLeakRecyclerView : RecyclerView {
constructor(context: Context): super(context)
constructor(context: Context, attrs: AttributeSet): super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int): super(context, attrs, defStyleAttr)
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
adapter = null
I'm currently using Epoxy 2.9.0 but it was happening since I'm using it (1.4.0)
Support Library is currently 27.0.2 happening since 25.0.0
I'm currently doing another big release so I will write more if others are appearing. If you have any idea where I should dig let me know. Most similar problems point animations as a problem.
Thanks for the details. From what I have been able to look up it does seem related to animations.
I would look into EpoxyModel#onFailedToRecycleView
- that is the only callback related to cleaning up animations that I know of.
I would guess that this isn't really related to Epoxy, and is a general RecyclerView issue. If you can help pinpoint any areas in Epoxy that could be changed to address it I'm happy to resolve that.
Looking in our own crash reports I see one random occurence of this, which suggests its a random bug. We have a huge amount of Epoxy usage, and I'm surprised we're not seeing it more given how much it is happening to you.
Since one of the crashes happens in the gap worker prefetch you could try setItemPrefetchEnabled(false)
as a palliative bandaid for now
@elihart @vdubedout I have probably more animated items in my app than most mortals on earth. It's a real-time app so we expect lots of insertions, deletions, updates, etc per second. Out of a 145K user base I've found 0 crashes related to recycling (and my users aren't exactly the brightest lights, so if there's a way to crash something they'll find it for sure). If I should guess I would say there's something else causing this.
I've seen Scrapped or attached views may not be recycled
issues twice:
1 - android:animateLayoutChanges
was set to true
on the XML (I guess you said no to this, so we can discard it).
2 - The items have one or more EditText's. If one of them is focused and the Recycler
kicks in to recycle the item then you'll get this kind of exceptions. android:focusableInTouchMode="true"
should fix this when applied to the RecyclerView.
As Eli said, setItemPrefetchEnabled(false)
should help as a palliative for now and should resolve a few of the crashes. Sometimes setHasStableIds(true)
helps as well, but don't know if it would help in your situation. Maybe if we could take a peak at your item(s) layout?
Hi there, thanks for the help.
I don't even animate a lot. Most of the animations are the defaults of epoxy. I've forced to false in xml to see if it changes anything. I use BeginDelayedTransition on the container for other parts. But it should not impact the recyclerView.
I don't have any EditText in my Models
Most of my crashed happen on listviews IN a viewpager (PublicProfile) but not only there.
I'm using Glide to load images in most of them
I try to clear loadings and clicklisteners in most of them
code: https://gist.github.com/vdubedout/0984e7ddcc3d271fd0f29e379db9fd7a
I'm currently working on this bug I would let you know more if I learn something
You can find the app below. It's not available worldwide. You can test it if you locate yourself in france via the search.
https://www.bitrise.io/artifact/4768732/p/d342cabff8da6862fa29e287b3374d2b