@@ -75,6 +75,8 @@ public class AppStartTrace implements ActivityLifecycleCallbacks, LifecycleObser
75
75
private static final @ NonNull Timer PERF_CLASS_LOAD_TIME = new Clock ().getTime ();
76
76
private static final long MAX_LATENCY_BEFORE_UI_INIT = TimeUnit .MINUTES .toMicros (1 );
77
77
78
+ // If the `mainThreadRunnableTime` was set earlier than this this duration, the assumption
79
+ // is that it was called immediately before `onActivityCreated` in foreground starts on API 34+.
78
80
private static final long MAX_BACKGROUND_RUNNABLE_DELAY = TimeUnit .MILLISECONDS .toMicros (100 );
79
81
80
82
// Core pool size 0 allows threads to shut down if they're idle
@@ -329,7 +331,8 @@ private void recordOnDrawFrontOfQueue() {
329
331
* <p>
330
332
* If it's prior to API 34, it's always set to true if `mainThreadRunnableTime` was set.
331
333
* <p>
332
- * If it's on or after API 34, and it was called less than 100ms before `onActivityCreated`, the
334
+ * If it's on or after API 34, and it was called less than `MAX_BACKGROUND_RUNNABLE_DELAY`
335
+ * before `onActivityCreated`, the
333
336
* assumption is that it was called immediately before the activity lifecycle callbacks in a
334
337
* foreground start.
335
338
* See https://github.com/firebase/firebase-android-sdk/issues/5920.
@@ -343,7 +346,8 @@ private void resolveIsStartedFromBackground() {
343
346
344
347
// If the `minaThreadRunnableTime` was set prior to API 34, it's always assumed that's it's
345
348
// a background start.
346
- // Otherwise it's assumed to be a background start if the runnable was set more than 100ms
349
+ // Otherwise it's assumed to be a background start if the runnable was set more than
350
+ // `MAX_BACKGROUND_RUNNABLE_DELAY`
347
351
// before the first `onActivityCreated` call.
348
352
// TODO(b/339891952): Investigate removing the API check, and setting a more precise delay.
349
353
if ((Build .VERSION .SDK_INT < 34 )
0 commit comments