Repository navigation
Description
A cold start can be sent as a warm start. This happens when the launch activity is destroyed while its app-start transaction is still open. Example: the user backs out before the ui.load transaction finishes. With TTFD on, that transaction can stay open for up to 25 seconds.
It affects both modes:
- Without standalone app starts, the
app.start.coldspan gets anapp_start_warmmeasurement. - With standalone app starts (the default on 9.x.x since Make Standalone App Start spans a default #5376), the
App Starttransaction is finished as cancelled and reported as warm.
Cause
When the last activity is destroyed, two lifecycle callbacks run in this order:
AppStartMetrics.onActivityDestroyedsets the start type toWARM. That's meant for the next launch.ActivityLifecycleIntegration.onActivityDestroyedfinishes the openui.loadorApp Starttransaction on the same thread.
PerformanceAndroidEventProcessor then reads the start type from AppStartMetrics while it processes that transaction. By then, step 1 has already changed it. So the launch that just ended is labeled with the type meant for the next one.
Suggested fix
Decide the start type once, when ActivityLifecycleIntegration.startTracing creates the transaction. Store it on the transaction or span. Don't read the shared AppStartMetrics singleton at processing time.
Related
- Cold Android launches can be classified as warm #6363 has the same symptom (cold labeled warm), but a different cause: the
firstIdlefallback below API 35. - fix(android): Time a warm relaunch within 1 minute from its own activity #6687 fixed a related bug in the same callback: a relaunch within 60s of process start was timed from process start. It did not fix this one.
Agent notes
Verified on main a8ff28280a (2026-11-30):
AppStartMetrics.onActivityDestroyed: whenremainingActivities == 0 && !isChangingConfigurations(), it setsappStartType = AppStartType.WARM,appLaunchedInForeground = true,shouldSendStartMeasurements = true,isWarmRelaunchPending = true.ActivityLifecycleIntegration.onActivityDestroyed:finishSpan(appStartSpan, CANCELLED),appStartTransaction.finish(CANCELLED)(standalone), then TTID/TTFD and theui.loadtransaction finish.finish()→captureTransactionruns the event processors synchronously on the main thread.PerformanceAndroidEventProcessor(around line 89):appStartMetrics.getAppStartType()choosesKEY_APP_START_COLDvsKEY_APP_START_WARM.AppStartMetricsregisters its lifecycle callbacks beforeActivityLifecycleIntegration, so its destroy callback runs first.
Reproduction (Robolectric; the scratch test was deleted): drive AppStartMetrics and ActivityLifecycleIntegration in Application dispatch order, mock Scopes.startTransaction to return a sampled SentryTracer, run the real PerformanceAndroidEventProcessor inside captureTransaction, and draw through a real View so postAtFrontOfQueue ordering applies. Destroy the launch activity before the ui.load finishes. The app.start.cold span gets app_start_warm.
On device: sample app with "Don't keep activities" on (toggle it in the Developer options UI; settings put doesn't take effect live). Cold launch, then press HOME before TTFD/idle timeout finishes the ui.load. Read the serialized transaction from logcat (debug sample logs "Serializing object:").
Fix sketch: capture coldStart in startTracing (it's already computed there for the span op) and pass it to the processor, e.g. as span data or a field on the transaction options, instead of reading AppStartMetrics.getAppStartType() in the processor. The relaunch logic that depends on onActivityDestroyed setting WARM for the next launch must keep working; see isWarmRelaunchPending from #6687.
Activity
linear-code commentedon Nov 30, 2026
JAVA-861