Skip to content

fix(android): Start a warm app start from onActivityPreCreated on API 29+ - #6719

Open
runningcode wants to merge 2 commits into
mainfrom
no/warm-start-on-activity-pre-created
Open

runningcode wants to merge 2 commits into
mainfrom
no/warm-start-on-activity-pre-created

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

📜 Description

On API 29+, AppStartMetrics now decides the app start type and restarts the warm app start span in onActivityPreCreated. Below API 29, where that callback doesn't exist, it keeps doing this in onActivityCreated.

💡 Motivation and Context

ActivityLifecycleIntegration already starts the activity.load span in onActivityPreCreated. A warm app.start transaction anchored at onActivityCreated therefore started after its own first child. This was raised in review of #6687.

  • resolves: JAVA-850

💚 How did you test it?

Unit tests.

📝 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

🤖 Generated with Claude Code

runningcode and others added 2 commits November 20, 2026 17:12
… 29+

The activity.load span starts in onActivityPreCreated, so a warm
app.start transaction anchored at onActivityCreated started after its
own first child. On API 29+ the first-activity logic now runs in
onActivityPreCreated; older versions keep onActivityCreated, since
pre-created callbacks don't exist there.

Fixes JAVA-850

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Nov 20, 2026

Copy link
Copy Markdown

JAVA-850

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 33c9028.

Main concerns: public contract, reach, data sent to Sentry.

Rules that block low also fired:

  • R4: a public API record changed: sentry-android-core/api/sentry-android-core.api

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

@sentry

sentry Bot commented Nov 20, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.65.0 (1) release

⚙️ sentry-android Build Distribution Settings

@runningcode
runningcode marked this pull request as ready for review November 20, 2026 16:40
@runningcode
runningcode requested review from a team and adinauer as code owners November 20, 2026 16:40
@runningcode
runningcode requested review from 0xadam-brown and romtsn and removed request for a team November 20, 2026 16:40
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 20, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 33c9028. Configure here.

// onActivityPreCreated is only dispatched on API 29+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
onActivityCreating(savedInstanceState);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Late init misses warm start

Medium Severity

On API 29+, onActivityCreating only runs from onActivityPreCreated. The SDK_INT check treats that callback as always having run, but registerActivityLifecycleCallbacks during Activity.onCreate happens after PreCreated was already dispatched. onActivityCreated then skips classification and warm re-anchoring, so app start type stays unknown and the warm span is never restarted. This hits the SentryAndroid.init fallback when SentryPerformanceProvider is removed and Sentry is initialized in Activity.onCreate.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 33c9028. Configure here.

This branch has not been deployed

No deployments
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.

1 participant