Open omtians9425 opened 2 years ago
@hotchemi I'd appreciate it if you could take a look when you have time (There is no rush) 🙇
@hotchemi how about this PR?
@hotchemi I'd appreciate it if you could take a look when you have time (There is no rush) 🙇
maybe lifecycleOwner = this
is not always right,fragment lifecycle is different from fragment viewLifecycle
I have the same problem, any solution for this bug!!!
Overview
PermissionRequester
multiple times the callback passed by closed one's instance is called and this may cause a crash.Reproducible steps
FirstFragment
is launched as a root FragmentSecondFragment
(PermissionsRequester
is constructed here) with tapping "CLICK TO NEXT"FirstFragment
SecondFragment
againToast
is about to be shown in Fragment's Context with a permission result callback)Stack trace:
Toast uses detached Context so
java.lang.IllegalStateException: Fragment SecondFragment{9e09ebc} (c9cd8d4c-7acc-476a-90c8-7e882fc8dd69) not attached to a context.
is shownGIF with the above procedure
Expected
Actual
Environment
Hypothesis for the cause of the crash
PermissionsRequster
was constructed by Fragment or Activity.PermissionsRequster
was constructed by Fragment, lambda passed intoLiveData.observe
will still be registered, and observing LiveData won't stop when the Fragment dies