question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Job does not have time to cancel and calls render after a view is destroyed

See original GitHub issue

Hello! 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:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
arkivanovcommented, Aug 1, 2020

I will also consider using Dispatchers.Main.immediate by default, if possible.

0reactions
Skeptickcommented, Aug 1, 2020

Oh, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rails Redirect fails after delete. (Delete is successful but ...
There is something wrong with the destroy action in this controller. The record is removed from the db, the view is read and...
Read more >
The activity lifecycle | Android Developers
When your activity is destroyed because the user presses Back or the activity finishes itself, both the system's and the user's concept of...
Read more >
5 common mistakes when using Architecture Components
1. Leaking LiveData observers in Fragments. Fragments have tricky lifecycle and when a fragment gets detached and re-attached it is not always ...
Read more >
Strict Mode - React
StrictMode is a tool for highlighting potential problems in an application. Like Fragment , StrictMode does not render any visible UI. It activates...
Read more >
React lifecycle methods: An approachable tutorial with examples
Before rendering, the component will have gone through its mounting, ... Note that a React component may not go through every phase.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found