Fixed
Status Update
Comments
ka...@gmail.com <ka...@gmail.com> #2
Yigit, do you have time to fix it?
reemission of the same liveData is racy
reemission of the same liveData is racy
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #3
yea i'll take it.
jb...@google.com <jb...@google.com> #4
Thanks for the detailed analysis. This may not be an issue anymore since we've started using Main.immediate there but I' not sure; I'll try to create a test case.
Description
Component used: Fragment Version used: 1.3.3 Devices/Android versions reproduced on: Emulator Android 10
Currently there is a crash trying to get parcelable from result after process restoration.
Setup:
MainActivity
,FirstFragment
andSecondFragment
.FirstFragment
toSecondFragment
.FirstFragment
callsgetParentFragmentManager().setFragmentResultListener()
inonViewCreated()
and listens for result.getParentFragmentManager().setResult()
on submit button click. Submit button does only that and doesn't navigate back toFirstFragment
.Bundle
viaputParcelable()
. We send backExampleClass
which implementsParcelable
using@kotlinx.parcelize.Parcelize
.Steps to reproduce:
SecondFragment
.FirstFragment
receives result inFragmentResultListener#onFragmentResult
and callsresult.getParcelable()
.android.os.BadParcelableException
There two ways to avoid crash:
result.setClassLoader(context.classLoader)
beforeresult.getParcelable()
.Is this something that should be fixed on Fragment or platform side?
What is the preferred workaround for the app developers in the meantime?