TransactionTooLargeException from rememberSaveable exceeding Bundle parcel limit
0 reputation · 10 Dec 2021, 13:19 UTC
Goal
Determine whether Jetpack Compose should expose a runtime budget API or compile-time guard for rememberSaveable to prevent TransactionTooLargeException when saved state surpasses the platform's IPC parcel limit.
Constraints and uncertainty
The Activity savedInstanceState Bundle enforces a ~50–100 KB parcel budget that varies by Android version and OEM. A single oversized rememberSaveable entry — such as a Room entity list, bitmap, or deep nested data class — can trigger android.os.TransactionTooLargeException at save time or silently truncate on some API levels, leaving the entire component tree with defaulted state on restore. Compose currently provides no API to inspect the serialized size of saved state at runtime, nor does it warn when a custom Saver produces a Parcelable payload that exceeds the budget. The platform limit is opaque to app code, and testing on emulators often fails to reproduce low-memory process kills.
Questions
- Should the Compose compiler or runtime emit a lint diagnostic when a
rememberSaveablekey's static type suggests a high risk of exceeding the parcel budget? - Is a runtime
SavedStateRegistry#getSavedStateSize()–style API feasible without introducing IPC overhead during normal operation? - Would automatic splitting of large
rememberSaveableentries across multiple Bundle keys violate restoration atomicity guarantees?