fix(anr): extend main thread detection from thread dump (#5733)
* fix(anr): detect main thread when OS names it after the process On some Android versions/OEMs, AppExitInfo's thread dump names the main thread after the process name (e.g. 'com.example.app') instead of 'main'. ThreadDumpParser previously only matched on 'main', causing the thread to not be flagged as main/crashed and resulting in ANR events with no usable stack trace. Pass the process name from ApplicationExitInfo.getProcessName() to ThreadDumpParser and treat a thread as main if its name equals 'main' OR the process name. Fixes JAVA-635 Co-Authored-By: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> * Format code * ref(anr): Detect main thread via sysTid matching process id The main thread can be renamed by the OS to the (potentially truncated) process name, so relying on the process name is fragile. On Linux/Android the main thread's kernel thread id (sysTid) always equals the process id, so use that as the authoritative signal instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * changelog * Simplify changelog entry * ref(anr): Normalize main thread name and skip threads without a stacktrace Normalize the main thread's name back to "main" once it is identified (the OS may have renamed it to the process name), and drop threads that have no stacktrace as they are not actionable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ref(anr): Detect main thread via sysTid and skip stackless threads Identify the main thread by matching the thread whose kernel thread id (sysTid) equals the process id, falling back to the conventional "main" thread name, and skip threads that have no stacktrace as they are not actionable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ref(anr): Clean up ThreadDumpParser Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Update CHANGELOG.md Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com>
M
Markus Hintersteiner committed
e3bd612b84f35c9392baef297f365c74885a2966
Parent: 69edd7d
Committed by GitHub <noreply@github.com>
on 7/8/2026, 7:42:41 AM