sentry-java
sentry-java copied to clipboard
Android: synchronize App context to native
Problem Statement
While working on a similar feature for sentry-unity SDK, I've noticed some context is synced to native crashes (namely Device) while the App context is missing. It would be useful to get the App information discovered by the java layer passed to native so that any crashes have the info.
Current state:
-
native error - no App context at the moment - checked on 6.0.0-alpha.4
Solution Brainstorm
No response
The App context is added via an event processor https://github.com/getsentry/sentry-java/blob/main/sentry-android-core/src/main/java/io/sentry/android/core/DefaultAndroidEventProcessor.java
One of the reasons why it's not added to the event is that if the app has updated, the version, app start time, version code, etc are going to be wrong and you'll be debugging an older version.
Ideally, all this device context should be passed to sentry-native during init time, so the data is available before crashing.
Ideally, all this device context should be passed to
sentry-nativeduring init time, so the data is available before crashing.
Yes, that's what I'm doing now for other SDKs in unity
https://github.com/getsentry/sentry-unity/blob/6322d6b6e5701d8dad143eac0efe0453f1b84b20/src/Sentry.Unity.Native/NativeContextWriter.cs may serve as an example of how to pass it to sentry-native
May need to be done in background as not to slow down app start.
@marandaneto will start a docs page for this.
We could reuse what @stefanosiano has done for testing the Java and C layer and write an integration test that runs on Sauce Labs or emulator.
In the first iteration we could just provide the static App context data on SDK init.
Let's wait for ANRv2 as we can already re-use the background worker to sync the data to sentry-native.
