Skip to content

Startup Time

Gleb edited this page Jan 23, 2024 · 4 revisions

iOS Startup time refers to Apple's definition of Launch Time, it says that Launch Time is consist of two parts:

  • Pre-main time refers to the time when the system actually loads code into the process memory, executes static initializers for all classes (for ObjC and C++ code) and frameworks that are linked during launch.
  • Main time refers to the part of app initialization logic specific for the particular application and controlled by developer.

Since the Pre-main time is mostly controlled by OS rather that app developer, when we plan optimizations, we mostly focus on optimizing the Main time.

  • Cold start usually happens when you launch the app after the system reboot or if you've just installed the app. It is the longest possible launch.
  • Warm start refers to the time when user resumes your app, but app was already killed by the system because system needed more memory for other apps. Those launches are usually faster than the cold ones because pre-main time is smaller.
  • Hot start refers to the time when user resumes your app, when app was already running in the background.

We monitor only Cold and Warm app starts, it means only starts when app is not running in the background (when application:didFinishLaunching: method is called during the launch).

This is the visualization of App Startup process for Booking App: Startup Time visualization

Prewarming

Since iOS 15, your app can be launched in the background without a user tapping on the app's icon. As we measure startup time between the process start time and the appearance of the first view controller, this time measurement will be inaccurate in the case of prewarming. There may be several days between when the app is launched by the system in the background and when the user actually launches your app. That's why PerformanceSuite provides the appStartedWithPrewarming flag in AppStartInfo, so you can exclude pre-warmed startup times from your monitoring.

Implementation

To monitor startup time you implement protocol StartupTimeReceiver, and method startupTimeReceived() is called once per app session few second after the start. You can check documentation for StartupTimeData to see the description of different intervals.

Clone this wiki locally