Repository: wdullaer/MaterialDateTimePicker

Issue #349: IOException after updating from 3.0.0 to 3.2.0
Created: 2017-05-08T05:32:25Z
Hello, I encounter this exception after updating from 3.0.0 to 3.2.0. Some of my app user experienced it and I haven't able to reproduce it myself. (log taken from fabric)
Fatal Exception: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.wdullaer.materialdatetimepicker.date.DefaultDateRangeLimiter)
       at android.os.Parcel.writeSerializable(Parcel.java:1394)
       at android.os.Parcel.writeValue(Parcel.java:1341)
       at android.os.Parcel.writeArrayMapInternal(Parcel.java:644)
       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313)
       at android.os.Bundle.writeToParcel(Bundle.java:1034)
       at android.os.Parcel.writeBundle(Parcel.java:669)
       at android.app.FragmentState.writeToParcel(Fragment.java:144)
       at android.os.Parcel.writeTypedArray(Parcel.java:1197)
       at android.app.FragmentManagerState.writeToParcel(FragmentManager.java:381)
       at android.os.Parcel.writeParcelable(Parcel.java:1363)
       at android.os.Parcel.writeValue(Parcel.java:1268)
       at android.os.Parcel.writeArrayMapInternal(Parcel.java:644)
       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313)
       at android.os.Bundle.writeToParcel(Bundle.java:1034)
       at android.os.Parcel.writeBundle(Parcel.java:669)
       at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3232)
       at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3653)
       at android.os.Handler.handleCallback(Handler.java:815)
       at android.os.Handler.dispatchMessage(Handler.java:104)
       at android.os.Looper.loop(Looper.java:194)
       at android.app.ActivityThread.main(ActivityThread.java:5763)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by java.io.NotSerializableException: com.wdullaer.materialdatetimepicker.date.DatePickerDialog
       at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
       at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
       at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
       at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
       at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
       at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
       at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
       at android.os.Parcel.writeSerializable(Parcel.java:1389)
       at android.os.Parcel.writeValue(Parcel.java:1341)
       at android.os.Parcel.writeArrayMapInternal(Parcel.java:644)
       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313)
       at android.os.Bundle.writeToParcel(Bundle.java:1034)
       at android.os.Parcel.writeBundle(Parcel.java:669)
       at android.app.FragmentState.writeToParcel(Fragment.java:144)
       at android.os.Parcel.writeTypedArray(Parcel.java:1197)
       at android.app.FragmentManagerState.writeToParcel(FragmentManager.java:381)
       at android.os.Parcel.writeParcelable(Parcel.java:1363)
       at android.os.Parcel.writeValue(Parcel.java:1268)
       at android.os.Parcel.writeArrayMapInternal(Parcel.java:644)
       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313)
       at android.os.Bundle.writeToParcel(Bundle.java:1034)
       at android.os.Parcel.writeBundle(Parcel.java:669)
       at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3232)
       at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3653)
       at android.os.Handler.handleCallback(Handler.java:815)
       at android.os.Handler.dispatchMessage(Handler.java:104)
       at android.os.Looper.loop(Looper.java:194)
       at android.app.ActivityThread.main(ActivityThread.java:5763)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Here's my code:
final int year = CALENDAR.get(Calendar.YEAR);
                final int month = CALENDAR.get(Calendar.MONTH);
                final int date = CALENDAR.get(Calendar.DATE);

                final DatePickerDialog dialog = DatePickerDialog.newInstance(new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePickerDialog view, int i, int i1, int i2) {
                        CALENDAR.set(i, i1, i2);
                        tanggal.setText(Helper.getReadableDate(CALENDAR));
                    }
                }, year, month, date);

                dialog.setMinDate(Helper.getTomorrowDate());
                dialog.show(getBaseActivity().getFragmentManager(), "datepicker");

Duplicate issue #351: DefaultDateRangeLimiter not Serializable
Created: 2017-05-10T11:36:14Z
Observing crashes when sending an app to background when DatePickerDialog is active and the platform is writing the DialogFragment to a Bundle while storing fragment backstack state. Stacktrace:
java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.wdullaer.materialdatetimepicker.date.g)
	at android.os.Parcel.writeSerializable(Parcel.java:1527)
	at android.os.Parcel.writeValue(Parcel.java:1475)
	at android.os.Parcel.writeArrayMapInternal(Parcel.java:724)
	at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1408)
	at android.os.Bundle.writeToParcel(Bundle.java:1157)
	at android.os.Parcel.writeBundle(Parcel.java:764)
	at android.app.FragmentState.writeToParcel(FragmentState.java:149)
	at android.os.Parcel.writeTypedArray(Parcel.java:1307)
	at android.app.FragmentManagerState.writeToParcel(FragmentManagerState.java:381)
	at android.os.Parcel.writeParcelable(Parcel.java:1496)
	at android.os.Parcel.writeValue(Parcel.java:1402)
	at android.os.Parcel.writeArrayMapInternal(Parcel.java:724)
	at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1408)
	at android.os.Bundle.writeToParcel(Bundle.java:1157)
	at android.os.Parcel.writeBundle(Parcel.java:764)
	at android.app.ActivityManagerProxy.activityStopped(ActivityManagerProxy.java:3841)
	at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3917)
	at android.os.Handler.handleCallback(Handler.java:751)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:154)
	at android.app.ActivityThread.main(ActivityThread.java:6290)
	at java.lang.reflect.Method.invoke(Method.java)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.io.NotSerializableException: com.wdullaer.materialdatetimepicker.date.b
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1224)
	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1584)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1549)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1472)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1218)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
	at android.os.Parcel.writeSerializable(Parcel.java:1522)
	... 23 more

(Unobfuscation: .g is .DefaultDateRangeLimiter, .b is .DatePickerDialog.)
Reading the source it seems that the next field in DatePickerDialog i.e. HapticFeedbackController mHapticFeedbackController would fail serialization in a case like this.

Closing comment (2017-05-10T12:31:44Z): Thanks for the detailed report.
This is a duplicate of #349 (I'll close this one in favor of the other)
I doubt the root cause is the HapticFeedbackController. This started after I introduced the DefaultDateRangeLimiter, so that's a more likely place to start looking.
If you have any more information, please share :-)