etsy / AndroidStaggeredGrid

An Android staggered grid view which supports multiple columns with rows of varying sizes.
https://github.com/etsy/AndroidStaggeredGrid
4.76k stars 1.13k forks source link

BadParcelableException being thrown frequently #73

Closed phyora closed 10 years ago

phyora commented 10 years ago

Hi

I am using a FragmentStatePagerAdapter, each page holds a StaggeredGridView. When I am paging through the ViewPager I sometimes get the following Exception:

android.os.BadParcelableException: ClassNotFoundException when unmarshalling: etsy.android.grid.StaggeredGridView$GridListSavedState at android.os.Parcel.readParcelableCreator(Parcel.java:2114) at android.os.Parcel.readParcelable(Parcel.java:2064) at android.os.Parcel.readValue(Parcel.java:1980) at android.os.Parcel.readSparseArrayInternal(Parcel.java:2293) at android.os.Parcel.readSparseArray(Parcel.java:1702) at android.os.Parcel.readValue(Parcel.java:2037) at android.os.Parcel.readMapInternal(Parcel.java:2264) at android.os.Bundle.unparcel(Bundle.java:223) at android.os.Bundle.getSparseParcelableArray(Bundle.java:1237)

This seems to happen randomly for ~10% of my users. Any ideas what's causing this?

phyora commented 10 years ago

I'm still getting this Exception. I even tried removing the onSaveInstanceState and onRestoreInstanceState methods from the StaggeredGridView class but it seems to have made no difference. Quite puzzling. Has no one else run into save state issues?

davejohncole commented 10 years ago

I was getting this exception in another project and stumbled on this:

http://stackoverflow.com/questions/11381470/classnotfoundexception-when-unmarshalling-android-support-v4-view-viewpagersav

Maybe you are seeing a variation of the same thing.

phyora commented 10 years ago

Thanks, despite a thorough search I hadn't found this stackoverflow post before.

I shall attempt the workaround here and report back with my findings: https://code.google.com/p/android/issues/detail?id=37484

Apologies if this turns out to not be a StaggeredGridView issue - it may help others with similar issues in the future if that workaround turns out to work.

phyora commented 10 years ago

@davejohncole Many thanks, I can confirm the FragementStatePagerAdapter bug was the issue. Applying the fix in your link has stopped all exceptions from occurring. I'll close this issue now as it's not applicable to AndroidStaggeredGrid.