Enrich Android event with device context when hard crash happens (signal handler)
Description
Enrich Android event with device context when hard crash happens (signal handler)
When does the problem happen
When there's a hard crash, sentry-native writes a file to the disk and Android enriches this event on restart, but some non-static data can't be read accurately anymore like freeMemory/isLowMemory, etc... Some other data would be nice to be read before crashing too like connectivity status, likely the connectivity status is the same if the user opens the App. right away, but it might give wrong values as well if the device just lost connection.
- [ ] During build
- [X] During run-time
- [ ] When capturing a hard crash
Environment
Any Android device/emulator
Steps To Reproduce
Cause an NDK hard crash (segfault)
Log output
See the event on sentry, if it crashes because of OOM, the freeMemory is high and isLowMemory is false.
If the API changed across Android versions, we can support only 21+ which is 90%+ devices.
I think this would require some more investigation effort, as it's unclear if this is even possible to call the Java layer within the signal handler.
I think this would require some more investigation effort, as it's unclear if this is even possible to call the Java layer within the signal handler.
all the static data (what does not change, e.g. os version, model, etc.) can be passed to sentry native when sentry native is init. and keep it cached, so before writing to the disk, you can read that, so the file is already written with all the static data. for the dynamic data, you cannot call Java from NDK because the signal handler breaks the JNI bridge, yes, but NDK still can read every dynamic data similarly to the Java layer, you can access all the Android APIs from NDK as well, but then you duplicate a lot of code in C, its a trade-off.