Repository navigation
fix(android): Detect startup crashes on the boottime clock - #6738
runningcode wants to merge 2 commits into
Conversation
PR risk: mediumFor commit Main concerns: public contract, host performance, reach. Rules that block low also fired:
This label is a hint for reviewers, not an approval. |
📲 Install BuildsAndroid
|
|
|
||
| AndroidEnvelopeCache( | ||
| final @NotNull SentryAndroidOptions options, | ||
| final @NotNull ICurrentDateProvider currentDateProvider) { |
There was a problem hiding this comment.
last usage of AndroidCurrentDateProvider
7e7a282 to
081b698
Compare
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 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
081b698 to
3a20dd8
Compare
| } | ||
|
|
||
| @Test | ||
| fun `when the device slept through the threshold since sdk init, does not write startup crash file`() { |
There was a problem hiding this comment.
My clanker found that this one does not really test for regressions (switching back to uptime would pass) and suggested writing a Robolectric test that starts the SDK through the provider, calls ShadowSystemClock.simulateDeepSleep(Duration.ofHours(5)), and checks that an uncaught crash writes no marker
There was a problem hiding this comment.
Oh, i didn't know that we could simulate deep sleep like that. Will do!
romtsn
left a comment
There was a problem hiding this comment.
one test needs hardening perhaps, LGTM otherwise!
📜 Description
Startup crash detection now measures the time since SDK init on the
MonotonicTicker(CLOCK_BOOTTIME), notSystemClock.uptimeMillis().Both SDK init entry points (
SentryPerformanceProviderandSentryAndroid) now start aStopwatchwhen their class loads. This happens next to the existingsdkInitMillis, andAppStartMetricsstores theStopwatchwith the same "first one wins" rule assdkInitTimeSpan.AndroidEnvelopeCachereads it.TimeSpanstays on uptime because changing its base is a v9 decision (JAVA-827). This was the last production use ofAndroidCurrentDateProvider. The class itself is deleted in v9.💡 Motivation and Context
Uptime stops during deep sleep. So a crash long after init could fall under
startupCrashDurationThresholdMillisif 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
sendDefaultPIIis enabled.🔮 Next steps
Delete
AndroidCurrentDateProviderin v9 (JAVA-827).🤖 Generated with Claude Code