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

[EPIC] Android Profiling Improvements and Hardening

Open markushi opened this issue 1 year ago • 2 comments

Description

This is a meta issue to collect reported issues around Android Profiling and how we can improve profiling overall.

Refer to the individual issues to learn more about the status.

### Likely root cause: Third Party code
- [ ] https://github.com/getsentry/sentry-java/issues/2604
### Likely root cause: Android Tracer
- [x] https://github.com/getsentry/sentry-java/issues/3561 -> https://issuetracker.google.com/issues/362293861
- [x] https://github.com/getsentry/sentry-java/issues/3653 -> https://issuetracker.google.com/issues/361129298
### Likely root cause: Sentry SDK

markushi avatar Sep 04 '24 13:09 markushi

I'm thinking about some workarounds that we can do, until it gets fixed (if it gets fixed in older Android versions) We can add another flag to guard "dangerous" profiles, and here is some idea for such detection:

  • With our Gradle plugin we can check the app code to see if there is any other call to Debug.startMethodTracingSampling and Debug.stopMethodTracing
  • Hook into native implementation and workaround the crashing calls
  • We can detect if a native library is called (via gradle plugin or at runtime if possible)
  • Create a file to check crashes between profile start/stop and disable it on next run
  • Cut out the AOSP profiler and bundle it inside our SDK, changing the abort with a warning

If you have any other workaround, feel free to add a comment with it The best would be create a custom profiler, but that's a big effort thing

stefanosiano avatar Sep 16 '24 09:09 stefanosiano

Update: the two issues that require fixes on ART side have been fixed by Google:

  • [x] https://github.com/getsentry/sentry-java/issues/3561 -> https://issuetracker.google.com/issues/362293861
  • [x] https://github.com/getsentry/sentry-java/issues/3653 -> https://issuetracker.google.com/issues/361129298

We're still keeping the underlying GH issues open until we get some information/confirmation that the fixes are rolled out with Google System/Security upates.

kahest avatar Sep 23 '24 14:09 kahest

The data we see is consistent with the expected rollouts of fixes mentioned above. Closing this issue now as there is no remaining action for us at the moment.

kahest avatar Apr 15 '25 09:04 kahest