Skip to content

feat: Sync file attachments to native#5211

Open
bitsandfoxes wants to merge 10 commits intomainfrom
feat/sync-file-attachment
Open

feat: Sync file attachments to native#5211
bitsandfoxes wants to merge 10 commits intomainfrom
feat/sync-file-attachment

Conversation

@bitsandfoxes
Copy link
Contributor

📜 Description

Relies on getsentry/sentry-native#1584

Attachments added to the scope should get synced to sentry-native. I.e. a Unity games has

SentrySdk.ConfigureScope(scope => scope.AddAttachment("special-logfile.log");

and the game crashes, that attachment should be available in the resulting sentry event.

💡 Motivation and Context

Resolves #4758

💚 How did you test it?

Unit tests. Unity SDK will have e2e tests.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

This needs to be used and implemented in the hybrid SDKs.
Adding support to sync bytes as attachments.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (replay) Add beforeErrorSampling callback to Session Replay by romtsn in #5214
  • Sync file attachments to native by bitsandfoxes in #5211

Internal Changes 🔧

  • (deps) Update Native SDK to v0.13.3 by github-actions in #5215

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

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

Generated by 🚫 dangerJS against 1ffacfc

@sentry
Copy link

sentry bot commented Mar 20, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
SDK Size io.sentry.tests.size 8.36.0 (1) release Install Build

return;
}

final byte[] bytes = attachment.getBytes();
Copy link
Member

Choose a reason for hiding this comment

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

there's also attachment.getByteProvider() which lazily evaluates and retrieves the bytes -- not sure if you want to support that from the gaming SDKs, but we use it when getting the bytes is heavy for the main thread, so it gets offloaded to the envelope serialization time on a bg thread, e.g.

Attachment.fromByteProvider(
() -> ScreenshotUtils.compressBitmapToPng(finalScreenshot, options.getLogger()),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think invoking the ByteProvider from inside the signal handler is going to be extremely risky. But I'll keep that in mind.

Copy link
Member

@romtsn romtsn left a comment

Choose a reason for hiding this comment

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

LGTM!

@bitsandfoxes bitsandfoxes marked this pull request as ready for review March 20, 2026 11:41
@github-actions
Copy link
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 301.81 ms 360.57 ms 58.76 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
8687935 332.52 ms 362.23 ms 29.71 ms
27d7cf8 309.43 ms 364.27 ms 54.85 ms
f064536 329.00 ms 395.62 ms 66.62 ms
abfcc92 337.38 ms 427.39 ms 90.00 ms
ae7fed0 293.84 ms 380.22 ms 86.38 ms
d15471f 361.89 ms 378.07 ms 16.18 ms
1df7eb6 397.04 ms 429.64 ms 32.60 ms
9fbb112 401.87 ms 515.87 ms 114.00 ms
6405ec5 310.88 ms 354.56 ms 43.69 ms
62b579c 318.48 ms 367.71 ms 49.24 ms

App size

Revision Plain With Sentry Diff
8687935 1.58 MiB 2.19 MiB 619.17 KiB
27d7cf8 1.58 MiB 2.12 MiB 549.42 KiB
f064536 1.58 MiB 2.20 MiB 633.90 KiB
abfcc92 1.58 MiB 2.13 MiB 557.31 KiB
ae7fed0 1.58 MiB 2.12 MiB 551.77 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
1df7eb6 1.58 MiB 2.10 MiB 532.97 KiB
9fbb112 1.58 MiB 2.11 MiB 539.18 KiB
6405ec5 1.58 MiB 2.12 MiB 552.23 KiB
62b579c 0 B 0 B 0 B

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.

Attachments set in Java do not end up in NDK crashes

3 participants