recyclerview-animators icon indicating copy to clipboard operation
recyclerview-animators copied to clipboard

Many "isRecyclable decremented below 0" error logs

Open ypresto opened this issue 8 years ago • 8 comments

04-19 18:39:25.047 967-967/us.mitene.development E/View: isRecyclable decremented below 0: unmatched pair of setIsRecyable() calls for ViewHolder{7325e91 position=213 id=199807, oldPos=-1, pLpos:-1}

Calls to setIsRecyable(false) and setIsRecyable(true) should always be paired according to document.

ypresto avatar Apr 19 '16 09:04 ypresto

+1

I get a lot of these log messages too. The code seems to still work, and no crashes; but something probably isn't right if these are getting spammed.

They haven't always been in my app. They seemed to start happening sometime after I added some more efficient use of notifyItemX() methods; not sure if that has something to do with it or not.

Removing the recyclerview-animator library and usage from my project makes the messages go away. So I am fairly sure it is some interaction with this library that is causing it, just not sure what exactly.

Occurring on Android 6 and 4.4 at least; haven't tested other OS versions yet.

jon-adams avatar May 06 '16 16:05 jon-adams

See http://stackoverflow.com/a/29102232/3142018 for a solution

csbenz avatar Jun 05 '16 22:06 csbenz

@csbenz what's the solution there? Seems unrelated

ZacSweers avatar Jun 06 '16 00:06 ZacSweers

+1

eoinfogarty avatar Jul 07 '16 04:07 eoinfogarty

According to @csbenz, the solution is to set holder.setIsRecyclable(); to false inside onClick method. Remember to set setIsRecyclable(); to true again after the view isn't expanded any more so that android can recycle it. Thank you!

xtonousou avatar Jul 26 '16 03:07 xtonousou

Does anyone have any insight as to how to fix this for animateChangeImpl? I have a viewholder using FastAdapter and toggle its selection. I have nothing extra myself, but disabling isRecyclable, doing the toggle, then reenabling it doesn't remove the error.

AllanWang avatar Apr 18 '17 19:04 AllanWang

Nevermind. I'll post here in case someone else needs it, but animateChange is a replica of the one in DefaultItemAnimator

What was missing was

if (oldHolder == newHolder) {
    // Don't know how to run change animations when the same view holder is re-used.
    // run a move animation to handle position changes.
    return animateMove(oldHolder, fromX, fromY, toX, toY);
}

at the very beginning

AllanWang avatar Apr 18 '17 19:04 AllanWang

I use the FlipInTopXAnimator with an OvershootInterpolator on a screen that user's can filter. I am also using multiple viewTypes. Without the animateMove fix from DefaultItemAnimator, the screen regularly crashes.

keith30xi avatar Jul 06 '17 12:07 keith30xi