Performance: scene-based background launch inflates _app_start until first foreground activation (12.19.2)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- swift
- Domain
- observability-sre
Research direction
Start by tracing Firebase Performance's automatic app-start instrumentation and how it observes UIKit AppDelegate and SceneDelegate lifecycle events; the report names no source files or tests. Reproduce the background-before-first-activation sequence and compare the automatic _app_start duration with the lifecycle events. Done when background waiting time is excluded while normal foreground launches remain measured; the issue provides detailed reproduction steps but no public minimal project.
Written by the indexing model from the issue text.
Description
Description
We observe minute-scale _app_start outliers in production, while our app-owned time-to-interactivity measurements remain much shorter.
During investigation, we reproduced a background-before-first-activation sequence locally. Firebase included the background waiting period in the automatic app-start trace.
Increasing the wait before foregrounding the application by 12 seconds increased the Firebase _app_start duration by approximately the same 12 seconds, while UI preparation time remained nearly unchanged.
This confirms the timing behavior in our local reproduction. We have not established that every production outlier has this cause.
Environment
- Firebase Apple SDK: 12.19.2
- Installation: Swift Package Manager
- Product: Firebase Performance
- Application lifecycle: UIKit AppDelegate + SceneDelegate, with UIApplicationSceneManifest
- Reproduction device: iOS Simulator 27.2
- Xcode: 27.2
- Debug build, without an attached debugger or process suspension during the measured launches
- Automatic instrumentation and performance data collection enabled locally
We used the application's existing test configuration to bypass Remote Config fetching and keep the performance configuration deterministic. Firebase SDK sources were not modified.
Expected behavior:
A genuine background launch should not include the wait until the user
first opens the application in the user-facing app-start duration.
At the same time, a normal foreground launch should not be discarded
simply because applicationState reports .background before scenes connect.
Related issues:
Possibly related to #10733 and the scene-based launch handling introduced
for #15802 / #15912.
We are not suggesting restoring the blanket .background check at
didFinishLaunching, since that would reintroduce the scene-based
foreground-launch problem.
Could you investigate this background-before-first-activation case?
Is there a supported workaround that excludes these measurements without
disabling network instrumentation, screen rendering, or app-owned custom
traces?
Reproducing the issue
This was reproduced in an existing UIKit application using AppDelegate
and SceneDelegate, with UIApplicationSceneManifest. I do not currently
have a public minimal reproduction project.
- Install and launch the application once in the iOS Simulator.
- Move the application to the background by opening Settings.
- Kill only the application's simulator process, without deleting
application data, to model process eviction. - Send a local simulated notification containing content-available: 1.
- Verify that:
- the application process was absent before the notification attempt;
- a new application PID exists afterward, before opening the app;
- lifecycle logs show UI preparation while both the application and
its scene are in the background; - UIApplicationDidBecomeActiveNotification has not occurred yet.
- Wait before foregrounding the application.
- Open the application and verify that the same PID is reused.
- Observe the first didBecomeActive event and Firebase's automatic
app-start trace. - Repeat with a longer wait before foregrounding.
No sleeps were inserted into application startup code. The controlled
delay was outside the application, between background launch and
foreground opening. No debugger or process suspension was used during
the measured launches.
Simulator notification limitation:
The content-available-only payload returned UNErrorDomain 1401
("Notification has no user visible content"). After adding alert
content, the command returned UNErrorDomain 2003 ("Repository could not
save notification. Source is not authorized").
Successful notification delivery or display is NOT claimed.
Nevertheless, the notification attempt spawned a new application
process in the background. We independently verified the new PID and
the application/scene lifecycle before foregrounding that same process.
Observed results:
Run 1. shorter wait before foregrounding:
- Local UI preparation interval: 0.152 seconds.
- didFinishLaunching entry to first didBecomeActive: 7.260 seconds.
- Firebase automatic app-start trace: 7.321 seconds.
Run 2. longer wait before foregrounding:
- Local UI preparation interval: 0.164 seconds.
- didFinishLaunching entry to first didBecomeActive: 19.355 seconds.
- Firebase automatic app-start trace: 19.399 seconds.
Increasing the controlled wait before opening the app by 12 seconds
increased Firebase's app-start duration by 12.078 seconds, while UI
preparation changed by only 12 milliseconds.
The UI preparation interval is a local diagnostic measurement, not a
claim that a custom Firebase trace was collected in the background.
Firebase SDK Version
12.19.2
Xcode Version
27.2
Installation Method
Swift Package Manager
Firebase Product(s)
Performance
Targeted Platforms
iOS
Relevant Log Output
Run 1:
12.19.2 - [FirebasePerformance][I-PRF100009] Logging trace metric - _as 7321.1930ms.
Run 2:
12.19.2 - [FirebasePerformance][I-PRF100009] Logging trace metric - _as 19399.2940ms.
If using Swift Package Manager, the project's Package.resolved
Relevant Firebase pin from Package.resolved:
{
"package": "Firebase",
"repositoryURL": "https://github.com/firebase/firebase-ios-sdk",
"state": {
"branch": null,
"revision": "8c29ca981990a32e626c8617544fa65d22b1834f",
"version": "12.19.2"
}
}
If using CocoaPods, the project's Podfile.lock
Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
- Dominant language
- C++
- Stars
- 7k
- Forks
- 1.8k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 70
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firebase/firebase-ios-sdk
-
api: analytics
Difficulty 4/5 3-5 days Newbie friendliness 35/100
firebase/firebase-ios-sdk#17075 ·
Maintainers usually reply within 1 day
-
api: firestore
Difficulty 4/5 3-5 days Newbie friendliness 43/100
firebase/firebase-ios-sdk#17073 ·
Maintainers usually reply within 1 day
-
RTDB: `.info` listen `onComplete` runs off the repo queue, so `infoSyncTree` is mutated from two threads (crash in `FSyncTree applyOperationHelper`)Possibly taken @paulb777 claimed this 3 days ago. Open
firebase/firebase-ios-sdk#17069 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Firestore watch stream keeps an expired App Check token until the next Auth refresh (no-op App Check change listener in FirestoreClient)Possibly taken @dconeybe claimed this 5 days ago. Openapi: firestore
firebase/firebase-ios-sdk#17056 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
api: crashlytics
Difficulty 4/5 3-5 days Newbie friendliness 35/100
firebase/firebase-ios-sdk#17046 ·
Maintainers usually reply within 1 day
All issues in firebase/firebase-ios-sdk
Similar issues
-
feat
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Issue-Docs Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
microsoft/winget-cli#6692 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
stratum-mining/sv2-tp#167 ·
Maintainers usually reply within 1 day
-
better error message bug low priority semantics strings
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day