Job does not have time to cancel and calls render after a view is destroyed
See original GitHub issueHello! In my application, I store a navigation action in a state, and also use the NavController::addOnDestinationChangedListener
to tell the Store
that the navigation action has been completed and can be nullified. Thus, Store
generates a new state at the very edge before destroying the view. Today I ran into the fact that 1 time out of 10, the state arrives in the render
method too late, and the application crashes due to the fact that the view has already nullified. Changing BinderLifecycleMode
from START_STOP
to RESUME_PAUSE
had no effect. I assumed that a coroutine does not have time to cancel Job
and added yield()
here, before assertOnMainThread()
, and it seems to help. I was unable to reproduce the problem again. It will be great if you do it in the library 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top GitHub Comments
I will also consider using
Dispatchers.Main.immediate
by default, if possible.Oh, thank you!