https://kotlinlang.org logo
#coroutines
Title
# coroutines
t

Thomas

07/17/2019, 6:42 PM
Hello, some of my users are getting this crash in my app:
Copy code
Fatal Exception: kotlinx.coroutines.flow.internal.ChildCancelledException Child of the scoped flow was cancelled
For some reason this crash does not have a stack trace (on both Firebase and Google Play). This makes it very hard to find the cause. Could someone here help me out? I am using Kotlin
1.3.41
and Coroutines
1.3.0-M2
.
d

Dico

07/17/2019, 9:01 PM
Try putting a try/catch around your application's main
t

Thomas

07/17/2019, 9:06 PM
@Dico Not sure where to put that as I have no idea where the crash occurs. I am using coroutines everywhere in my project. I’m also not able to reproduce the crash on demand so I think this would be difficult to fix. The crash occurs on app start and the second time it’s gone.
d

Dico

07/17/2019, 9:08 PM
I said around your main, I.e. wrap all the code from the main thread in it then introspect any errors that make it there
l

louiscad

07/18/2019, 1:40 AM
Are you using
callbackFlow
or
channelFlow
with APIs that might continue offering values after unregistering, or have non thread-safe unregistering which could lead to race conditions where a value is offered after unregistration?
v

Vsevolod Tolstopyatov [JB]

07/18/2019, 9:06 AM
Hi, stacktraces of cancellation exceptions are missing in the release mode. Could you please enable debug mode (https://github.com/Kotlin/kotlinx.coroutines/blob/master/docs/debugging.md) in your application and report where this exception came from?
t

Thomas

07/25/2019, 10:52 AM
I tried making my own
combineLatest
operator (it was not added, see https://github.com/Kotlin/kotlinx.coroutines/issues/1262). You can find it in the same gist. My guess it I made a mistake somewhere.
No, it’s not the combineLatest operator. Still getting the exception.
I think something like this is throwing the exception:
Copy code
someFlow
    .switchMap { transformTheFlow(it) }
    .collect {
        doSomethingWithTheResult(it)
    }
Maybe this is related? It is a different exception but could be the same bug. https://github.com/Kotlin/kotlinx.coroutines/issues/1334
Maybe this is related?...
Just built Kotlin coroutines myself with this fix. Unfortunately after some time I got the crash again. So this is a different issue.
189 Views