Skip to content

feat(native): Added App Hang capture for macOS#1780

Open
bitsandfoxes wants to merge 29 commits into
masterfrom
feat/app-hang-macos
Open

feat(native): Added App Hang capture for macOS#1780
bitsandfoxes wants to merge 29 commits into
masterfrom
feat/app-hang-macos

Conversation

@bitsandfoxes

@bitsandfoxes bitsandfoxes commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Resolves https://github.com/getsentry/team-gdx/issues/155

The Goal

The goal is to have a mechanism that allows capture of frozen/stuck main threads. The resulting event should provide the same level of detail and insights as actual errors. This means contexts, tags, breadcrumbs, trace, and stack trace.

The How

With the new native crash backend we have a daemon running out-of-process. We want to re-use this to monitor a heartbeat. Whatever is considered the main thread periodically calls heartbeat on the SDK. This reset the timestamp. The daemon captures the state of the stuck process should the timestamp exceed the configured threshold.

For this the PR adds the following new API:

  • sentry_options_set_app_hang_enabled:
  • sentry_options_set_app_hang_timeout_ms
  • sentry_app_hang_heartbeat

We can consider extending this in the future by

  • Letting a variable number of threads emit a heartbeat and monitor those
  • Introducing a way to skip the next missed heartbeat. I.e. in case of an expected long operation

The Result

Sample event, see here.

Screenshot 2026-06-08 at 17 29 08

bitsandfoxes and others added 13 commits May 29, 2026 16:39
native_backend_flush_scope runs on every scope mutation (set_tag,
set_context, set_user, ...). Folding breadcrumbs into the flushed base
event re-serialized the entire breadcrumb ring on each of those calls -
prohibitive on a hot path such as a 60fps game main thread.

Give apply_scope a scope-mode argument: the continuous flush now passes
SENTRY_SCOPE_NONE, while the crash handler still passes
SENTRY_SCOPE_BREADCRUMBS to capture them at crash time (the process's
last chance to record them). This matches the pre-existing behavior
before breadcrumbs were added to the shared flush path.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against b1674db

@bitsandfoxes bitsandfoxes changed the title added app hang feature, macOS only feat(native): Added App Hang capture for macOS Jun 3, 2026
Base automatically changed from feat/native-daemon-reads-breadcrumbs to master June 8, 2026 11:08
@bitsandfoxes bitsandfoxes force-pushed the feat/app-hang-macos branch from 82a09d4 to f5c4eaa Compare June 8, 2026 11:57
@bitsandfoxes bitsandfoxes marked this pull request as ready for review June 8, 2026 15:36
@bitsandfoxes bitsandfoxes requested a review from jpnurmi June 8, 2026 15:36
Comment thread src/sentry_app_hang.c Outdated
Comment thread src/backends/native/sentry_crash_daemon.c Outdated
Comment thread src/backends/native/sentry_crash_daemon.c
Comment thread src/backends/native/sentry_crash_daemon.c
Comment thread src/sentry_app_hang.c
Comment thread src/sentry_app_hang.c
Comment thread src/backends/native/sentry_crash_daemon.c
Comment thread src/backends/native/sentry_crash_daemon.c
Comment thread src/backends/native/sentry_crash_daemon.c

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b1674db. Configure here.

Comment thread src/backends/native/sentry_crash_daemon.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant