Repository navigation
feat(android): attach all threads to app hangs through the NDK - #2344
Open
bitsandfoxes wants to merge 2 commits into
Open
bitsandfoxes wants to merge 2 commits into
bitsandfoxes wants to merge 2 commits into
Conversation
Add NdkOptions.setAppHangAttachAllThreads(boolean) and isAppHangAttachAllThreads(), off by default. When it is on, the JNI init sets the app-hang thread stackwalk mode to SENTRY_THREAD_STACKWALK_MODE_ALL; when it is off, only the hung thread is walked.
|
bitsandfoxes
marked this pull request as ready for review
November 25, 2026 14:11
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Android SDKs that use the NDK can turn on app-hang tracking (
NdkOptions.setEnableAppHangTracking). However, their app-hang events carry only the hung thread's stack. sentry-native can now attach the stacks of all threads to app-hang events (sentry_options_set_app_hang_thread_stackwalk_mode, #2327), but the NDK bindings don't expose it, so the Android SDK and the SDKs built on it can't turn it on.How
NdkOptionsgetssetAppHangAttachAllThreads(boolean)andisAppHangAttachAllThreads(). It's off by default, next tosetEnableAppHangTrackingandsetAppHangTimeoutMillis.initSentryNativecallssentry_options_set_app_hang_thread_stackwalk_mode(options, SENTRY_THREAD_STACKWALK_MODE_ALL). Each app-hang event lists the other threads with their names and stacks, and the hung thread is marked as crashed.SENTRY_THREAD_STACKWALK_MODE_HUNG_ONLY, and app-hang events are unchanged.The option only has an effect while app-hang tracking is on.
Caveats
The option exposes two Android issues from #2327 to every app that turns it on. Today they can only happen for the hung thread; with the option on, they can happen for every thread.
EINTR: each thread is interrupted by a signal so its stack can be read. A thread blocked insleep,poll,epoll_waitor a similar call returns early withEINTR. Code that doesn't retry onEINTRcan treat that as an error.