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

BadParcelableException still exists in v1.2.0 #28

Closed
nickstamp93 opened this issue Dec 17, 2018 · 9 comments
Closed

BadParcelableException still exists in v1.2.0 #28

nickstamp93 opened this issue Dec 17, 2018 · 9 comments
Assignees
Labels
Milestone

Comments

@nickstamp93
Copy link

nickstamp93 commented Dec 17, 2018

Caused by android.os.BadParcelableException ClassNotFoundException when unmarshalling: android.support.design.stateful.ExtendableSavedState android.os.Parcel.readParcelableCreator (Parcel.java:2326) android.os.Parcel.readParcelable (Parcel.java:2276) android.view.AbsSavedState.<init> (AbsSavedState.java:57) android.view.View$BaseSavedState.<init> (View.java:20245) com.andremion.counterfab.CounterFab$SavedState.<init> (CounterFab.java:306) com.andremion.counterfab.CounterFab$SavedState.<init> (CounterFab.java:291) com.andremion.counterfab.CounterFab$SavedState$1.createFromParcel (CounterFab.java:343) com.andremion.counterfab.CounterFab$SavedState$1.createFromParcel

@andremion
Copy link
Owner

andremion commented Jan 4, 2019

@nickstamp93, I'm not able to reproduce it.
I tried in 16, 22, 28 and it was not reproduced...

@sebaslogen
Copy link

We experienced the crash again in production using library version 1.2.0

Fatal Exception: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.google.android.material.stateful.ExtendableSavedState
       at android.os.Parcel.readParcelableCreator(Parcel.java:2432)
       at android.os.Parcel.readParcelable(Parcel.java:2358)
       at android.view.AbsSavedState.<init>(AbsSavedState.java:57)
       at android.view.View$BaseSavedState.<init>(View.java:21468)
       at com.andremion.counterfab.CounterFab$SavedState.<init>(CounterFab.java:306)
       at com.andremion.counterfab.CounterFab$SavedState.<init>(CounterFab.java:291)
       at com.andremion.counterfab.CounterFab$SavedState$1.createFromParcel(CounterFab.java:343)
       at com.andremion.counterfab.CounterFab$SavedState$1.createFromParcel(CounterFab.java:336)
       at android.os.Parcel.readParcelable(Parcel.java:2365)
       at android.os.Parcel.readValue(Parcel.java:2264)
       at android.os.Parcel.readSparseArrayInternal(Parcel.java:2675)
       at android.os.Parcel.readSparseArray(Parcel.java:1967)
       at android.os.Parcel.readValue(Parcel.java:2321)
       at android.os.Parcel.readArrayMapInternal(Parcel.java:2614)
       at android.os.BaseBundle.unparcel(BaseBundle.java:221)
       at android.os.Bundle.getSparseParcelableArray(Bundle.java:856)
       at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1361)
       at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2646)
       at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2416)
       at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372)
       at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
       at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
       at android.os.Handler.handleCallback(Handler.java:743)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:171)
       at android.app.ActivityThread.main(ActivityThread.java:5417)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I can't reproduce manually but these are the devices from customers that experienced the crash:

  • Xiaomi - Redmi Note 4 - Android 6.0
  • ZTE - Zmax Pro - Android 6.0.1

@andremion
Copy link
Owner

@sebaslogen, are you sure they are using the app with the latest version of the library?
I still can't reproduce it...
😕

@sebaslogen
Copy link

@andremion, yes the release includes v1.2.0 of this lib

@nickstamp93
Copy link
Author

I also confirm that the library included in my production app is v1.2.0

@svinouze
Copy link

svinouze commented Jan 9, 2019

Hi guys! I confess i'm not using this library but bumped into this thread while looking for answers as I have the same issue (using also a custom FloatingActionButton with save state implementation).
As for me it's easy to reproduce when you know how to do it: just turn on the don't keep activity option in your developer tools then pause and resume the activity that holds the FAB. It will crash while restoring state.
I tried the implementation you did while patching the issue with the ClassLoaderCreator. It then works above Nougat but fails under it as it tries to use the class which should not be called under Nougat.
i've reverted design library to 27.1.1 unfortunately but will keep an eye for a solution. But I suppose the fix will come only when migrating to Jetpack as they said 28.0.0 is the last version for the support library...

@andremion
Copy link
Owner

Hey guys,
Sorry for the delayed answer.
I just fixed it and it will release in 1.2.1 together with the migration to AndroidX
Thanks for report it.

@andremion andremion self-assigned this Feb 3, 2019
@andremion andremion added this to the v1.2.1 milestone Feb 3, 2019
@andremion
Copy link
Owner

I appreciate if you get me a feedback of this fixing when you have time to use it.
Thanks.

@svinouze
Copy link

Just tested it, all good for me :)
As an optim I would suggest to reuse the super state when saving instead of recreating an ExtendableSavedState

@Override
    public Parcelable onSaveInstanceState() {
        Parcelable state = super.onSaveInstanceState();
        if (state instanceof ExtendableSavedState) {
            Bundle bundle = new Bundle();
            bundle.putInt(COUNT_STATE, mCount);
            ((ExtendableSavedState) state).extendableStates.put(STATE_KEY, bundle);
        }
        return state;
    }

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

No branches or pull requests

4 participants