Closed frist008 closed 4 years ago
All logs usually contain Unsafe.park.
glide-source-thread-3
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2161)
at sun.misc.Unsafe.park(Unsafe.java:358)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:190)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2059)
at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:548)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1087)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1147)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:784)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:393)
sun.misc.Unsafe.park (Unsafe.java)
java.util.concurrent.locks.LockSupport.park (LockSupport.java:190)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2067)
java.util.concurrent.PriorityBlockingQueue.take (PriorityBlockingQueue.java:548)
bn.a (bn.java:1)
bn.run (bn.java:2)
Hi,
I'm worried that I don't have a Stacktrace where the error occurred
Please try to enable debug mode: https://github.com/Kotlin/kotlinx.coroutines/blob/master/docs/debugging.md#debug-mode to have stacktraces in JobCancellationException
It's hard to tell what exactly is wrong without actual stacktraces, but as a wild guess, please ensure that you do not invoke channel.offer
from non-suspending methods as it can unexpectedly throw CancellationException
(#974).
Also, it is worth to add SafeCoroutineExceptionHandler
to your launchSafe
to handle exceptions from coroutine children as well
My team encountered this as well and unfortunately, we haven't identified the root cause.
But we did make the following changes in a release and haven't seen it since. Maybe these will be helpful:
Observable.asFlow()
usages to Observable.toFlowable(BackPressureStrategy.LATEST).asFlow()
, like this comment from #2104.Flow.asObservable()
usages to Flow.asFlowable().toObservable()
v3.14.9
to v4.7.2
. v1.3.7
to v1.3.8
Other things to note:
channel.offer
explicitly in our source code.Fatal Exception: kotlinx.coroutines.JobCancellationException: Job was cancelled
.
Hi,
I'm worried that I don't have a Stacktrace where the error occurred
Please try to enable debug mode: https://github.com/Kotlin/kotlinx.coroutines/blob/master/docs/debugging.md#debug-mode to have stacktraces in
JobCancellationException
It's hard to tell what exactly is wrong without actual stacktraces, but as a wild guess, please ensure that you do not invoke
channel.offer
from non-suspending methods as it can unexpectedly throwCancellationException
(#974). Also, it is worth to addSafeCoroutineExceptionHandler
to yourlaunchSafe
to handle exceptions from coroutine children as well
We weren't using channel.offer
or RX
explicitly in our source code.
I already add SafeCoroutineExceptionHandler
in coroutineContext
for BaseViewModel : ViewModel(), CoroutineScope
.
If I add it again to launchSafe, won't it be a duplicate?
I am not using experimental or deprecated functions in the project at all.
I have set in Application
System.setProperty (DEBUG_PROPERTY_NAME, DEBUG_PROPERTY_VALUE_ON)
I think it will be necessary to wait a few days. Before I get any results from users in beta testing.
Replaced our Observable.asFlow() usages to Observable.toFlowable(BackPressureStrategy.LATEST).asFlow()
Thanks, that's a great place to start looking!
I already add SafeCoroutineExceptionHandler in coroutineContext for BaseViewModel : ViewModel(), CoroutineScope. If I add it again to launchSafe, won't it be a duplicate?
If the scope of BaseViewModel
is used for launchSafe
, then it's indeed not necessary
I found a bug. It consisted in the fact that I used in one place in my code the suspend
function in the catch (e: CancellationException)
block.
Helped me:
class Application : Application {
override fun onCreate() {
super.onCreate()
System.setProperty(DEBUG_PROPERTY_NAME, DEBUG_PROPERTY_VALUE_ON)
}
}
I continue to observe. If no new issues are found by the end of the month, I will close the discussion.
Perhaps this problem is somehow related to a Google bug. https://issuetracker.google.com/issues/164317567
After switching to Kotlin 1.4, no new error messages appeared. Thanks to all.
@frist008 have you by any chance switched back to Observable.asFlow()
now that you have switched to Kotlin 1.4? How about Flow.asObservable()
?
@frist008 have you by any chance switched back to
Observable.asFlow()
now that you have switched to Kotlin 1.4? How aboutFlow.asObservable()
?
We weren't using RX explicitly in our source code.
Hello. Migrated my project from RxJava to Kotlin coroutines. My project has up to 2000-3000 online per day and 20_000 per month.
I started getting all sorts of errors on Crashlitics with JobCancellationException.
Full log:
Fatal Exception: kotlinx.coroutines.JobCancellationException: Job was cancelled
.However, there are 30-50 other streams. I'm worried that I don't have a Stacktrace where the error occurred? and I cannot fix the problem.
Furthermore. I cannot reproduce it myself. This error occurs with real users, but not me. For real users, the error does not repeat itself for a month. The sample for all users is very small - 0.23%. And the chance of repetition is even less.
The error header can be quite different on Crashlitics:
You may also have noticed that I have listed 2 sides of the library that are thrown with JobCancellationException.
It's funny, but I don't use coroutines explicitly in them. It's just magic.
I am using a wrapper to run coroutines.