Skip to content

feat(profiling): Link iOS UI profiles to transactions and send Hermes chunks on iOS #7088

Open

Description

@antonis

Problem

UI profiling (_experiments.profilingOptions) on iOS only half-works today:

  • sentry-cocoa profiles and uploads native profile chunks, but startProfiler on iOS always resolves nil (packages/core/ios/RNSentry.mm, "sentry-cocoa has no public API for the current profiler id"). Because of that, iOS transactions get no contexts.profile.profiler_id, so Sentry can't link a transaction or span to its profile.
  • Hermes JS samples aren't sent as profile chunks on iOS (gated to Android API 35+ in uiProfilingIntegration.ts), so iOS UI profiles contain only native frames.

Android already handles both (#6916, #6966). Both PRs list iOS as a follow-up that's blocked on Cocoa exposing the profiler ID.

Transaction-based profiling (profilesSampleRate) isn't affected: JS owns the profile_id there.

Unblocked by

getsentry/sentry-cocoa#9712 adds SentrySDK.internal.profiling.currentProfilerId (Swift) and SentryObjCSDK.internal.profiling.currentProfilerId (ObjC). It returns the profiler_id that Cocoa writes into continuous profile chunks, or nil when the profiler is inactive. The ID is set synchronously by SentrySDK.startProfiler() and stays the same for the whole process.

Tasks

1. Link iOS transactions to the UI profile

  • Bump sentry-cocoa to the release that includes feat: Expose the profiler ID to hybrid SDKs sentry-cocoa#9712
  • RNSentryInternal.swift: add currentProfilerId() wrapping SentrySDK.internal.profiling.currentProfilerId, with a nil stub on watchOS/tvOS/visionOS (same #if pattern as startProfiler(forTrace:))
  • RNSentryInternalWrapper.{h,m}: add a passthrough
  • RNSentry.mm startProfiler: resolve with the current profiler ID instead of nil, and remove the outdated comment
  • No JS or codegen change needed: NativeRNSentry.startProfiler() is already typed Promise<string | undefined | null>, and uiProfilingIntegration already stamps profiler_id when it gets one
  • Tests: native iOS test for the resolved value (nil when sampled out); sample app/e2e check that an iOS transaction has contexts.profile.profiler_id matching the chunk's profiler_id

2. Send Hermes samples as UI profile chunks on iOS

  • Enable sendsHermesChunks on iOS in uiProfilingIntegration.ts
  • Check how Sentry merges the javascript chunk with Cocoa's sample-format chunks, and settle the JS thread ID. Android uses a synthetic 2^32 ID because Perfetto samples the JS thread under the same OS thread ID; check whether Cocoa's Mach-port thread IDs collide the same way.
  • Verify end to end on device: one profile with JS and native frames, and spans pointing to the JS thread

Acceptance criteria

  • With UI profiling on iOS, transactions created during a profiler session have contexts.profile.profiler_id equal to the profiler_id of the uploaded chunks, and the transaction opens its profile in Sentry
  • When the profiler doesn't run (sampled out), nothing is stamped and nothing breaks
  • (Task 2) iOS UI profiles show JS frames on the JS thread alongside native frames
  • Works on both the New and Old Architecture

References

Activity

  1. linear-code commented on Nov 23, 2026

    @linear-code
  2. self-assigned this
    on Nov 23, 2026
  3. antonis commented on Nov 26, 2026

    @antonis
    ContributorAuthor

    Unblocked: #7114 bumps sentry-cocoa to 9.36.0, which ships getsentry/sentry-cocoa#9712 (SentrySDK.internal.profiling.currentProfilerId). Work can start once #7114 merges.

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