Martyna Maron
03/05/2021, 4:25 PMonResume
of my main fragment, I’ve got code like this (further down the chain, I don’t call this directly like this in onResume
):
suspend fun onSessionStart() = withContext(Dispatcher.javascript) {
for(feature in featuresList) {
feature.setUpSynchronously()
myActivity.lifecycleScope.launch(Dispatcher.javascript) {
feature.setUpAsync()
}
}
}
Right after I call this method above, I call this:
suspend fun start() = withContext(Dispatcher.javascript) {
//...
}
Note that setUpAsync()
may call a method which switches to Dispatcher.network
, but doesn’t launch a new coroutine.
My problem is that on a fresh app launch, this code runs fine, but when I trigger onSessionStart
again, when the app is still alive, I never get to start()
and the app stalls. I can see by the logs that all of the setUpAsync()
calls finish, but they don’t seem to return 🤷🏻♀️
Removing the context when launching the async set up, seems to fix the problem:
myActivity.lifecycleScope.launch {
feature.setUpAsync()
}
But I don’t understand why, any idea?Andrew
03/05/2021, 5:01 PMDispatcher.javascript
before - is this a custom dispatcher in your project?Martyna Maron
03/05/2021, 5:03 PMExecutorService
Anshulupadhyay03
03/08/2021, 7:21 AMMartyna Maron
03/08/2021, 9:11 AMColton Idle
03/09/2021, 1:37 AMgildor
03/09/2021, 1:45 PMgildor
03/09/2021, 1:47 PMgildor
03/09/2021, 1:47 PMNatsuki(开元米粉实力代购)
03/20/2021, 12:42 PMDispatchers.javascript
,
launch should return immediately, even may before setUpAsync
called, i guess the thread underline javascript
is blocked