Skip to content

fix(android): preserve app start type when launch activity is destroyed early - #6809

Closed
sahuadarsh0 wants to merge 1 commit into
getsentry:mainfrom
sahuadarsh0:fix/6808-preserve-app-start-type
Closed

sahuadarsh0 wants to merge 1 commit into
getsentry:mainfrom
sahuadarsh0:fix/6808-preserve-app-start-type

Conversation

@sahuadarsh0

Copy link
Copy Markdown

📜 Description

Record the classified app start type (cold / warm) in APP_START_TYPE_DATA when ActivityLifecycleIntegration creates or updates a standalone app.start transaction (foreground launch, headless start, and eager extension), and resolve the start type in PerformanceAndroidEventProcessor from the transaction's own app.start.cold/app.start.warm child span or recorded APP_START_TYPE_DATA before falling back to AppStartMetrics.getAppStartType().

💡 Motivation and Context

When the launch activity is destroyed while its ui.load or standalone app.start transaction is still open, AppStartMetrics.onActivityDestroyed runs first and flips appStartType to WARM for the next launch. ActivityLifecycleIntegration.onActivityDestroyed then finishes the open transaction on the same thread, and PerformanceAndroidEventProcessor previously read the already-mutated AppStartMetrics singleton, reporting the ending cold start as warm.

💚 How did you test it?

Added unit tests in PerformanceAndroidEventProcessorTest (both non-standalone app.start.cold span and standalone app.start transaction paths when AppStartMetrics flips to WARM before processing) and ActivityLifecycleIntegrationTest (reproducing AppStartMetrics.onActivityDestroyed running before ActivityLifecycleIntegration.onActivityDestroyed in standalone mode).

Ran :sentry-android-core:testReleaseUnitTest across PerformanceAndroidEventProcessorTest, ActivityLifecycleIntegrationTest, and AppStartMetricsTest (225 tests passing) plus :sentry-android-core:spotlessCheck.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

None.

@sahuadarsh0
sahuadarsh0 requested review from a team and adinauer as code owners November 30, 2026 09:56
@sahuadarsh0
sahuadarsh0 requested review from 0xadam-brown and runningcode and removed request for a team November 30, 2026 09:56
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 920c6c2.

Main concerns: data sent to Sentry, reach, host performance.

This label is a hint for reviewers, not an approval.

@runningcode

Copy link
Copy Markdown
Contributor

Thanks for opening. Please read our contributing guide before opening a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cold app start reported as warm when its activity is destroyed before the transaction finishes

2 participants