Skip to content
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

New RecyclerView Grouping crash on Clear/Insert sequence #1640

Closed
thefex opened this issue Mar 6, 2017 · 12 comments
Closed

New RecyclerView Grouping crash on Clear/Insert sequence #1640

thefex opened this issue Mar 6, 2017 · 12 comments
Milestone

Comments

@thefex
Copy link
Contributor

thefex commented Mar 6, 2017

New RecyclerView Grouping feature crashes when ObservableCollection is Cleared and then some items are inserted.
It crashes with RecyclerView viewholder incosistency.
Preparing fix.

@thefex
Copy link
Contributor Author

thefex commented Mar 7, 2017

I have implemented support for Group Child collection INotifyCollectionChanged event supports (add/remove/reset) - dynamic group childs collection.

Turns out that crashes was not a bug in grouping implementation.
Support Library RecyclerView has crash bug - https://code.google.com/p/android/issues/detail?id=77846#c10. It says it's fixed - bullshit (check comments). That bug have crashed my app when I was using grouping. I think it has showed with grouping because there are a lot of Insert/Remove sequence operations.

I will push dynamic child support + crash workaround in a moment.

@thefex
Copy link
Contributor Author

thefex commented Mar 7, 2017

Pushed pull request with RecyclerView crashes.
I will add INotifyCollectionChanged of Group Child collection support in separate issue.

@Nickolas-
Copy link
Contributor

Hi got the same exceptions , but the problem was with not properly dispatching event. Did you check it ?

@thefex
Copy link
Contributor Author

thefex commented Mar 8, 2017

it's not an issue with "event dispatching". It just crash with normal ObservableCollection - easy to reproduce when a lot of Remove/Insert sequence calls are made.
Check google issue I have mentioned.

@Nickolas-
Copy link
Contributor

Are you using MvxObservableCollection ? I guess you dispatching event not on UI thread.

@kjeremy
Copy link
Contributor

kjeremy commented Mar 8, 2017 via email

@thefex
Copy link
Contributor Author

thefex commented Mar 8, 2017

I am using RX DynamicData and I do the thing on UI thread. Well if it was UI thread issue the exception would not be IndexOfOutBoundsException + it would always crash (it does not always crash, just sometimes when Clear + Add is called).

That's the backend(PCL) code which manages list by the way:
searchEventObservable .SelectMany(async x => await GetItemsWithSearchFilter(0, x)) .ObserveOn(SynchronizationContext.Current) .Subscribe(items => { ItemsSource.Clear(); ItemsSource.AddRange(items); RecentSearchResultCount = items.Count(); })

I always Observe on SynchronizationContext.Current (UI thread) so it is impossible.

@Nickolas-
Copy link
Contributor

ObservableCollection not thread safe, so maybe you are invoking insert , remove from different thread that can cause this issues.

@thefex
Copy link
Contributor Author

thefex commented Mar 8, 2017

I don't, I use RX DynamicData and I always, explictly specify that things related to collection modification should be invoked on Current SynchronizationContext which is in fact UI thread.
Crashes and stack trace indicates that this bug is caused by issue reported on google tracker. Also - workaround described in tracker works fine - if it was UI thread issue i wouldn't see filled, working lists in my app.

@thefex
Copy link
Contributor Author

thefex commented Mar 8, 2017

I guess I have to implement reproduction sample so you will start to believe that something is fucked up with recyclerview. Will do it and ping you back - but not earlier than on weekend

@kjeremy
Copy link
Contributor

kjeremy commented Mar 8, 2017 via email

@Nickolas-
Copy link
Contributor

if you have a test project , I could take a look , what's happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants