Hi everyone. Who can help me my coroutine job leak...
# coroutines
a
Hi everyone. Who can help me my coroutine job leaks i dont get  it why?
Copy code
private var searchJob: Job? = null
private fun search(query: String = "") {
        searchJob?.cancel()
        searchJob = viewLifecycleOwner.lifecycleScope.launchWhenStarted {
            viewModel.searchTaskList(query).collectLatest {
                adapter?.submitData(it)
            }
        }
    }
LeaksCanary: Fragment received onDestroy callback and FragmentManager is null
z
Just by looking at this, I can't tell. The scope where you're launching should be canceled when view goes away đŸ˜•
u
if you clear searchJob manually does it shut up?
a
@zkeme No it is not
@ursus I tried clearing onDestroyView , onDestroy
@ursus worked on onStop but interesting that launchWhenStated dont work it is active in onViewCreated
d
I'm not very familiar with leaks canary. Can you explain how you know that job is leaking by this message
LeaksCanary: Fragment received onDestroy callback and FragmentManager is null
?