idanatz / OneAdapter

A Viewholderless Adapter for RecyclerView, who supports builtin diffing, states (paging, empty...), events (clicking, swiping...), and more.
MIT License
470 stars 45 forks source link

IndexOutOfBoundsException: Inconsistency detected #37

Closed vellrya closed 3 years ago

vellrya commented 3 years ago

Hello, thank you again for a wonderful library :)

Seems like one of fixed issue present in 2.0.2 version: https://github.com/ironSource/OneAdapter/issues/3#issue-480093616 + fresh comment.

Issue reproduced many times (but not in 100% of case) when using OneAdapter for search result output. When search query deleted from EditText and all elements set to adapter again, I got following crash:

java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{8d1f079 position=650 id=-982111498, oldPos=0, pLpos:0 scrap [attachedScrap] tmpDetached not recyclable(1) no parent} androidx.recyclerview.widget.RecyclerView{e7fe2ea VFED..C.. ......ID 0,147-1080,1272 #7f0a01db app:id/stickerRV}, adapter:com.idanatz.oneadapter.internal.InternalAdapter@a3ef664, layout:a.b.c.ChatActivity$onCreate$layoutManager$1@13990cd, context:a.b.c.ChatActivity@1d3c1e

java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{1ea3008 position=962 id=-982111498, oldPos=0, pLpos:0 scrap [attachedScrap] tmpDetached not recyclable(1) no parent} androidx.recyclerview.widget.RecyclerView{a1072c1 VFED..C.. ......ID 0,147-1080,1272 #7f0a01db app:id/stickerRV}, adapter:com.idanatz.oneadapter.internal.InternalAdapter@fcde36a, layout:a.b.c.ChatActivity$onCreate$layoutManager$1@3f0505b, context:a.b.c.ChatActivity@ce1c807

I think fast filling and changing data in the adapter can cause this error. Can you check this when you have time? Thanks)

idanatz commented 3 years ago

Hi, The next version will change the internals of how diffing is handled hopefully fixing this issue. Will be released in a few days.

idanatz commented 3 years ago

v2.1.0 is out with different diffing mechanism implementation, hoping it will solve this bug for good. 🤞 please note that the dependency has changed as well due to the deprecation of the current publication, so take a look at the README.