最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Kotlin Coroutines Stacktrace Recovery trims the suspend call stack - Stack Overflow

programmeradmin7浏览0评论

I encountered an issue with using Coroutines Stacktrace recovery on Android. I followed official documentation but seems like Im missing something.

I enabled debug mode with System.setProperty("kotlinx.coroutines.debug", "on"); in my project's Application class onCreate, but it does not seem to work for me no matter what I do.

For example this code:

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        runBlocking {
            callerFunction1()
        }
     }

fun callerFunction1() {
        CoroutineScope(Dispatchers.Main + CoroutineName("Caller1")).launch {
            intermediateFunction1()
        }
}

suspend fun intermediateFunction1() {
        delay(100) 
        intermediateFunction3()
    }

suspend fun intermediateFunction2() {
        delay(100)
        crashFunction()
    }

will trim the stack trace only to crashFunction call without any callers info.

Is there a chance to obtain a trace in a way: crashFunction -> intermediateFunction2 -> intermediateFunction1?

What I tried:

  • Using Coroutine ExceptionHandler
  • Using try-catch at the top level
  • Using my CustomException which implements CopiableThrowable
  • Using other types of exception like IllegalStateException

Environment

  • Android
  • Standard debug build - no Proguard or R8
  • kotlin 2.0.0
  • coroutinesVersion 1.8.1
发布评论

评论列表(0)

  1. 暂无评论