Fixed
Status Update
Comments
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit b6f920cbc24f2e12ba3f881a2d61f7e845e9797e
Author: Ian Lake <ilake@google.com>
Date: Fri Nov 19 14:48:01 2021
Avoid saving an empty Bundle for SavedStateRegistry
When performSave() is called, SavedStateRegistry
might actually not have anything to save. In those
cases, it should avoid adding an empty Bundle to
the outBundle.
This allows systems that use SavedStateRegistry
(such as Fragments) to use Bundle.isEmpty() as a
sign on whether it needs to add its Bundle, etc.
Test: new SavedStateRegistryTest test
BUG: 203457956
Change-Id: Ib49bd8645a5d4e38de329e50fe659b1baf7fcba3
M savedstate/savedstate/src/main/java/androidx/savedstate/SavedStateRegistry.java
M savedstate/savedstate/src/androidTest/java/androidx/savedstate/SavedStateRegistryTest.kt
https://android-review.googlesource.com/1896865
Branch: androidx-main
commit b6f920cbc24f2e12ba3f881a2d61f7e845e9797e
Author: Ian Lake <ilake@google.com>
Date: Fri Nov 19 14:48:01 2021
Avoid saving an empty Bundle for SavedStateRegistry
When performSave() is called, SavedStateRegistry
might actually not have anything to save. In those
cases, it should avoid adding an empty Bundle to
the outBundle.
This allows systems that use SavedStateRegistry
(such as Fragments) to use Bundle.isEmpty() as a
sign on whether it needs to add its Bundle, etc.
Test: new SavedStateRegistryTest test
BUG: 203457956
Change-Id: Ib49bd8645a5d4e38de329e50fe659b1baf7fcba3
M savedstate/savedstate/src/main/java/androidx/savedstate/SavedStateRegistry.java
M savedstate/savedstate/src/androidTest/java/androidx/savedstate/SavedStateRegistryTest.kt
Description
Component used: SavedState
Version used: 1.1.0
When unconditionally calls even if there are no components that were registered to save their state.
SavedStateRegistry
is asked toperformSave
, itputBundle
This means that in cases like Fragments, where the Fragment itself has a
SavedStateRegistry
and the fragment's view has its ownSavedStateRegistry
, the overall saved state is increased doubly so (at what seems like a cost of 0.2KB per fragment).While not a significant part of the total saved state, this can add up with deep stacks.