Keep what saved instance state is restored through - #875
Merged
Conversation
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
added a commit
to suskie778/Vector
that referenced
this pull request
Aug 5, 2026
Keep what saved instance state is restored through (JingMatrix#875)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #871, and #834 before it.
The manager crashes when its activity is restored after the host process has been reaped. Two keep rules are missing from
manager/proguard-rules.pro, and the second one is only reachable once the first is in place.Android resolves an enum's constants by reflective name lookup:
Enum.valueOfasks the class forvalues(). Kotlin no longer calls that method itself —entriescompiles to its own synthetic field — so the last call site is gone and R8 shrinks it away, from 105 of the 106 enums the released manager carries. An enum held in saved instance state goes into the Bundle asVAL_SERIALIZABLE, sinceParcelhas no enum case andjava.lang.EnumisSerializable, and it can then no longer be read back. The navigation suite scaffold state is one such enum, and it sits above every screen.CREATORis found the same way, by a field lookup R8 cannot see, and it had been dropped from everyParcelablethe manager does not already keep by name. AmutableStateOfthat survives process death is aParcelableSnapshotMutableState, so with the enums restored the same read fails withBadParcelableExceptioninstead.Both stanzas are AGP's, from
proguard-android-optimize.txt. That file stopped being passed toproguardFilesin #263. The manager it was dropped from copied theCREATORrule back by hand and declared no enums at all, so neither rule was missed until #796.