We want our system to perform as smoothly as possible. It can suspend your app, and you'll stop consuming the user's battery. That way, if the system gave your app time to run, you can tell the system, hey, I'm done a little early. If we run for less time, we'll drain less battery.Īnd so, when we design APIs, we focus on the right amount of time to run to support specific use cases while maintaining great battery life, and when using these APIs, think about how to be efficient and alert the system when you're done doing work by calling completion handlers. If we run for longer, then we'll drain more battery. So, we can plot the times our app runs in the foreground in these lightly shaded rectangles, and we can plot the time the app runs in the background in these darkly shaded rectangles. The left might be the start of the day when the sun rises, and the right might be the end of the day, and maybe the user decides to plug in their device towards the end of the day, and we have that green charging region to represent that. To visualize this, let's take a timeline. Whenever your app is running in the foreground or the background, it's using power, and over time, this drains energy and can drain battery. For example, maybe the user entered some foreign region or maybe there was some new health data that your app needed to be made aware of.Īnd when running in the background, we care deeply about user experience, so there are many important factors we consider when we design APIs to support these use cases. The second way is through specific event triggers where the app gets background time in order to respond to something that happened in the world. You can think of something like downloads or periodic updates or maybe finishing some foreground work. This applies to more generic background execution where the app wants to perform some work and it makes a request to the system. Now, why do we enter this state? It really boils down to two ways. So, looking at this diagram, we're talking about that third box where the app is running in the background but it's not necessarily visible to the user. Background threads or background queues, but when we're talking about background execution, we're talking about the app running or executing code while it's not in the foreground. We can begin by answering the question of what is background execution? What do we mean? So, when we think of background, it can mean many things. Let's begin with an overview of background execution. So, today, we'll talk about background execution, give a general overview, then talk about some best practices to follow, and finally, my colleague, Thomas, will come up to introduce a new background task framework that offers new background execution opportunities. And at Apple, we design APIs that give background execution to enable these use cases and experiences. So, if we come up with a list of what might require background execution, we might come up with something like this, things like navigation or accessory communication or maybe periodic updates and downloads. Some of these are in the foreground when the user is actively using the app, and some of these are in the background and require background execution in order to be possible. Users love apps, and they love apps because of the many great experiences that they enable. I'm Roberto from the Software Battery Life Team here at Apple, and I'm really excited to talk to you guys today about advances in App Background Execution.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |