mfaani
mfaani

Reputation: 36427

What's the difference between cold launch, warm launch?

Are these terms defined by Apple? Does cold mean app was killed. And warm means app was in memory?

Upvotes: 0

Views: 3052

Answers (1)

mfaani
mfaani

Reputation: 36427

From docs on Reducing Your App’s Launch Time

Your app activation varies significantly depending on previous actions on the device. For example, on iOS, if you swipe back to the home screen and immediately re-enter the app, that is the fastest activation possible. It’s also likely to be a resume. When the system determines that a launch is required, it is commonly referred to as a “warm launch.”

Conversely, if a user just played a memory-intensive game, and they then re-enter your app, for example, it may be significantly slower than your average activation. On iOS, your app typically was evicted from memory to allow the foreground application more memory. Frameworks and daemons that your app depends on to launch might also require re-launching and paging in from disk. This scenario, or a launch immediately after boot, is often referred to as a “cold launch.”

Think of warm and cold launches as a spectrum. In real use, your users will experience a range of performance based on the state of the device. This spectrum is why testing in a variety of conditions is essential to predicting your real world performance.

From WWDC:

So, let's take a look at those launches I talked about before, there's a cold launch, a warm launch, and something is often referred to as launch, but isn't quite a launch, a resume.

Cold launches occur after reboot, or when your app has not been launched for very long time. In order to launcher app, we need to bring it from disk into memory, startup system-side services that support your app, and then spawn your process. As you'd expect, this can take a little time, but fortunately, once it's happened once, you'll experience a warm launch. In this case, your app still needs to be spawned, but we've already brought your app into memory and started up some of those system-side services. So, this will be a little bit faster and a little bit more consistent.

Finally, there's that resume. This occurs when a user reenters your app from either the home screen or the app switcher. As you know, the app is already launched at this point, so it's going to be very fast. What you need to remember from this is not to confuse resumes with launches when you're taking measurements

tldr:

every time you hit the app icon, it can be one of the 4 following states:

  • app wasn't launched for a long long time or it was just launched after a reboot
  • app was launched and killed before. But launched again. So some system services are still in memory.
  • app was launched before, but got suspended to reduce memory, it's process is still ongoing. Hitting the app icon won't trigger an app launch
  • app was launched, but then only backgrounded. It's still in memory. e.g. you've had app put in background while listening to music or location tracking. So tapping on the app on the app icon, won't trigger another app launch. (this scenario wasn't mentioned in the above docs, but was worth mentioning)

enter image description here

Upvotes: 4

Related Questions