Skip to content

Help: Unable to trigger a "Warm" app start event #1950

@cmathew

Description

@cmathew

Integration

sentry-android

Build System

Gradle

AGP Version

7.1.2

Proguard

Disabled

Version

5.6.3

Steps to Reproduce

  1. Create an app that initializes Sentry inside your Application class's onCreate method
  2. Enable "Do Not Keep Activities" inside an Android device's developer options
  3. Start the app
  4. Background the app
  5. Resume the app
  6. Note on the Sentry dashboard that no "Warm" start performance events are captured, only "Cold" starts

Expected Result

This docs make a distinction between Cold and Warm app starts. From what it says, I would expect the above steps to trigger a Warm start.

Actual Result

Only Cold start events are reported. I looked into the SDK code and discovered there's a ActivityLifecycleIntegration variable called firstActivityCreated which gets stuck on true after first launch. Seemingly this prevents setColdStart(false) from being called, and hence Warm start events from registering:

private void setColdStart(final @Nullable Bundle savedInstanceState) {
  if (!firstActivityCreated) {
    // if Activity has savedInstanceState then its a warm start
    // https://developer.android.com/topic/performance/vitals/launch-time#warm
    AppStartState.getInstance().setColdStart(savedInstanceState == null);
  }

Looking at the code it's unclear when firstActivityCreated could become false again, except after a full application restart (in which case it should of course be considered a Cold start). If it matters: my application uses a single Activity and initializes Sentry programmatically. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions