From c0a22e5c0b5655ffd590e51b57660b119c14bf2a Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 20 May 2026 13:53:11 +0000 Subject: [PATCH] feat: include crashing thread name in crash report Capture the crashing thread's name from the UncaughtExceptionHandler and surface it in the report (both in the device-info table and at the top of the stack-trace block), so main-thread crashes can be distinguished from coroutine-worker crashes at a glance. --- .../amethyst/service/crashreports/ReportAssembler.kt | 10 +++++++++- .../service/crashreports/UnexpectedCrashSaver.kt | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/crashreports/ReportAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/crashreports/ReportAssembler.kt index a5b4016b0d..d9ccddcf32 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/crashreports/ReportAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/crashreports/ReportAssembler.kt @@ -24,7 +24,10 @@ import android.os.Build import com.vitorpamplona.amethyst.BuildConfig class ReportAssembler { - fun buildReport(e: Throwable): String = + fun buildReport( + e: Throwable, + threadName: String = Thread.currentThread().name, + ): String = buildString { append(e.javaClass.simpleName) append(": ") @@ -70,9 +73,14 @@ class ReportAssembler { append("| User | ") append(Build.USER) appendLine(" |") + append("| Thread | ") + append(threadName) + appendLine(" |") appendLine() appendLine("```") + append("Thread: ") + appendLine(threadName) appendLine(e.toString()) e.stackTrace.forEach { append(" ") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/crashreports/UnexpectedCrashSaver.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/crashreports/UnexpectedCrashSaver.kt index 1c316de9df..d3bc9fffb8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/crashreports/UnexpectedCrashSaver.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/crashreports/UnexpectedCrashSaver.kt @@ -35,8 +35,9 @@ class UnexpectedCrashSaver( ) { if (e !is OutOfMemoryError) { // OOM reports are junk + val threadName = t.name scope.launch { - cache.writeReport(ReportAssembler().buildReport(e)) + cache.writeReport(ReportAssembler().buildReport(e, threadName)) } } defaultUEH!!.uncaughtException(t, e)