Skip to content

Stagger non-critical executor work until after first frame #5706

Description

@runningcode

Problem

The single SentryExecutorService thread starts working immediately during init: loadLazyFields (JsonSerializer map build), previous-session move/finalize (file IO), ANR ApplicationExitInfo parsing (binder + parse), cached-envelope sends, options-persistence writes (sentry/src/main/java/io/sentry/Sentry.java:548), system-events receiver registration. On 4-core devices this competes for CPU/IO with the app's first-frame work, even though almost none of it is needed in the first second.

Proposal

Investigate gating non-critical tasks (ANR exit-info processing, options persistence reset, previous-session finalize, device-info pre-cache) on first-frame / idle — e.g. via the existing AppStartMetrics activity lifecycle callbacks — instead of enqueueing them at init.

Same philosophy as SDK-1346 (delay Session Replay init), applied to the executor queue.

Constraints

  • The startup-crash flush must stay immediate (it deliberately blocks init).
  • Previous-session finalize and ANR processing exist to deliver crashes/ANRs early — quantify the delivery-latency tradeoff before moving them.
  • Headless processes (services, workers) never render a first frame — need a fallback trigger (idle handler or timeout).

Metadata

Metadata

Assignees

No one assigned

    Fields

    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