Podcast Search

Under the Radar

317: Optimizing for Battery Life

Select a time to play from there. The line being spoken is highlighted as the audio plays.

0:00:00Welcome to Under the Radar, a show about independent iOS app development.

0:00:03I'm Marco Arment.

0:00:05And I'm David Smith.

0:00:06Under the Radar is usually not longer than 30 minutes, so let's get started.

0:00:09So today I want to talk about power, or in the context of the ways we use it, battery life

0:00:15is probably more specific because we're not particularly – like that is the limiting

0:00:20factor for a great many of our apps and the way that they get used, especially for things

0:00:25that we both make, which are long-lived, long-run applications.

0:00:29So if someone might use Pedometer++ to go out for an all-day hike, or they might open

0:00:35Overcast and listen to a podcast while going out on an all-day hike.

0:00:39And so in both of those cases, battery life and power consumption become an important aspect

0:00:45of the user experience.

0:00:46And battery life and power consumption are just a very difficult and challenging thing to optimize

0:00:53and to get right in a way that is sometimes – I personally find very frustrating, but

0:00:58it's something that I've been working on a lot recently.

0:00:59Like in the last few months, I've been working on a mode in Pedometer++ that's focused on

0:01:04sort of long endurance days.

0:01:06So like being able to go out and track a workout for maybe for 20 hours, that's a very different

0:01:11thing than if you're going out for a couple of – you know, like a 20, 30-minute run.

0:01:16And so I've been doing a lot of work on battery life and power management and sort of – it

0:01:21seemed a good topic to discuss.

0:01:23I think I have some – it's like some hints, some tips, some pitfalls, some frustrations.

0:01:27There's just a lot of things that kind of go into this because it's not as straightforward

0:01:31as some of the other optimizations we might be doing where it's very easy to just open

0:01:36instruments.

0:01:36You run it.

0:01:38You run your app with instruments connected, and you can run the time profiler, and you'll

0:01:41see where your app is spending the most time.

0:01:45And obviously that's related to power and battery consumption, but the power and battery

0:01:49implication of just using a lot of CPU is more nuanced and complicated.

0:01:54Because fundamentally, I think the thing that's challenging is ultimately power consumption

0:01:59is going to come from two things.

0:02:02One, the most obvious, is that it's just the work you're doing on the CPU, the GPU.

0:02:06Like, your app is, you know, doing something.

0:02:09That's what it's doing.

0:02:10And that work will use power.

0:02:13Just fundamentally, that's the nature of electronics and how these things work.

0:02:17And the other place you'll use power is if you are ever transmitting or receiving anything,

0:02:22whether that be sound, you know, photons from the display, Wi-Fi, GPS, any of these kinds

0:02:28of things that are sending or receiving any kind of data, those things are using power.

0:02:32And fundamentally, improving and extending the battery life of your app and reducing its

0:02:38power consumption is fundamentally going to be about doing less of one of those two things.

0:02:42Like, there is no magic other way to do this.

0:02:45It's just you have to either do less work, and that will get one side of your power consumption

0:02:51down, or you need to transmit or receive, you know, less.

0:02:55Whether that be, you know, the way in which you are gathering, say, like, GPS data.

0:02:59So that's very relevant for Pedometer Plus Plus.

0:03:01I've done a lot of work on that.

0:03:03Or in terms of Pedometer Plus Plus, it's dealing with, like, sending and receiving of light from

0:03:07the heart, you know, the heart rate sensor on the Apple Watch is a fairly meaningful, you

0:03:13know, consumer of energy.

0:03:16And those ones particularly are challenging because they run into sort of physics limits, you know,

0:03:23in the way that, like, if someone's playing a podcast from a phone speaker, if it's oscillating

0:03:28air back and forth from the, you know, from the iPhone's speaker, that oscillation is taking

0:03:33energy.

0:03:33And there's a certain amount of, there's nothing you can do about that directly.

0:03:37And so in that case, you're kind of stuck that it's going to use a certain amount of

0:03:40sound energy to do it.

0:03:42But there are things we can do on the consumption side.

0:03:45And I think the process of finding a good fit for this is just, it's a challenging road

0:03:49because inevitably in this, your job, you know, your app has a job to be done.

0:03:54And so you need to do that job.

0:03:58You have to see, like, the easiest way to use no battery is to do nothing.

0:04:01That's not particularly helpful.

0:04:03So finding the line between actually doing something useful and not being overly zealous

0:04:07and, you know, using too much of the user's battery life and then them being frustrated,

0:04:11you know, because they wanted to listen to a podcast for 10 hours and it ran out of battery

0:04:15at nine.

0:04:15Yeah.

0:04:16I mean, you know, the easiest way to have, you know, impressive battery life for your app

0:04:21is for people never to launch it.

0:04:22So, which is great.

0:04:24Like, you know, yeah, most people who download your app eventually don't launch it anymore

0:04:27if they ever did.

0:04:28So, you know, this problem does solve itself, but more seriously, and I think it's important

0:04:33to recognize too, like, there's a lot of different patterns of usage of apps and, you know, sometimes

0:04:40and there's also what people expect of, you know, apps and their power consumption.

0:04:46Those don't always necessarily line up and you have to kind of have reasonable expectations

0:04:51for what is realistic for your app in terms of power efficiency.

0:04:56Like, you know, in terms of, you know, if you have, I think some kind of, you know, common

0:05:02utility app where it doesn't really do anything in the background, there is occasional need

0:05:07to launch it, interact with it for a relatively brief time, and then close it.

0:05:12In that kind of scenario, you can do basically whatever you want and it doesn't matter.

0:05:17Like, it's not, like, unless someone's going to be spending a very long time in your app,

0:05:23it's probably not going to be possible for it to do meaningful damage to their battery

0:05:27life, even if you're, like, running all the radios and the GPS and everything.

0:05:31Like, you know, there's only so much you can do in a minute or two.

0:05:34But where this becomes more important is, you know, background tasks especially, or if you,

0:05:42if somebody is in constant interaction with the app.

0:05:45So, for instance, if, you know, if you have, like, a navigation app, that's probably going

0:05:48to be on screen for extended times.

0:05:50Certainly, you're going to be probably using the GPS radio.

0:05:53And there's all sorts of, you know, in that kind of case, there's all sorts of little, little

0:05:58tricks you can do to reduce your power consumption.

0:06:01Like, with GPS, for instance, you can, you can reduce the precision that you need or the update

0:06:05frequency, core motion and core location.

0:06:08Like, there's all these different parameters you can set to, to make that, you know, more or

0:06:13less efficient.

0:06:14You know, basically, when you're looking at power efficiency, the major areas that matter

0:06:20a lot are screen brightness, radio and GPS usage, which is a radio technically, but yeah.

0:06:28So, screen brightness, radio usage, and CPU usage.

0:06:31Like, that's, and GPU, of course, you know, but so, you know, processor usage.

0:06:34Those are the major areas that, that matter a lot.

0:06:39What surprised me about overcast development is that I, I found another area, as you mentioned

0:06:45a minute ago, that matters a lot, which is speaker usage.

0:06:48Like, if somebody's using the built-in speaker to push that air, to make that sound, that surprised

0:06:54me when I learned that that actually was a pretty big power draw.

0:06:56And the way I learned that was, it was not possible to learn that through any kind of tooling.

0:07:03There is no instruments simulator or Xcode meter that tells me how much power the speaker

0:07:09is using.

0:07:10The way I learned that was, a long time ago, I ran a test.

0:07:13I was curious to see, like, you know, what, what I was expecting to see was how efficient

0:07:21or inefficient AirPlay versus Bluetooth would be versus built-in headphones.

0:07:26Like, that, that was what I expected to find.

0:07:28And what, and what I expected to find was that using the Wi-Fi radio, which is AirPlay, was

0:07:33going to be less power efficient or more power hungry than using Bluetooth.

0:07:38And I expected both of those to be more power hungry than using the built-in headphone jack

0:07:44to power headphones directly.

0:07:45And what I found instead was, yeah, those matter.

0:07:48But if the phone is sitting around beaming stuff wirelessly to something else, that's

0:07:54actually pretty efficient for audio data.

0:07:57What I found was that the, the speaker in the phone by far was the largest power drain for

0:08:06overcast.

0:08:06Like, if you play out of the built-in speaker, it uses way more battery power than if you are,

0:08:12you know, sending it to headphones or speakers in any other way.

0:08:16So that's something that, like, I, there was no way for me to find that other than just

0:08:21like, all right, set up some tests, like, you know, make a test playlist, you know, play

0:08:26it from the beginning and just have it just go for hours and hours and hours.

0:08:30I turned off sync, you know, all that stuff, but like, you know, try to control it as best

0:08:34as I could.

0:08:35And it took, you know, like a week or two to run these tests.

0:08:38And, but eventually, you know, I got my results.

0:08:41And a lot of times that's just what you have to do.

0:08:43And like, you know, just like performance testing, a lot of times when you do performance

0:08:50testing, you know, you're, you're doing the CPU time thing with instruments or whatever.

0:08:53A lot of times things that you think will be really inefficient are actually fine.

0:09:00And you're spending a surprising amount of time or something as surprisingly costly that

0:09:05you wouldn't have guessed would be.

0:09:06And that exact same pattern holds in my experience for any kind of power and battery testing too.

0:09:13And there's all sorts of ways that you can, you know, unknowingly waste power.

0:09:18Like, like one of the common things is if you have some kind of internet connection requiring

0:09:24operation, say like a background sync.

0:09:27One of the ways that, one of the common pitfalls for that that I have found is what happens if

0:09:32the sync fails?

0:09:33And this can happen, for instance, if the person is like on a, on a subway and they lose their

0:09:38connection for a few minutes or they're just, you know, they're hiking in the mountains

0:09:41and they're offline, you know, what happens if the person's offline and some operation

0:09:47in your app tries to use the connection?

0:09:49What can happen is that can start going in a loop, just trying to hammer it over and over

0:09:56and over again, making that request over and over and over again, which can not only make

0:10:01the radios keep trying to connect, but can also burn CPU power by a lot.

0:10:05And so there's situations where like you might not even realize like, oh, my app seems really

0:10:11efficient, but if you're offline, it turns out you like power usage spikes and you might

0:10:16never know that in your testing unless you're doing offline power testing somehow, which is

0:10:20not a super common thing.

0:10:21I don't think people test for, but like there's all sorts of surprises when you do power testing

0:10:26that you don't realize like, oh, if I, if this weird condition happens, this will infinite

0:10:32loop or this process will spin forever or it'll, it'll keep trying to do this thing.

0:10:36So there's all sorts of things like that.

0:10:38But then you have to contend with, even if you do a really good job of power optimization,

0:10:44if your app is inherently doing something that requires a lot of power that the user has explicitly

0:10:52asked you to do, whether that's playing podcasts very loudly out of the built-in speaker or just

0:10:58using an app constantly with a screen on that happens to use, you know, the network

0:11:02or GPS, like if, if that's what your app is doing, it's going to use a lot of power and

0:11:07people, people are going to go into that battery section of their, of their settings and they're

0:11:10going to see your app on top, even if they were using it that whole time.

0:11:14So to some degree, this also creates marketing challenges or user support challenges in the

0:11:20sense that like people, even if people like, you know, spend the energy knowingly with your

0:11:27app, they will still blame you if it's inefficient, even if there's nothing you can do about it.

0:11:33So there are, there are a lot of, a lot of, um, you know, sprawling places that, that power

0:11:38testing and power mindfulness can take you.

0:11:42Yeah. And I think in that there's this funny aspect of, yeah, like there, there's a fundamental

0:11:48limit that you run into with power, power efficiency testing. Like at a certain point,

0:11:53this is at least has been my experience is like, I've done a bunch of things and I think there's

0:11:57some tools that I've, or strategies I've taken that I think would be useful to discuss, but broadly

0:12:01it's like there's at a certain, you will inevitably hit this point that this is just like, this is the

0:12:06floor and you can't go any lower. Um, and that is frustrating insofar as if that number is

0:12:11too high and you're going to either have to diminish the user experience in terms of do

0:12:16something different. Like that was ultimately like in the case of Panometer plus plus, what

0:12:20I found is that if you run, you know, essentially continuous GPS and all of the workout tracking

0:12:26stuff that you can do on an Apple watch, it is as far as I can tell, not possible to get

0:12:31the sort of the 20 hour goal that I was trying to get on my Apple watch ultra. Like it was just

0:12:36not possible that if in the way I determined that is that I built.

0:12:40A stripped down version of my app that did nothing but those two things using just the

0:12:46system APIs as basic as I could make it and ran that. And like, so at this point I'm confident

0:12:51that it's not, you know, Swift UI getting into a funny state and using lots of data or other

0:12:57background processing or refresh, you know, things. It's like as minimal of an app as I possibly

0:13:02could. And I ran it. And like, at that point I determined this is the floor. If you do this

0:13:07and this and this, it is going to take at least this amount of battery to do it. And so like

0:13:11in my case, I've worked out, well, what if I don't do this? What if I do this? You know,

0:13:15every, I only get the heart rate every so often rather than, you know, every second, which is

0:13:19the default. Um, and those kinds of operations are things that you just have to choose because

0:13:23otherwise that floor is fixed and there's nothing you can do about it in the sense of, you know,

0:13:29in your case, it's like playing the sound at full volume out of the, out of the speaker.

0:13:32There is a floor there that is going to be ascribed to you that you can do nothing about.

0:13:37It doesn't mean there aren't things we can do to still be helpful. And I think that's

0:13:40the interesting aspect of a lot of this is it's finding the places where there are these pain

0:13:46points. And particularly it's finding them, yeah, finding the things that will get run,

0:13:49sort of run away from you. As I think something that very often seemed to be a pattern for what I

0:13:53was finding, um, in my work and like actually ran into a specific example of what you were,

0:13:57you were just describing where I had a thing that was loading, you know, loads map tiles.

0:14:02And typically when the app is set up such that you would download your map tiles ahead of time

0:14:07so that you have them sort of offline. Um, but if you don't do that and then you go off into the

0:14:12wilderness, what I would, I discovered is that, um, as soon as you lose connectivity and it tries to

0:14:17load every time SwiftUI updates the map, it will try load again and try load again and try load again.

0:14:23And obviously like at some point the system is intelligent about that in terms of if it,

0:14:28you know, if the, if it has no internet connection, I suspect that those are failing

0:14:33instantaneously. So it's not like this terrible loop, but it's still a bad loop. And it's in this

0:14:38exact situation where the user does not want their battery to be running down. And so it's like,

0:14:43that was something I have to resolve and have to deal with. Um, cause you have to find these situations

0:14:48where you're going to use lots of battery. And I mean, the reality with this, that is feel,

0:14:52it feels very like scientific method, but it's this very interesting process you have to do of

0:14:57designing experiments to isolate particular variables and then running actual like real

0:15:04world tests. Because there's something about battery testing that is frustrating is that very,

0:15:09you know, to, to understand your battery consumption over eight hours, you have to do the thing for

0:15:15eight hours. Um, and this is a situation where I very much envy Overcast being able to just play audio

0:15:21rather than if you want to test what it's like to track the GPS coordinates of an Apple watch moving

0:15:27through space, you kind of have to actually move the Apple watch through space for eight hours, which

0:15:32is, is fine. If you know, you're like me and I'm, I'm training for a long event. And so I very often

0:15:37have the, you know, the exam, the opportunity to do that, but it is going to be really frustrating

0:15:42when you're supposed to be going out for like an, you know, an eight hour hike and, you know,

0:15:47an hour into it, you realize this is a bad build, like something's wrong, something, you know,

0:15:50something you did isn't right. And just like, well, I guess this test didn't work. And I'm just,

0:15:54you know, I'm just going to have to try again the next time I go for a long hike. Um, cause you just

0:15:58have to design these experiments and try things out and be, you know, be experimental, be creative

0:16:03with it is something too. I think like you were saying is it isn't always going to be the thing that

0:16:07you think. And so to some degree, you have to isolate different variables, experiment and test

0:16:13them separately, and then make sure that you're trying to be holistic in that approach of understanding

0:16:18that it isn't necessarily the obvious thing that is going to be the most power consumptive.

0:16:22Sometimes it's going to be other things. And so, you know, you'll turn things off, um, incrementally

0:16:28or, or experimentally and try and isolate like this variable seems to be where things are, you know,

0:16:34where things are getting stuck or where there's extra power consumption, where maybe there doesn't

0:16:38need to be, or if it's above what you, you know, what, what it seems to be. And so that's kind of

0:16:43what we end up having to do, or at least as far as I can tell, that's what you're going to do. And

0:16:47there's no easy way around it because you can, in order to really know the real life results,

0:16:52you have to actually go out into the real world. Like I love the simulator for testing my core location

0:16:57stuff. And I've all, you know, this, there's, we've talked about SimGenie before, which is a great tool

0:17:01for being able to, you know, reproduce GPS tracks in the simulator. So you can actually test your like

0:17:08logic for that. And that's useful to some degree in terms of I've done a lot of work, you know,

0:17:12that improves my battery life by making my algorithms more efficient, which I can do in

0:17:16the simulator. But ultimately at some point you're going to have to lace up your shoes, get out and

0:17:21actually test it in the field or try it in the situations where it's going to be used. Because if

0:17:25you don't, you won't actually know what the battery life will be used in practice.

0:17:29Yeah, exactly. And that's, that's the answer to so many of these things. Like a lot of times it just

0:17:34depends because battery life, you know, with, with the big users of it, like the screen brightness,

0:17:39the speaker, you know, the usage of GPS, like those are, those are big users of it. Those it's kind of

0:17:48obvious when, you know, like, okay, using the radios is power inefficient. Well, if you can like use them

0:17:56less frequently, maybe batch your requests, they don't have to like constantly wake up, you know,

0:18:00connect to whatever, and then go back to sleep. Like that, that, that's kind of more obvious.

0:18:04Sometimes when you're dealing with optimization of processor usage or, you know, like load on the

0:18:11processor, sometimes it's less obvious what will matter and what won't because the processors are

0:18:18really complicated. And this is partially true of the radios too. The radios are also very complicated,

0:18:23but the processors, I think more than anything, this is where you have to often just try stuff and you

0:18:29can't rely on the little meter and Xcode that says power use, you know, power impact low, you know,

0:18:34like that's, that's a very coarse mechanic because the reality is the processors, oftentimes they're

0:18:41doing such complicated things. They're, they're managing their power. So in such a complex way,

0:18:46they're, they're splitting tasks between the efficiency cores and the performance cores, you know,

0:18:51they're, they're ramping up the clock speed and then ramping it back down, like, you know,

0:18:55many times per second, like, you know, like they're, they're doing these things that sometimes

0:18:59what you think will be inefficient or efficient won't be. Um, because sometimes they can, you know,

0:19:06like for instance, if you have a certain amount of computation to, to do, and it doesn't really

0:19:11matter when you do it, you might think, let me do a little bit at a time. So the CPU is only like,

0:19:15you know, 5% used for a long time. Well, that actually might be less efficient than using a hundred

0:19:23percent of a core for five seconds and then stopping or whatever, because that can actually

0:19:28like the, some core might have to stay awake longer than it would if it's doing a long running small

0:19:35task, as opposed to being able to do a big burst of work and then go to sleep for a longer time after

0:19:41that. Um, the, this, this, um, pattern is called race to sleep. And the idea is oftentimes it is more

0:19:47efficient with modern, uh, processors often is more efficient to just do the work really fast

0:19:53at maximum power and then stop and then, you know, sleep for as long as you possibly can before you

0:19:58ask it to do more. Um, and sometimes the opposite is true depending on whether that task, you know,

0:20:04can run on an efficiency core or not. So, you know, as you were saying, Dave, like there is really no

0:20:08better answer than you got to just test this stuff and be, you know, be willing to experiment.

0:20:13And again, to many apps, this won't even be necessary to many apps. You know, if people are just

0:20:19launching it briefly, no problem, like do whatever you want. But once you have

0:20:22something long running, if it's some kind of, you know, background thing or, or, you know, long

0:20:27foreground usage, this is going to start to matter a lot. And people, people are going to notice like,

0:20:33Hey, does my phone get hot while I use this app? Or does my battery sync dramatically? Like that,

0:20:38that does matter to people a lot.

0:20:40Yeah. And if, and if you'll allow me a brief rant, I'm very frustrated by how the tooling we have

0:20:48for this is because ultimately, like I said, we have to just do these tests. And I feel like it is,

0:20:53it feels very frustrating in like whatever the 18th year of iOS's existence. That's so often I'm falling

0:21:00back to like in the console, logging the battery percent as reported by the system as the best tool

0:21:07I have for a lot of these things. And as a side rant, it is very frustrating that debug builds,

0:21:13you know, I'm clearly a developer doing this thing. We'll still have the masked battery percentage

0:21:19reported to it, which is like, where it like rounds to the nearest 5%.

0:21:22Oh yeah.

0:21:23Which is like, why are you doing that to me? Like that, that's, that's unnecessary. I understand it

0:21:27makes sense in, you know, for fingerprinting reasons and things in like production apps, but come on,

0:21:31I wish that would just give me the actual number so that I don't need to run things for like twice as long

0:21:36to make sure that I'm averaging out the weird sort of rounding issues and errors there. But

0:21:41nevertheless, it's something that I was just really surprised by when I went and wanted to do

0:21:45like power analysis and these kinds of things. Like I expected there to be like a really detailed

0:21:50instrument in Xcode that would give me a lot of the detail that, that I might want. And as far as I

0:21:56could tell, there's some very basic things and some of them have sort of come and gone over the years.

0:22:01Some, like sometimes you, I find these articles about tools which don't seem to exist in Xcode

0:22:05anymore. But like, ultimately I kind of get a lot of t-shirt sizing with the power consumption

0:22:10is the best you can do where it's like, you're doing small, medium, or large amounts of battery

0:22:16use right now, which is like, okay, but if I'm trying to optimize things more specifically, it'd be

0:22:22really helpful if there was some amount of more like, you're using so many, whatever, like, you know,

0:22:27milliwatt hours or milliwatts per hour, whatever, like some measurement that I could actually be basing

0:22:32something on or things like that. And I understand obviously measurement always has overhead. And so

0:22:38that's, maybe that's why some of these things don't, aren't in there, but like in a lot of circumstances,

0:22:42I wish I could take on that overhead and understand obviously it's doing a lot of extra work. So the percent,

0:22:47you know, the battery percent would no longer be representative, but the measurement of what my app

0:22:52was doing or what the overall system power draw is could be consistent between runs or those kinds of things.

0:22:58And it was just a very, it was something that really surprised me where I feel like a lot of like instruments is

0:23:03amazing and continues to get better every year, it seems, but power when battery life particularly just didn't seem like

0:23:10something that there was nearly as much detail and ability for us to dig into. And particularly if you're doing

0:23:17anything with watchOS, like it was shocking to me how challenging it was to, because even some of these like t-shirt sized

0:23:25power usage things don't seem to apply on watchOS. And so on what I ended up doing for a bunch of my apps, like I was

0:23:31saying, I was like combining, stripping these things down to their smallest parts. And sometimes I would just run the

0:23:37library that I had written on my iPhone and see how it works there where I could actually get some bit more data there and run and have a

0:23:44slightly faster sort of testing cycle there. And obviously the iPhone is not an Apple Watch, but it is

0:23:50close and, you know, things that are bad on the iPhone are likely also going to be bad on watchOS. And so I was able to

0:23:56catch some issues that way. But it was just one of these things that I was very surprised by. And maybe it is to your

0:24:00point that a lot of, there's certain kinds of apps that just don't need to worry about power consumption

0:24:07dramatically that, I mean, in a way that like Widgetsmith, you know, is an app that I don't think I've ever really

0:24:11paid much attention to its battery consumption. Because it's an app that users tend to open,

0:24:17do an operation for a short period of time, and then close the app, and that's it. And so it's very

0:24:23unlikely Widgetsmith's ever going to show up, you know, in a very heavy, heavy way in a user's

0:24:27battery meter. But in the places that I do use it, boy, do I wish there was some kind of way that I could

0:24:33have a better insight into it. I mean, it reminds me of those things you'll see in like when you're playing,

0:24:37you know, people are playing video games, and they have like a little HUD that has the current,

0:24:40you know, frames per second and details about the rendering. It's like, boy, do I wish I could just

0:24:45have a little HUD on the top of the screen that was telling me the current pain of power consumption as

0:24:48it's being drawn from the battery or something. Like that would have made my life so much easier and

0:24:52saved me so much time in this process.

0:24:54You know what you should do? You should scale it up to be able to run on a Mac Mini,

0:24:57spin up like, you know, a hundred of those processes and just put a kilowatt meter between

0:25:01the Mac Mini and the wall, and you can see how much power it's pulling.

0:25:05Just take the battery completely out of this, out of the loop, and just do it purely by the amount

0:25:11of power draw that is happening on the computer. There you go. Problem solved. I don't know why I

0:25:15didn't think of that.

0:25:18One other thing I wanted to mention is programmatically adapting to low power mode. So this

0:25:24is one thing you can do on the process info object. There's an is low power mode enabled property,

0:25:29and there's some notifications there when it changes to if you want to monitor it that way.

0:25:32This is one of those things that I thought was a great idea. And so I tried it. And it turns out,

0:25:40so my thinking was, how about when the device is in low power mode for overcast, maybe I do things

0:25:47like, you know, reduce the frame rate of animations that I'm generating manually, like those waveform

0:25:52animations I had, like in the pause button. Maybe I reduce the frame rate of that. Maybe, you know,

0:25:57more importantly, maybe I will reduce the frequency at which I sync back to the server. Or maybe I would

0:26:04defer tasks like downloading, you know, like checking for artwork changes for podcasts and downloading new

0:26:09artwork. Maybe I, you know, defer those until it's not in low power mode. And that was a great,

0:26:13those were all great ideas. And they all failed. Except for the animation frame or anything. I think

0:26:18I actually kept that one. But everything else I had to abandon, because the reality is many users out

0:26:26there basically use low power mode all the time. It's a very, very common usage pattern that people just

0:26:33like every day they just pick up their phone and flip on low power mode. And so you can't, you shouldn't

0:26:40change anything in low power mode that would negatively affect your app if that was always the condition under

0:26:47which it was running. So for instance, I was like, I was deferring artwork updates when I, this was years

0:26:52ago now. But you know, I had this idea, I'll defer artwork updates. And I was getting complaints from

0:26:57people saying, I like, but I have the wrong art for this podcast. And I like, I would have, I would

0:27:03occasionally begin with some of them. And oftentimes it was, I would get to this question, and they were

0:27:07actually running low power mode all the time. And so it was just never having a chance to update.

0:27:11And so this is something that you can, you can do, and you know, you can make minor tweaks to what your

0:27:17app is doing in response to low power mode. But I would not recommend making major tweaks. Because

0:27:23and even if you tell the user, maybe if you have a banner up saying, you know, sync deferred because

0:27:27of low power mode or whatever, like, that's not going to solve your problem. Because that's not going to

0:27:30make people, you know, change their power using their phone. That's just going to make them, you know,

0:27:34not use your app or complain about it. So be careful what you change in response to that. And make sure

0:27:41it's something that the ramifications aren't too bad if you are never running in regular mode.

0:27:47Yeah, and I think, so I ran into a similar sort of pattern then in the end of this update I'm

0:27:52working on, where I was thinking, oh, if the user's in low power mode on their watch, like I should

0:27:57do different things. And I think what I ended up settling on is that for the same reasons you're

0:28:01describing, I think it would be better. And this is sort of where I'm going is there's a mode inside of

0:28:06the app that does different things. And is the sort of the expedition mode,

0:28:11the long run, you know, long, long walk kind of mode that the user is specifically opting into,

0:28:18rather than responding to the system flag, which can be on for a variety of reasons.

0:28:22It's the something that the user is saying, hey, I want to maximize my battery life,

0:28:29I want to turn this on. And they're making a positive choice to do that, rather than assuming

0:28:34that the reason they have low power mode on is because they want those low power features. They

0:28:39may want all of the capability, but, you know, just are turning that on out of habit or out of sort of

0:28:46other, other reasons or other needs. And so, or similar, like I think of in watchOS, there's some

0:28:50switch, you know, some switches that you have to go and turn on if you want to enhance the battery life

0:28:55in low power mode. Like it takes, can take fewer GPS readings or heart rate readings in the main

0:29:01workouts app, but you have to go and turn that on rather than the system just assuming, oh, you're in

0:29:05low power mode. I'm going to do that for you because you just don't want to make assumptions. And you

0:29:09don't ultimately in all of this battery life is a tension between user experience and capability

0:29:14and power. And like, you just, there's a certain trade-off that you have to make there and be careful

0:29:19about making assumptions about that is exactly right. Like you don't want to assume that the situation

0:29:23is any one state, whether that's low power mode here, whether that's, you know, network

0:29:29connectivity, whether it's screen brightness, volume on the speaker, all of these things are just these

0:29:33variables we're trying to balance between. And if we can get the balance right, we can improve the overall

0:29:38battery, you know, user experience by giving a user more time with our app, which is ultimately

0:29:43wonderful, but we just have to be thoughtful and careful, you know, to arrive at that place in a way that

0:29:47makes everybody happy.

0:29:48Thanks for listening, everybody. And we'll talk to you in two weeks.

0:29:52Bye.