You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There may be a delay between the change of the source collection and the calls to NotifyItemXXX methods of the adapter, resulting in desynchronizations of the recycler's view and its datasource, thus generating random crashes when the recyclerview try to load a removed item.
Old (and correct) behavior
When an ObservableCollection is structurally updated in a viewmodel, and this collection is bound to the ItemsSource of a RecyclerView's adapter, the adapter subscribes to INotifyCollectionChanged and dispatch these events to NotifyDataSetChanged().
If the viewmodel's collection is changed on a worker thread, the app will crash. But there will be no delay between the change of the collection and the recycler's view notifications.
Current behavior
To prevent crashes when a viewmodel's collection is changed on a worker thread, the adapter posts the change on the MainLooper. This introduces the delay explained at the start of this bug report and leads to random crashes.
if (Looper.MainLooper == Looper.MyLooper())
{
NotifyDataSetChanged(e);
}
else
{
var h = new Handler(Looper.MainLooper);
h.Post(() => NotifyDataSetChanged(e));
}
Reproduction steps
Connect an ObservableCollection to an MvxRecyclerView, add lots of items.
Remove an item every second in your viewmodel from a worker thread (timer)
scroll the list in the app, it will crash at some point.
Configuration
Version: 6.x
Platform:
馃摫 iOS
馃 Android
馃弫 WPF
馃寧 UWP
馃崕 MacOS
馃摵 tvOS
馃悞 Xamarin.Forms
The text was updated successfully, but these errors were encountered:
softlion
changed the title
MvxRecycler view should not post NotifyDataSetChanged on MainLooper
MvxRecycler view must not post NotifyDataSetChanged on MainLooper
Mar 2, 2019
馃敊 Regression
Introduced by the fix for #2144
There may be a delay between the change of the source collection and the calls to NotifyItemXXX methods of the adapter, resulting in desynchronizations of the recycler's view and its datasource, thus generating random crashes when the recyclerview try to load a removed item.
Old (and correct) behavior
When an ObservableCollection is structurally updated in a viewmodel, and this collection is bound to the ItemsSource of a RecyclerView's adapter, the adapter subscribes to INotifyCollectionChanged and dispatch these events to NotifyDataSetChanged().
If the viewmodel's collection is changed on a worker thread, the app will crash. But there will be no delay between the change of the collection and the recycler's view notifications.
Current behavior
To prevent crashes when a viewmodel's collection is changed on a worker thread, the adapter posts the change on the MainLooper. This introduces the delay explained at the start of this bug report and leads to random crashes.
Reproduction steps
Configuration
Version: 6.x
Platform:
The text was updated successfully, but these errors were encountered: