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

Wouter Vegter

03/07/2019, 9:19 AM
we have a lot of problems with JobCancellationException causing our android app to hard-crash we already did a lot of research & tweaking to migitate this problem, but it keeps popping up this is what we do: - in Activity.onStart we create quite some (hierarchical) jobs that listens to all kinds of firebase data registrations - when some data changes via channel, we regularly need to stop some data observers and start new data observers via jobs/channels, for switching this data we use our own switchMap method we want to use kotlin&coroutines in our production app, but now we are in serious doubt whether coroutines and the JobCancellationExceptions are maybe not stable enough currently -> Is there anyone that has had a similar experience or can someone offer insight how we prevent JobCancellationException forcing our app to crash?
message has been deleted
message has been deleted
message has been deleted
v

Vsevolod Tolstopyatov [JB]

03/07/2019, 2:04 PM
JCE does not crash an application from within coroutines, it is deliberately ignored in every exception handler. If you see JCE in Android logs, most probably you are closing a channel, but keep sending messages to it from Android-specific non-suspending callback: offer/sendBlocking can throw a JCE and you should catch it in callbacks. Could you please provide a self-contained reproducer?
😁 1
w

Wouter Vegter

03/07/2019, 6:05 PM
I managed to reproduce it, and after that I discovered it originated from non-suspending callbacks. we caught the JCE and our android app is running fine now. thanks a lot for providing this info, we are more confident we can release our app to production! my 2cents: maybe there is some way to add this 'hint' you gave into the exception description of the JCE, in this way it can help other devs that stumble upon this same problem
7 Views