sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

Attachments set in Java do not end up in NDK crashes

Open tustanivsky opened this issue 3 months ago • 7 comments

Description

Custom user attachments that were set in Java via Sentry.configureScope do not end up in NDK crashes.

The issue originated from the Unreal Engine SDK which uses sentry-java internally to support error monitoring on Android:

  • https://github.com/getsentry/sentry-unreal/issues/191

Currently, the only way to workaround this is to configure a custom beforeSend handler and add the missing attachments to captured crash event manually on the next app launch by using a Hint object. However, this requires us to instruct sentry-unreal users to instrument their code accordingly whereas the expected behavior is for this functionality to work out of the box.

A potential solution is to persist the attachment metadata to disk (see PersistingScopeObserver.java) and then enrich the NDK event on the next launch, similar to how this is handled for data like tags, contexts, etc.

tustanivsky avatar Sep 26 '25 13:09 tustanivsky

Let's store attachments to disk and enrich native envelopes on the next app start with them. Once all envelopes are processed, we can safely delete the attachment files.

markushi avatar Oct 01 '25 13:10 markushi

@markushi Is there any ETA on when this might be picked up?

tustanivsky avatar Nov 04 '25 13:11 tustanivsky

@tustanivsky no ETA at the moment - how critical is this for Unreal (or maybe other gaming SDKs)?

romtsn avatar Nov 11 '25 12:11 romtsn

@romtsn This is something we’ve been planning to address as part of the Quality Quarter to align how the attachments feature works across all platforms supported by the Unreal plugin.

Afaik this issue may also affect the Godot SDK though @limbonaut would know for sure.

tustanivsky avatar Nov 11 '25 12:11 tustanivsky

Understood, I will try to give it a stab later this week. I don't think it's a big lift

romtsn avatar Nov 11 '25 12:11 romtsn

Indeed, this also affects the Godot SDK. Just to let you know, sentry-native can now handle byte attachments. This should probably match the Java API well.

limbonaut avatar Nov 11 '25 13:11 limbonaut