Skip to content

fix(native): daemon constructs breadcrumbs from file#1775

Merged
bitsandfoxes merged 14 commits into
masterfrom
feat/native-daemon-reads-breadcrumbs
Jun 8, 2026
Merged

fix(native): daemon constructs breadcrumbs from file#1775
bitsandfoxes merged 14 commits into
masterfrom
feat/native-daemon-reads-breadcrumbs

Conversation

@bitsandfoxes

@bitsandfoxes bitsandfoxes commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Follows #1769

The Goal

The goal is to have the daemon create non-crashing events that have the same scope as crashing ones. The non-crashing event created by the app hang detection was missing breadcrumbs.

Context

The crash capture works by the in-process part of the SDK maintaining a base event that the daemon later can pick up, enrich and send. This base event also contains the flushed scope.

Breadcrumbs live on the scope but do not get flushed when added:

// the `no_flush` will avoid triggering *both* scope-change and
// breadcrumb-add events.
SENTRY_WITH_SCOPE_MUT_NO_FLUSH (scope) {
sentry_scope_add_breadcrumb(scope, breadcrumb);
}
}

So the native_backend_except running in-process has to flush the scope including the breadcrumbs to have them in the base event for them to be available in the event sent by the daemon.

// Apply scope to event including breadcrumbs
SENTRY_WITH_SCOPE (scope) {
sentry__scope_apply_to_event(
scope, options, event, SENTRY_SCOPE_BREADCRUMBS);
}

That also means that the daemon never touched the breadcrumb ringfiles.

What This Does

Instead of relying on the native_backend_except to sync the breadcrumbs to the base event (which won't be happening in case of non-crashing events) we make the daemon pick up the breadcrumbs that are written to file anyway.

#skip-changelog

bitsandfoxes and others added 9 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>
Comment thread src/backends/native/sentry_crash_daemon.c
Comment thread src/backends/native/sentry_crash_daemon.c Outdated
Comment thread src/backends/native/sentry_crash_daemon.c Outdated
return;
}

// Serialize to JSON (so it can be deserialized on next start)

@bitsandfoxes bitsandfoxes Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That comment is misleading, could not find who or what was reading the JSON on the next start.

uint64_t shutdown_timeout;
uint64_t transfer_timeout;
bool system_crash_reporter_enabled;
uint32_t max_breadcrumbs;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since it's the daemon now constructing the breadcrumbs from files it needs the max_breadcrumbs.

@bitsandfoxes bitsandfoxes changed the title Feat/native daemon reads breadcrumbs fix(native): daemon constructs breadcrumbs from file Jun 3, 2026

@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 8a5a6be. Configure here.

Comment thread src/backends/native/sentry_crash_daemon.c
@mujacica

mujacica commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Let's also write some unit and integration tests to verify this works end-to-end on all 3 platforms

Base automatically changed from fix/native-flush-scope to master June 8, 2026 09:41
@bitsandfoxes bitsandfoxes requested review from jpnurmi and mujacica June 8, 2026 10:18
@bitsandfoxes bitsandfoxes merged commit b209917 into master Jun 8, 2026
63 checks passed
@bitsandfoxes bitsandfoxes deleted the feat/native-daemon-reads-breadcrumbs branch June 8, 2026 11:08
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.

2 participants