Skip to content

fix(android): Detect startup crashes on the boottime clock - #6738

Open
runningcode wants to merge 2 commits into
mainfrom
no/java-729-startup-crash-ticker
Open

runningcode wants to merge 2 commits into
mainfrom
no/java-729-startup-crash-ticker

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

📜 Description

Startup crash detection now measures the time since SDK init on the MonotonicTicker (CLOCK_BOOTTIME), not SystemClock.uptimeMillis().

Both SDK init entry points (SentryPerformanceProvider and SentryAndroid) now start a Stopwatch when their class loads. This happens next to the existing sdkInitMillis, and AppStartMetrics stores the Stopwatch with the same "first one wins" rule as sdkInitTimeSpan. AndroidEnvelopeCache reads it. TimeSpan stays on uptime because changing its base is a v9 decision (JAVA-827). This was the last production use of AndroidCurrentDateProvider. The class itself is deleted in v9.

💡 Motivation and Context

Uptime stops during deep sleep. So a crash long after init could fall under startupCrashDurationThresholdMillis if the device slept in between, and it would be marked as a startup crash.

💚 How did you test it?

Unit tests use TestMonotonicTicker. They include a test where the ticker jumps 5 hours, which an uptime clock would have left out.

📝 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

Delete AndroidCurrentDateProvider in v9 (JAVA-827).

🤖 Generated with Claude Code

runningcode and others added 2 commits November 23, 2026 11:14
Startup crash detection measured the time since SDK init with
SystemClock.uptimeMillis(), which stops while the device is in deep
sleep. A crash long after init, with sleep in between, could fall under
the threshold and be marked as a startup crash.

Both SDK init entry points now also start a Stopwatch on the
MonotonicTicker, which counts deep sleep, and AndroidEnvelopeCache
reads that. The TimeSpan stays on uptime because changing its base is a
v9 decision. This removes the last production use of
AndroidCurrentDateProvider; the class itself goes away in v9.

Fixes JAVA-729

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

linear-code Bot commented Nov 23, 2026

Copy link
Copy Markdown

JAVA-729

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

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 7e7a282.

Main concerns: public contract, host performance, reach.

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 23, 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


AndroidEnvelopeCache(
final @NotNull SentryAndroidOptions options,
final @NotNull ICurrentDateProvider currentDateProvider) {

@runningcode runningcode Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

last usage of AndroidCurrentDateProvider

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

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.

Clean up the remaining AndroidCurrentDateProvider usages

1 participant