Skip to content

Defer the API 35+ getHistoricalProcessStartReasons binder call off the main thread #5702

Description

@runningcode

Problem

AppStartMetrics.registerLifecycleCallbacks performs an ActivityManager.getHistoricalProcessStartReasons(1) binder call synchronously on the main thread on API 35+ (sentry-android-core/src/main/java/io/sentry/android/core/performance/AppStartMetrics.java:467-475). Under auto-init this runs at ContentProvider time via SentryPerformanceProvider.onAppLaunched. #5275 already restricted it to API 35+, but on those devices it still blocks the main thread on a system_server round-trip during the coldest part of startup.

Proposal

The result (appStartType / cachedStartInfo) is only consumed later when app-start spans are assembled — investigate moving the lookup to a background thread/executor with the consumer reading a Future or volatile, or deferring until first frame.

Risks

  • registerLifecycleCallbacks runs very early (ContentProvider), before the Sentry executor exists — may need a lazy or Handler-based defer rather than options.getExecutorService().

Activity

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