Skip to content

Adopt Perfetto format for Android 17 profiling #6894

Open

Description

@sentry-junior

Android 17 transaction profiles from the React Native sample app are dropped, while the same build is accepted on Android 16. The reported cause is that Android 17 ART method-trace headers include fields rejected by Relay's parser; skipping those fields makes the profile acceptable (workaround PR #6892, Relay issue #6517).

Proposal: adopt the Perfetto format for Android 17 profiling.

via Antonis Lilis.

--

View Junior Session [Sentry]

Activity

  1. linear-code commented on Oct 15, 2026

    @linear-code
  2. self-assigned this
    on Oct 15, 2026
  3. antonis commented on Oct 15, 2026

    @antonis
    Contributor

    Investigated what "adopt Perfetto on Android 17" would involve. Summary: Perfetto is only available for continuous/UI profiling, not for the transaction profiles RN sends today. RN's experimental UI profiling, which would use Perfetto on API 35+, currently doesn't start on RN Android. So adopting Perfetto is a project, not a quick fix, and getsentry/relay#6517 is still needed either way.

    What the code says

    • sentry-android: on API 35+, continuous profiling uses PerfettoContinuousProfiler (Android ProfilingManager). Transaction-based profiling always uses the legacy Debug profiler. AndroidOptionsInitializer.setupProfiler: "Transaction-based profiling always relies on the legacy Debug-based profiler… Perfetto profiling only supports continuous profiling." That matches sentry-java's develop-docs/feature/profiling/perfetto.md: "Only continuous profiling is supported on the Perfetto path — transaction-based and app-start profiling are not."
    • Relay: Perfetto traces are only accepted as profile_chunks (application/x-perfetto-trace, converted to Sample v2). The legacy transaction profile item has no Perfetto path.
    • RN: the default Android profile is a legacy transaction profile (Hermes js_profile plus a Debug method trace). UI profiling exists only as _experiments.profilingOptions, which is forwarded to the native SDKs (RNSentryStart.configureAndroidProfiling). Nothing on the JS side uses it, so no Hermes/JS frames are captured, and Perfetto's native stack sampling wouldn't show JS functions either.

    Tested on Android 17 (API 37 emulator), sample app, with profilingOptions passed natively through sentry.options.json. profilesSampleRate had to be removed natively, since sentry-android turns continuous profiling into a no-op when it's set.

    • Native picks it up: Continuous profiler is enabled true, PerfettoContinuousProfiling integration registered, and Device is API 35+. Skipping legacy app-start profiling — Perfetto ProfilingManager will be initialized after Sentry.init().
    • lifecycle: 'trace': Profiling lifecycle is set to TRACE but tracing is disabled. Profiling will not be started automatically. RN traces in JS, so native tracing is off and the profiler never starts.
    • lifecycle: 'manual' + startOnAppStart: true: no Perfetto/ProfilingManager activity, no chunks captured or sent within about 3 minutes.
    • manual mode has no JS API. The ProfilingOptions.lifecycle JSDoc mentions Sentry.profiler.startProfiler/stopProfiler, but RN doesn't export them.

    What adopting Perfetto would take

    1. Make RN UI profiling actually run on Android: drive the native continuous profiler from JS spans (trace lifecycle doesn't work with JS tracing) and/or expose startProfiler/stopProfiler.
    2. Send Hermes samples as their own profile_chunks linked by profiler_id, so JS frames aren't lost, and confirm with the profiling team that the UI can combine JS and native chunks the way it combines js_profile today.
    3. Account for ProfilingManager's constraints: it's system rate-limited and its results arrive asynchronously. Fine for continuous sessions, not a drop-in for per-transaction start/stop.

    Recommendation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions