Skip to content

Android: app_start_cold is inflated when the process is background-spawned (FCM) before the user opens the app #6382

Description

@yonitou

What React Native libraries do you use?

React Navigation, Hermes, RN New Architecture, Expo (mobile only)

Are you using sentry.io or on-premise?

sentry.io (SaS)

Are you using any other error monitoring solution alongside Sentry?

Yes

Other Error Monitoring Solution Name

Datadog

@sentry/react-native SDK Version

8.10.0

How does your development environment look like?

react-native: 0.83.2
react: 19.2.0
Android: hermesEnabled true, newArchEnabled true
Android SDK API levels: 31, 35, 36
@react-native-firebase/messaging in use (FCM push)

Sentry.init()

Sentry.init({
  dsn: '...',
  tracesSampleRate: 0.2,
  integrations: [
    Sentry.reactNativeTracingIntegration(),
    Sentry.reactNavigationIntegration(),
  ],
})

Steps to Reproduce

1. Android app with app start tracking + FCM push.
2. Fully close the app.
3. Send a push → Android spawns the process in the background; the native SDK stamps the app start timestamp at process creation.
4. User opens the app some seconds later → first Activity created, first frame drawn.
5. Check measurements.app_start_cold for that session.

Expected Result

Cold start reflects the real user-perceived startup (process already resident, ~1s), or the measurement is dropped. Like the Cocoa SDK does for pre-warmed starts getsentry/sentry-cocoa#1896

Actual Result

app_start_cold is the full gap between background process creation and the first frame after the user opens the app.

Example production trace: Cold Start span = 17.2s, but its children are Process Initialization (181ms) and JS Bundle Execution (1037ms), with a ~16s gap of no activity in between (the process idling in background before the user opened it):

app.start.cold "Cold Start" [17233ms]
├─ "Process Initialization" [181ms] T+0.00s
│ ── ~16s idle, no spans ──
└─ "JS Bundle Execution" [1037ms] T+16.19s

Values range from ~4s to ~56s but never above 60s, matching the 1-minute cap in AppStartMetrics. This creates wrong values for p95/avg cold start on Android.

Looks like appLaunchedInForeground is only evaluated in onActivityCreated(), which fires when the user finally opens the app.

Related fixes I checked don't cover this:

The iOS equivalent was fixed by dropping pre-warmed starts: getsentry/sentry-cocoa#1896

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    Status
    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions