I've seen lot of question about ViewPager but now it's on ViewPager2.
I'm getting a java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel with ViewPager2. I've seen that TooLargeTool could help determine where this TooLargeException could come from. My bundle is bestof_date and is quite low (0.1KB) but the android:support:fragments just keep increasing
All this come from a ViewPager + Recyclerview standard implementation using FragmentStateAdapter as I can have a 150+ tabs
2021-05-14 17:08:16.373 com.my.application D/TooLargeTool: MainActivity.onSaveInstanceState wrote: Bundle167873131 contains 10 keys and measures 43.7 KB when serialized as a Parcel
* com.google.app_measurement.screen_service = 0.2 KB
* KEY_COMPONENT_ACTIVITY_RANDOM_OBJECT = 0.2 KB
* android:viewHierarchyState = 1.9 KB
* KEY_COMPONENT_ACTIVITY_REGISTERED_KEYS = 9.8 KB
* androidx.lifecycle.BundlableSavedStateRegistry.key = 30.3 KB
* KEY_COMPONENT_ACTIVITY_REGISTERED_RCS = 0.6 KB
* KEY_COMPONENT_ACTIVITY_PENDING_RESULT = 0.1 KB
* KEY_COMPONENT_ACTIVITY_LAUNCHED_KEYS = 0.1 KB
* android:lastAutofillId = 0.1 KB
* android:fragments = 0.4 KB
2021-05-14 17:08:16.482 com.my.application D/TooLargeTool: BestofVideosFragment.onSaveInstanceState wrote: Bundle168360416 contains 3 keys and measures 1.2 KB when serialized as a Parcel
* androidx.lifecycle.BundlableSavedStateRegistry.key = 0.1 KB
* android:view_registry_state = 0.2 KB
* android:view_state = 0.9 KB
* fragment arguments = Bundle87348377 contains 1 keys and measures 0.1 KB when serialized as a Parcel
* bestof_date = 0.1 KB
2021-05-14 17:08:17.003 com.my.application D/TooLargeTool: BestofFragment.onSaveInstanceState wrote: Bundle113147201 contains 4 keys and measures 24.0 KB when serialized as a Parcel
* android:support:fragments = 22.5 KB
* androidx.lifecycle.BundlableSavedStateRegistry.key = 0.1 KB
* android:view_registry_state = 0.2 KB
* android:view_state = 1.2 KB
* fragment arguments = Bundle176902886 contains 0 keys and measures 0.0 KB when serialized as a Parcel
2021-05-14 17:08:17.075 com.my.application D/TooLargeTool: NavHostFragment.onSaveInstanceState wrote: Bundle75010087 contains 7 keys and measures 29.1 KB when serialized as a Parcel
* android:support:fragments = 26.9 KB
* androidx.lifecycle.BundlableSavedStateRegistry.key = 0.1 KB
* android-support-nav:fragment:defaultHost = 0.1 KB
* android:view_registry_state = 0.2 KB
* android-support-nav:fragment:graphId = 0.1 KB
* android-support-nav:fragment:navControllerState = 1.5 KB
* android:view_state = 0.1 KB
Update 1:
After searching a bit more I've found that it is because FragmentStateAdapter is saving the state of the view which piles up until we reach maximum capacity and crash, is there a way to clear that up ?