Skip to content

Keep what saved instance state is restored through (#875) - #1

Merged
suskie778 merged 1 commit into
suskie778:Test1from
JingMatrix:master
Aug 5, 2026
Merged

Keep what saved instance state is restored through (#875)#1
suskie778 merged 1 commit into
suskie778:Test1from
JingMatrix:master

Conversation

@suskie778

Copy link
Copy Markdown
Owner

Restoring the manager after its process had been reaped crashed, which is JingMatrix#871 -- and JingMatrix#834 before it, on Android 13. Two rules are missing, and the second one only became visible once the first was in place.

R8 shrank values() out of 105 of the 106 enums in the released manager, because nothing calls it any more: Kotlin compiles entries to a separate synthetic field, so the generated method is left without a call site. Enum.valueOf looks that method up by name, so an enum written into a Bundle -- Parcel has no enum case and java.lang.Enum is Serializable, so it goes out as VAL_SERIALIZABLE -- cannot be read back. The navigation suite scaffold state is one such enum, and it sits at the root of every screen.

CREATOR is found the same way, by a reflective field lookup R8 cannot see, and it was gone from every Parcelable the manager did not already keep by name. A mutableStateOf that survives process death is a ParcelableSnapshotMutableState, so with the enums fixed the same restore threw BadParcelableException instead.

Both stanzas are AGP's, from proguard-android-optimize.txt. That file stopped being passed to proguardFiles in JingMatrix#263, five years ago; the legacy manager had copied CREATOR back by hand, the rewrite in JingMatrix#796 did not, and it declared no enums at all, so neither rule was missed until the Compose manager needed them.

Verified on a Pixel 6 (Android 17) and a Galaxy A52s (Android 14): open the manager, background it, kill the host process so the icicle comes back through a Parcel, reopen. Before, that crashed every time; after, state restores across repeated cycles, including the Logs tab and an open bottom sheet.

Restoring the manager after its process had been reaped crashed, which is #871
-- and #834 before it, on Android 13. Two rules are missing, and the second one
only became visible once the first was in place.

R8 shrank values() out of 105 of the 106 enums in the released manager, because
nothing calls it any more: Kotlin compiles `entries` to a separate synthetic
field, so the generated method is left without a call site. Enum.valueOf looks
that method up by name, so an enum written into a Bundle -- Parcel has no enum
case and java.lang.Enum is Serializable, so it goes out as VAL_SERIALIZABLE --
cannot be read back. The navigation suite scaffold state is one such enum, and
it sits at the root of every screen.

CREATOR is found the same way, by a reflective field lookup R8 cannot see, and
it was gone from every Parcelable the manager did not already keep by name. A
`mutableStateOf` that survives process death is a ParcelableSnapshotMutableState,
so with the enums fixed the same restore threw BadParcelableException instead.

Both stanzas are AGP's, from proguard-android-optimize.txt. That file stopped
being passed to proguardFiles in #263, five years ago; the legacy manager had
copied CREATOR back by hand, the rewrite in #796 did not, and it declared no
enums at all, so neither rule was missed until the Compose manager needed them.

Verified on a Pixel 6 (Android 17) and a Galaxy A52s (Android 14): open the
manager, background it, kill the host process so the icicle comes back through
a Parcel, reopen. Before, that crashed every time; after, state restores across
repeated cycles, including the Logs tab and an open bottom sheet.
@suskie778
suskie778 merged commit a4b52ac into suskie778:Test1 Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants