fix(android): Prevent duplicated breadcrumbs on tombstone-merged events - #5888
fix(android): Prevent duplicated breadcrumbs on tombstone-merged events#5888lucas-zimerman wants to merge 1 commit into
Conversation
Tombstone-merged native crash events already carry their own breadcrumb history from crash time; backfilling persisted scope breadcrumbs on top of them duplicated entries. Skip the backfill when the event already has breadcrumbs, matching the guard already used for cached native events in SentryClient.applyScope(). Co-Authored-By: Claude <noreply@anthropic.com>
|
The fix seems simple, and it kinda is, both capture event and add breadcrumbs are being asynchronously sent to the NDK layer, so at the end, they end up duplicated when checked. Here is a sample event before the patch: https://sentry-sdks.sentry.io/issues/7652870323/events/8c52a48aa88c4060366c04557a092f4d/?project=5428562&referrer=discover-events-table Also since both observers on Native are async, I thought we would lose some breadcrumb, but by doing some testing on a 10ms loop, it seems like there were no missing breadcrumbs. Happy to do a sanity check on merging the breadcrumbs if necessary. |
📜 Description
Tombstone-merged native crash events already carry their own breadcrumb history captured at crash time.
ApplicationExitInfoEventProcessor.setBreadcrumbs()was unconditionally appending disk-persisted scope breadcrumbs on top, duplicating overlapping entries (navigation,device.event,ui.click, etc.).💡 Motivation and Context
Root cause of getsentry/sentry-dart#3856 —
TombstoneMergedevents on Android showed duplicated breadcrumbs compared to the regularsignalhandlerevent for the same crash.ApplicationExitInfoEventProcessorbackfills persisted scope data ontoBackfillableevents (ANR and Tombstone). Every other field it backfills only fills in what's missing, butsetBreadcrumbsblindlyaddAll'd the persisted list even when the event already had its own breadcrumbs. ANR events never hit this branch (they always start breadcrumb-less), but Tombstone-merged events reuse the native SDK's own captured event, which already has breadcrumbs — so the persisted, overlapping list got appended on top.Fix mirrors the existing guard in
SentryClient.applyScope()forCachednative events: skip the backfill when the event already carries breadcrumbs.Linear: JAVA-627, DART-429
💚 How did you test it?
./gradlew :sentry-android-core:testReleaseUnitTest --tests "*ApplicationExitInfoEventProcessorTest*"— all 50 tests pass../gradlew spotlessApply apiDump— clean, no public API surface changed (private method).📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Open against
getsentry/sentry-javaonce ready.