woocommerce / woocommerce-android

WooCommerce Android app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
277 stars 135 forks source link

IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling androidx.recyclervi... #5377

Closed sentry-io[bot] closed 2 years ago

sentry-io[bot] commented 2 years ago

Sentry Issue: WOOCOMMERCE-ANDROID-2EQ

IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling androidx.recyclerview.widget.RecyclerView{b760ee3 VFED..... ......I. 0,279-1080,1200 #7f0a0592 app:id/productTagsRecycler}, adapter:com.woocommerce.android.ui.products.tags.ProductTagsAdapter@cfc04a6, layout:androidx.recyclerview.widget.LinearLayoutManager@f1cbee7, context:dagger.hilt.android.internal.managers.ViewComponentManager$FragmentContextWrapper@4ace8d5
    at com.woocommerce.android.ui.products.tags.ProductTagsAdapter.setProductTags(ProductTagsAdapter.kt:62)
    at com.woocommerce.android.ui.products.tags.ProductTagsFragment.showProductTags(ProductTagsFragment.kt:178)
    at com.woocommerce.android.ui.products.tags.ProductTagsFragment.setupObservers$lambda-4(ProductTagsFragment.kt:152)
    at com.woocommerce.android.ui.products.tags.ProductTagsFragment.lambda$V3Twk4e2IPgaxlYF3qGufxO70Lw
    at com.woocommerce.android.ui.products.tags.-$$Lambda$ProductTagsFragment$V3Twk4e2IPgaxlYF3qGufxO70Lw.onChanged
...
(118 additional frame(s) were not displayed)
wzieba commented 2 years ago

I'm not sure why this crash popped out in 7.6-rc-2 but I believe it might be easy to fix with:

  1. Changing ProductTagsAdapter to override from androidx.recyclerview.widget.ListAdapter so diff will be computed on the background thread
  2. Simplify ProductTagsAdapter#setProductTags - I think it could have only one line that delegates all diff calculations to DiffUtil#calculateDiff