-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Occasional crash when expanding/collapsing group while updateAsync is running #286
Comments
I guess this will also happen when you write an adapter in a normal way and try to mess it up (calling notify...()) while it's dispatching its diffResult. Maybe there is a workaround like: disable all interactions with the Items when we begin updating and enable back via https://github.com/lisawray/groupie/blob/master/library/src/main/java/com/xwray/groupie/OnAsyncUpdateListener.java |
@khatv911 Yeah, I imagine there could be other cases like that that can trigger this crash too. Yeah I guess a workaround like disabling all interactions while the update is running could work, though that might not be an ideal solution in itself as updating the list can be triggered in the background so users would be clueless why their actions are ignored sometimes. |
@scorpeeon i agree that it could be a race cond. though the name is async..., what is done in background is calculating DiffResult while dispatching that result is still in ui thread. in my project, i already gave up expandablegroup and rebuild the whole list even when only one group needs expanding as a trade-off. |
That's an interesting approach. I wonder how you handle expanding/collapsing items without ExpandableGroup, especially animations. Also if you don't need ExpandableGroup, I guess you might as well just use a ListAdapter.. |
expandablegroup doesn’t involve any animations. it just purely call notifyItemRemoved and notifyItemAdded. the animations you see is from RecyclerView#ItemAnimator. So implement a effective DiffUtil will result the same. |
for collapsed/ expanded state, i had to store in a map. it actually the same approach when you handle checkboxes |
Describe the bug
When GroupAdapter.updateAsync() keeps getting called in the background and I click expand/collapse on an expandable item, occasionally I get a crash.
To Reproduce
I forked the project and created a branch with a modified example to reproduce the bug: https://github.com/scorpeeon/groupie/tree/updateasync-expandable-bug
Steps to reproduce the behavior:
When starting the example (non-databinding) the code will keep calling updateAsync to update the items. Meanwhile if I keep tapping the expand/collapse button on the expandable item, the code will eventually crash. (it might take a while for it to happen, tapping it rapidly tend to give faster results)
Expected behavior
Code should not crash when expanding items while using updateAsync.
Library version
2.5.1
Additional context
Example stacktraces here:
Another one:
The text was updated successfully, but these errors were encountered: