martypitt
05/15/2024, 12:23 PMresult.throwOnFailure
This code is counting for nearly 93% of our CPU time when we're under load.
I've debugged, and see the error getting thrown are:
`kotlinx.coroutines.flow.internal.ChildCancelledException`: Child of the scoped flow was cancelled
(which is designed not to populate the stack trace -- good thing)
kotlinx.coroutines.flow.internal.AbortFlowException
Flow was aborted, no more elements needed -
(appears as though it does capture the stack, not 100% sure though).
Assuming the root cause is that we're misusing the framework somehow, It's not obvious to me where these errors are being generated in our code.
Anyone had experience with this, or got pointers on how to improve this?ross_a
05/15/2024, 1:12 PMkotlinx.coroutines.debug
enabled or -ea
?ross_a
05/15/2024, 1:13 PMinternal actual class AbortFlowException actual constructor(
@JvmField @Transient actual val owner: FlowCollector<*>
) : CancellationException("Flow was aborted, no more elements needed") {
override fun fillInStackTrace(): Throwable {
if (DEBUG) return super.fillInStackTrace()
// Prevent Android <= 6.0 bug, #1866
stackTrace = emptyArray()
return this
}
}
internal actual class ChildCancelledException : CancellationException("Child of the scoped flow was cancelled") {
override fun fillInStackTrace(): Throwable {
if (DEBUG) return super.fillInStackTrace()
// Prevent Android <= 6.0 bug, #1866
stackTrace = emptyArray()
return this
}
}
ross_a
05/15/2024, 1:13 PMmartypitt
05/15/2024, 1:15 PMmartypitt
05/15/2024, 1:16 PMross_a
05/15/2024, 1:18 PMprintln(MyClass::class.java.desiredAssertionStatus())
println(System.getProperty(DEBUG_PROPERTY_NAME))
Should be able to indicate if either are enabledmartypitt
05/15/2024, 1:19 PMfalse
null
martypitt
05/15/2024, 1:19 PMmartypitt
05/15/2024, 1:20 PMross_a
05/15/2024, 1:21 PMmartypitt
05/15/2024, 1:21 PM