Comments (7)
I have done some testing on the sample app. It occurs regardless of dialog or bottom sheet but only seems to happen with specific use cases within the sample app. For example, it can work in some InfoSheets but not in others. It crashes all sheets in my app.
In the sample app,
- InfoSheet example 1 crashes but the rest do not.
- Lottie Animations example crashes.
- OptionsSheet example '1' crashes but the rest do not.
- None of the ColorSheets crash but it does in my app.
- ClockTimeSheet example crashes.
- All TimeSheets crash (1-7).
- All CalendarSheets crash (1-4).
- All InputSheets crash (1-3).
- The Custom Sheet does not crash.
This is the exception I get when it occurs in my app:
Process: org.bandev.buddhaquotes, PID: 10722
java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = org.bandev.buddhaquotes.fragments.QuoteFragment$onViewCreated$3$1$1)
at android.os.Parcel.writeSerializable(Parcel.java:1833)
at android.os.Parcel.writeValue(Parcel.java:1780)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:928)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1589)
at android.os.Bundle.writeToParcel(Bundle.java:1253)
at android.os.Parcel.writeBundle(Parcel.java:997)
at androidx.fragment.app.FragmentState.writeToParcel(FragmentState.java:127)
at android.os.Parcel.writeTypedObject(Parcel.java:1634)
at android.os.Parcel.writeTypedList(Parcel.java:1513)
at android.os.Parcel.writeTypedList(Parcel.java:1470)
at androidx.fragment.app.FragmentManagerState.writeToParcel(FragmentManagerState.java:58)
at android.os.Parcel.writeParcelable(Parcel.java:1801)
at android.os.Parcel.writeValue(Parcel.java:1707)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:928)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1589)
at android.os.Bundle.writeToParcel(Bundle.java:1253)
at android.os.Parcel.writeBundle(Parcel.java:997)
at android.os.Parcel.writeValue(Parcel.java:1698)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:928)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1589)
at android.os.Bundle.writeToParcel(Bundle.java:1253)
at android.os.Parcel.writeBundle(Parcel.java:997)
at android.os.Parcel.writeValue(Parcel.java:1698)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:928)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1589)
at android.os.Bundle.writeToParcel(Bundle.java:1253)
at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4545)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.io.NotSerializableException: com.maxkeppeler.sheets.options.OptionsSheet
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1240)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1604)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1565)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1488)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1234)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:354)
at android.os.Parcel.writeSerializable(Parcel.java:1828)
at android.os.Parcel.writeValue(Parcel.java:1780)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:928)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1589)
at android.os.Bundle.writeToParcel(Bundle.java:1253)
at android.os.Parcel.writeBundle(Parcel.java:997)
at androidx.fragment.app.FragmentState.writeToParcel(FragmentState.java:127)
at android.os.Parcel.writeTypedObject(Parcel.java:1634)
at android.os.Parcel.writeTypedList(Parcel.java:1513)
at android.os.Parcel.writeTypedList(Parcel.java:1470)
at androidx.fragment.app.FragmentManagerState.writeToParcel(FragmentManagerState.java:58)
at android.os.Parcel.writeParcelable(Parcel.java:1801)
at android.os.Parcel.writeValue(Parcel.java:1707)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:928)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1589)
at android.os.Bundle.writeToParcel(Bundle.java:1253)
at android.os.Parcel.writeBundle(Parcel.java:997)
at android.os.Parcel.writeValue(Parcel.java:1698)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:928)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1589)
at android.os.Bundle.writeToParcel(Bundle.java:1253)
at android.os.Parcel.writeBundle(Parcel.java:997)
at android.os.Parcel.writeValue(Parcel.java:1698)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:928)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1589)
at android.os.Bundle.writeToParcel(Bundle.java:1253)
at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4545)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)```
from sheets.
I couldn't figure out why it wants to serialize the class OptionsSheet (or another) in the first place - and for what reason only specific configurations or sheet types lead to this Exception, while other keep working. Thanks a lot for this issue.
If you have any idea, just let me know. When I have some more free time, I will look into this.
from sheets.
I don't know how the mechanism of lambda serialization works in kotlin, but the problem is serializable listeners on saveInstanceState. Android trying to serialize MainActivity and that's reason why app crashes:
After comment all lines with listeners and icons buttons - all works fine (activity is not destroyed when we go app switcher).
Of course if Activity is destroyed all listeners were gone. (you can simulate that by use split screen).
from sheets.
I tried creating classes for listeners with serializable interfaces and it doesn't work (same error). It still have reference to MainActivity which cannot be serialized. I research some articles about serialization of listeners and people re-registering listeners. I use Material Dialogs(https://github.com/afollestad/material-dialogs) library in my other project and this library doesn't restore sheets after onPause(). Maybe this constraint is the reason why.
I found this description about listener serialization:
The listener variable is a reference to an object instance
reference: https://stackoverflow.com/a/36036818
I think sheets should be recreating by app not library.
from sheets.
That's all I could find as well. It makes sense that listeners are not serializable. However, from a convenience standpoint it certainly would be nice if a dialog or bottom-sheet could recover from a configuration change. :)
I agree with you - I will be removing the auto-restoration of the sheets.
from sheets.
Can you show me the exception that is thrown?
Does this happen with every type of sheet in the sample? (for dialog and bottom-sheet?)
from sheets.
That's interesting. I assume the working examples in the sample just didn't make use of a lambda listener then.
Seems like I have to create wrapper classes that are parcalabe / serializable and pass the lambda functions before adding them to the Bundle.
On the other hand I could just replace them with (functional) interfaces that are parcalabe / serializable, which would save me some additional classes.
I tend to decide for the latter. What do you think?
(Using lambda functions seemed so convenient previously...)
from sheets.
Related Issues (20)
- Color: TextView overlaps SeekBar HOT 2
- Localization: consider using platform resources HOT 1
- onNegative / onPositive support for dynamic drawables
- Text content on OptionSheet HOT 1
- Option constructor with long click listener without specifying sub-text. HOT 2
- Core module leaking colour attributes into consuming applications HOT 1
- make bottom sheet form scrollable HOT 1
- Option customisation support HOT 1
- Cannot use textview on bottomsheet HOT 3
- How to modify the size of the TextView of OptionSheet? HOT 1
- ColorSheet For Jetpack Compose. HOT 4
- CharSequence to the rescue
- Positive button should be invisible or unclickable.
- Custom year range in CalendarSheet HOT 1
- Text/Icons not centered when using OptionSheet as dialog HOT 1
- Upgrade to material 3. HOT 1
- Looping for option sheet HOT 1
- prevent dismiss
- Months Layout
- `rememberSheetState` and `rememberLauncherForActivityResult` not working together in the same page
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sheets.