SentryMarkus HintersteinerAnnouncement
Android profiling now uses Perfetto via ProfilingManager
Summary
Starting with Sentry Android SDK 8.51.0, continuous profiling on Android 15 and newer uses Perfetto through Android’s system ProfilingManager API, while devices below Android 15 keep the legacy Debug.startMethodTracing profiler. Existing continuous-profiling users need no configuration change; upgrading moves eligible devices to the new profiler automatically. Moving profiling outside the app process avoids crashes tied to the legacy runtime tracer, reduces CPU and memory overhead, and produces profiles less influenced by the profiler itself. A sample profile shows Gson parsing a large JSON asset for more than a second on the main thread, exposing a missing withContext(Dispatchers.IO) call. Android rate-limits profiling requests, so even a profileSessionSampleRate of 1.0 does not guarantee every session is profiled, and enableLegacyProfiling defaults to true but can be set false to avoid the legacy tracer entirely.
Context
Before SDK 8.51.0, Sentry Android profiling used Debug.startMethodTracing, which samples threads with the Android runtime’s built-in tracer inside the app process. That legacy tracer can crash an app when other code in the process creates native threads, attaches them to the runtime, and exits without detaching them. Profiling inside the app also adds CPU and memory overhead and can influence the code being measured. Android 15 introduced the system ProfilingManager API, which can record Perfetto-based stack samples outside the app process; older devices remain on the legacy profiler.
Approach / What changed
Sentry replaced the in-process legacy profiler with Android’s ProfilingManager on Android 15+ (API 35+), which records Perfetto-based stack samples in a system process. Existing continuous-profiling setups need no configuration change; eligible devices switch after upgrading to SDK 8.51.0. The new enableLegacyProfiling option defaults to true, preserving legacy profiling on older devices; setting isEnableLegacyProfiling to false avoids the legacy tracer entirely and limits profiling to Android 15+. Raw Perfetto traces can be downloaded from a Sentry profile and opened in ui.perfetto.dev. For local testing, the system rate limiter can be disabled with an adb device_config command.
Takeaways
The legacy tracer can crash an app when other code in the process creates native threads, attaches them to the runtime, and exits without detaching them; Perfetto profiling does not use that tracer.
Raw Perfetto traces can be downloaded from a Sentry profile and opened in ui.perfetto.dev for more detail than the flame chart.
For local testing, Android’s profiling rate limiter can be disabled with: adb shell device_config put profiling_testing rate_limiter.disabled true.
FAQ
What happens to profiling on devices below Android 15 after upgrading?
They continue using the legacy profiler by default because enableLegacyProfiling defaults to true. If isEnableLegacyProfiling is set to false, those devices are not profiled and only Android 15+ devices use Perfetto.
Why might a session lack a profile when profileSessionSampleRate is 1.0?
Android rate-limits profiling requests and does not guarantee that it will fill them. The system decides when to profile, so even a sample rate of 1.0 does not ensure every session gets a profile.
How can I view the raw Perfetto trace from a Sentry profile?
Download the raw Perfetto trace from the profile in Sentry and open it in ui.perfetto.dev. The trace provides more detail than the flame chart.
Source and freshness
- Source
- blog.sentry.io
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.