Open oakkitten opened 3 years ago
some thoughts & ideas:
what seems to help is; moving RecyclerView
from outside the enclosing RelativeLayout
..¯\_(ツ)_/¯
also, another related issue might be some stuck rows. they are usually semi transparent so must've been abandoned in the process of animation. the animation itself got canceled, but the view wasn't removed or recycled or anything and it just stays there. probably another manifestation of the underlying issue
also, the last crash was mentioned in #459
the issue might happen a tad more rarely now but still exists
apparently this issue affects buffer fragment's RecyclerView
, as reported in #525:
Process: com.ubergeek42.WeechatAndroid, PID: 12400
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 5(offset:-1).state:17 com.ubergeek42.WeechatAndroid.views.AnimatedRecyclerView{e41407a V.ED.V... ......ID 0,0-1080,1722 #7f090054 app:id/chat_lines}, adapter:com.ubergeek42.WeechatAndroid.adapters.ChatLinesAdapter@bc9d02b, layout:androidx.recyclerview.widget.LinearLayoutManager@e9cec88, context:com.ubergeek42.WeechatAndroid.WeechatActivity@4f9e700
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:133)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:9)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:12)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:102)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:59)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:7)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:3)
at android.view.View.layout(View.java:22466)
...
there are a few very rare bugs related to buffer list's
RecyclerView
and its item animator. these bugs has been present in the app for a long time. it is possible to reproduce them, but it takes a bit of effort, even then it's not reliable and can take tens of minutes to reproduce. i could not reproduce these bugs in isolated environment.at this time my best guess is some obscure race condition in the library code. for the first bug to manifest, apparently you have to trigger a change animation, which is then ended by subsequent animation:
DefaultItemAnimator.runPendingAnimations()
then schedules animation using the deleted view holder, which leads to a crash:the holder in question comes from
mPendingChanges
. i gather it shouldn't be there as it must've been removed by something around the call toendChangeAnimationIfNecessary
. so theRecyclerView
is in some bad state. i think this underlying issue causes the other crashes as well.in order of the frequency of appearance, these are:
(ignore the fact that it's a
TextView
above, notbufferlist_item_container
)These can be triggered on current search & master branches by simulating rapid buffer list changes by using this and perhaps by having the following in
WeechatActivity.onHotlistSelected()
: