epoxy: Epoxy Recyclerview displays duplicate items that are not in the dataset
I’ve run into an issue that seems to be related to some kind of race condition going on in the Epoxy code.
I’m use a PagedListEpoxyController. I do a lot of rapid updates to the data set and Epoxy is usually great for that given the diffing and everything.
But I seem to run into an issue when I have am editing my data set and quickly requesting new model builds. I edit my data set by copying (using kotlin data classes).
The issue I’m seeing is that the recycler view is displaying items twice even though they aren’t in my data set.
The example is for a messaging app
- I send a message: a new model gets added to my data set with a sending state that is reflected visually on the model view (loader)
- I immediately send another message, new data gets added again
- The first message API call returns, the data gets manipulated so the message is no longer in sending state, view gets updated
- The second message API call returns immediately after, that view gets updated correctly.
The problem is… All the sudden the first set of data that was originally added to my data list is at the bottom of the list. I.E. My first X messages that were loaded when I opened my app are now duplicated below my last 2 messages I just sent.
I debugged and I’m stumped. I verified that the data set I’m feeding to my controller does not contain the duplicates and thus the recycler view is not reflecting my data set. The behavior is not consistent. It seems to happen when calls to loadBefore
in my PageKeyedDataSource (Paging library) get triggered. So I can more easily reproduce if I send multiple messages, scroll up to load more data thru paging. I’ve found the paging library to be kinda finicky so calls to loadBefore can happen a lot.
But even if a lot of calls are being made, I can’t figure out why my RecyclerView would be displaying these duplicate items that are NOT in the data set. I verified this with logs…debugging doesn’t work because it has to do with some kind of race.
Has this issue come up before? The view displaying things that are not in the data set?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 43 (21 by maintainers)
I would also like to point out #567
From what we gathered in that thread it seems to be related with requesting a model build while another one is running.