Attachments set in Java do not end up in NDK crashes
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.
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 Is there any ETA on when this might be picked up?
@tustanivsky no ETA at the moment - how critical is this for Unreal (or maybe other gaming SDKs)?
@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.
Understood, I will try to give it a stab later this week. I don't think it's a big lift
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.