Skip to content

Scope sync attachments for Android, iOS and Native #5052

Open
0 of 1 issue completed
Open

Description

@jamescrosswell

This was actually just added in 0.13.3 of the Native SDK:

We should probably add a follow up task for this (and to investigate the other native syncs).

Originally posted by @jamescrosswell in #5038

Warning

Before implementing for Native, consider/verify how scopes are stored in the Native SDK. Can they be AsyncLocal? If not, we don't want to add attachments from one AsyncLocal scope that get added to events from another AsyncLocal scope... in an ASP.NET Core app (native AOT), that could result in attachments relating to one request being added to events from other requests.

This isn't an issue for Andoid/iOS but needs to be considered for AOT compiled server apps.

See:

➡️ A possible solution to this is to limit the attachment sync to global scope mode.

Important

If we do this after #4061 then we have to circle back and update those docs again

Maybe it's just easier to implement the scope sync and avoid double handing on the docs.

Sub-issues

Sub-issues

0 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. linear-code commented on Mar 23, 2026

    @linear-code
  2. added
    .NET
    on Mar 24, 2026
  3. Flash0ver commented on Mar 24, 2026

    @Flash0ver
    Contributor

    See

    • public void AddAttachment(SentryAttachment attachment)
      {
      try
      {
      // TODO: Missing corresponding functionality on the Android SDK
      }
      finally
      {
      _innerObserver?.AddAttachment(attachment);
      }
      }
      public void ClearAttachments()
      {
      try
      {
      // TODO: Missing corresponding functionality on the Android SDK
      }
      finally
      {
      _innerObserver?.ClearAttachments();
      }
      }
    • public void AddAttachment(SentryAttachment attachment)
      {
      try
      {
      // TODO: Missing corresponding functionality on the Cocoa SDK
      }
      finally
      {
      _innerObserver?.AddAttachment(attachment);
      }
      }
      public void ClearAttachments()
      {
      try
      {
      // TODO: Missing corresponding functionality on the Cocoa SDK
      }
      finally
      {
      _innerObserver?.ClearAttachments();
      }
      }
    • public override void AddAttachmentImpl(SentryAttachment attachment)
      {
      // TODO: Missing corresponding functionality on the Native SDK
      }
      public override void ClearAttachmentsImpl()
      {
      // TODO: Missing corresponding functionality on the Native SDK
      }
  4. Flash0ver commented on Jul 8, 2026

    @Flash0ver
    Contributor

    Also needs updating / removing the note added to the docs via getsentry/sentry-docs#17590.

  5. jurganson commented on Sep 4, 2026

    @jurganson

    @jamescrosswell Just to understand the impact of this - I assume this is to help sync scoped attachments (and logcat.log I would presume), to those pesky native signalhandler crashes, that are often very hard to diagnose, because they are missing attachments?

  6. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 4, 2026
  7. jamescrosswell commented on Sep 6, 2026

    @jamescrosswell
    CollaboratorAuthor

    @jurganson yes pretty much. It's about getting attachments that have been added to the managed/.NET scope on events thrown by the native/android/ios SDKs (so things like the signal interrupts, macho exceptions etc.).

  8. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 6, 2026
  9. jurganson commented on Sep 7, 2026

    @jurganson

    @jamescrosswell Awesome, thanks for the info. This would greatly help my case, as I have several different signal interrupts, with little to no stack trace. Apart from the other attachments, just a simple logcat.log in those cases would be extremely helpful. I put my hope and vote into this getting prioritized in the near future 🤞

  10. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 7, 2026
  11. jamescrosswell commented on Sep 7, 2026

    @jamescrosswell
    CollaboratorAuthor

    Good feedback - thanks @jurganson. I'll bump the priority on this one.

    Right at the moment I'm stretched a bit thin so can't pick it up immediately. Once things are looking on track for the .NET 11 release and once my new colleague (who starts next week) is onboarded, we'll be able to look at picking things like this off the backlog again.

  12. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 7, 2026
  13. jamescrosswell commented on Nov 26, 2026

    @jamescrosswell
    CollaboratorAuthor

    Adding the iOS details from #4034, now closed as a duplicate:

    • On iOS, attachments added with scope.AddAttachment(...) are missing from native crash events (SentrySdk.CauseCrash(CrashType.Native)).
    • The native SetBeforeSend on iOS doesn't receive attachments either. Native crash reports are sent on the next launch, so the reporter suggested a hook at that point (like App Center's hasCrashedInLastSession) where the app could add attachments before the report goes out.
    • CocoaScopeObserver.AddAttachment is still a no-op, with a TODO saying Cocoa has no matching API. The current bindings expose addAttachment: on SentryObjCScope, so that may no longer be true.
    • The people asking for this attach their own logs of process state, which matter most for native crashes that have little or no stack trace.

    The Android side, including the logcat.log attachment, is tracked in #3545, now a sub-issue of this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETImprovement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions