firebase / firebase/firebase-android-sdk

Why is the API 34+ importance-based app-start check not used below API 34?

Open
#8,509 1 comment 0 reactions 0 assignees View on GitHub
api: performance type: question
Dominant language
Java
Stars
2.6k
Forks
710
Avg merge
2d 23h
Merged PRs (30d)
34

Description

### Background

`app_start` being suppressed on API 34+ (#8103). The old timing-window heuristic was replaced on API 34+ by a `RunningAppProcessInfo.importance` read at first capture. The changelog says "Pre-API-34 behavior is unchanged."

So today there are two different signals:

- **Below 34** — `StartFromBackgroundRunnable` is posted to the main Looper from `FirebasePerfEarly` (`FirebasePerfEarly.java:55`). If it runs before the first `onActivityCreated`, the start is treated as background (`AppStartTrace.java:350-356`).
- **34+** — `ActivityManager.getMyMemoryState()` importance is read once during `registerActivityLifecycleCallbacks`. Only `IMPORTANCE_FOREGROUND` allows the trace (`AppStartTrace.java:360`).

### Question

`ActivityManager.getMyMemoryState()` has been available since API 16, and `AppStartCause.readImportance()` already runs on **every** API level (`AppStartCause.java:79`). Only the classification is gated:

```java
if (apiLevel >= 34) {
Cause cause = importance == IMPORTANCE_FOREGROUND
? Cause.FOREGROUND
: Cause.UNKNOWN;
return new AppStartCause(cause, importance, apiLevel);
}

// API < 34: legacy AppStartTrace logic owns the decision.
return new AppStartCause(Cause.UNKNOWN, importance, apiLevel);
```

What specifically blocks using the importance signal below API 34?

Contributor guide

Open the contributing guide

Research direction

Start with AppStartCause.java:79, FirebasePerfEarly.java:55, and AppStartTrace.java:350-360 to trace how importance and lifecycle timing interact across API levels. Review related history and tests, then document the compatibility or behavioral reason for the API 34 gate; done means the expected behavior below API 34 is clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, firebase, java
Domain
mobile-dev, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.