0:00:00Welcome to Under the Radar, a show about independent iOS app development.
0:00:04I'm Marco Arment.
0:00:05And I'm David Smith.
0:00:06Under the Radar is never longer than 30 minutes, so let's get started.
0:00:10So we are in the tail end of, I guess, big update season,
0:00:15and it's a time of year where one of the things--
0:00:18we've talked about many aspects of what this looks like
0:00:20and of the changes that come and how to manage new APIs
0:00:24and adopting things and dealing with backwards compatibility with old devices,
0:00:29but I think an area that I think is useful for us to kind of talk about
0:00:33is the ways in which sometimes our apps are changing underneath of us,
0:00:39or there are updates or things that are changed inside of iOS or WatchOS
0:00:44or whatever operating system you're working on
0:00:46that can then cause problems for application
0:00:49where ostensibly code that hasn't changed, unrunning things,
0:00:53can potentially be turned around in iOS updates and cause lots of problems.
0:00:58And it can manifest itself in a lot of different areas that we'll kind of talk through.
0:01:02But I think it's an area that, like this year in particular,
0:01:06I think there was a lot of this where iOS 13, WatchOS 6 had a lot of--
0:01:12there were a lot of changes in some of the lower-level parts of the system
0:01:17that, at least for my applications and I think for yours as well,
0:01:20there's been just issues.
0:01:22And some of these are user-facing.
0:01:24Some of these are things that are indirectly user-facing.
0:01:27There's been a lot of changes in the way that when your app is backgrounded
0:01:32how likely it is that it will remain in the background
0:01:34versus being terminated and then relaunched,
0:01:37which is sort of user-facing and sort of not.
0:01:40In your case, if someone's listening to audio and they get killed,
0:01:44the user would be aware.
0:01:46But even just otherwise, if the user has to, when they tap on your app icon,
0:01:51if it relaunches with a full relaunch versus just immediately restoring,
0:01:56it makes the app feel more responsive.
0:01:58It makes it feel good.
0:02:00But being aware even that your app is being killed in the background
0:02:02is something that is sometimes awkward to notice
0:02:05or something that's hard to see.
0:02:07I mean, especially a lot of these behaviors are really tricky
0:02:10when they don't really happen when you're connected via Xcode
0:02:13to your application because your app is rarely killed in the background
0:02:17while it's in an active debug session.
0:02:19I imagine the app is kind of given a different level of priority
0:02:25in that context than it would if it was just running
0:02:28and then you go off and do other stuff.
0:02:30And so these are often kind of tricky to do.
0:02:32So I think there's an interesting thing to just kind of talk about,
0:02:34A, identifying these things.
0:02:36What are some of the kind of pitfalls that are likely to cause problems
0:02:40when things change in iOSes?
0:02:42And then just kind of some of our experiences and then some of the tools.
0:02:46I think Apple has increased dramatically some of the tools
0:02:49that we have at our disposal, and the organizer especially,
0:02:52to identify these kind of behaviors
0:02:54and then so we can kind of respond to them accordingly.
0:02:57- Yeah, exactly.
0:02:58I mean, and I've been facing so many issues like this.
0:03:01And the thing with issues like this where the system is terminating your app
0:03:05for some reason or just because it wants the memory back for its own purposes,
0:03:10many of these issues are mostly out of your hands.
0:03:14Many of these issues are not your fault, but many of them are.
0:03:18And it's often hard to know the difference.
0:03:21And it's hard to necessarily even know that you're having these problems in your apps.
0:03:25Because for the longest time, there was either minimal reporting on this
0:03:30or it wasn't being reported at all.
0:03:33And even if you use a third-party crash reporter framework,
0:03:38I think those still mostly don't get things like energy log terminations
0:03:42and stuff like that.
0:03:43So you really have to look in the organizer in Xcode
0:03:46and look at the crash logs there and the energy logs there
0:03:50to really have an idea of how bad of a problem do you have with these things
0:03:54and why and when are you getting killed.
0:03:58And unfortunately, like, you know, iOS since the very beginning
0:04:02has had, as part of the public API, has had these low memory warnings
0:04:07where on every view controller you get that method that's like,
0:04:11you get notified if the system's on memory
0:04:13and then you have a chance to release some memory.
0:04:16And if you don't release enough memory, your app's probably going to get killed.
0:04:19There is no equivalent to that for tons of other conditions
0:04:26that can get your app killed.
0:04:28And it seems like in every major version of iOS,
0:04:32they seem to be adding more of these.
0:04:34And watchOS also, as you are very well aware,
0:04:37you know, watchOS from the very beginning has had a lot of, like,
0:04:39super tight restrictions on things like how much CPU time your app can use,
0:04:43how many seconds it has to, before it has to, like, you know,
0:04:47draw its snapshot or whatever.
0:04:49There's all these different conditions like that where not only are most of these restrictions
0:04:54undocumented and changed between OS releases,
0:04:56normally in the direction of getting more strict and having more restrictions,
0:04:59but also there is no public API, there's no notification,
0:05:03there's no callback, there's nothing that serves as a warning signal to your app
0:05:08so that you can, like, change what it's doing before it just gets killed by the system.
0:05:13So you really have to dig through these logs to even find out that you are getting killed for this reason.
0:05:18And a lot of times the logs will reveal what the limit is,
0:05:23but sometimes they won't really reveal, like, how you hit that limit or why or what your app was doing.
0:05:28They try to have stack traces on some of them, but they're often not very helpful
0:05:33because it isn't, like, an actual crash.
0:05:36All they can do is, like, sample, like, what it happened to be doing at the moment it decided to terminate the app,
0:05:41but that oftentimes is not related to why it was terminating the app.
0:05:45And so it's very, very hard to figure some of these things out.
0:05:49And the tooling, in some ways, like the Xcode organizer,
0:05:54especially in the new, in Xcode 11, there's this new metrics tab,
0:05:59and this is super interesting.
0:06:01Like, if you haven't taken a look at the organizer in a while,
0:06:03open up Xcode 11, go to the metrics tab,
0:06:06and it reports all sorts of great, useful information about the versions of your app
0:06:12that have been submitted to the App Store,
0:06:14and over time, how things like battery usage and memory usage and launch time,
0:06:19how those have changed over each release.
0:06:21So you can see, like, for instance, one of the metrics here is disk writes.
0:06:26If your app writes too much to the disk, as of iOS 13, it gets killed.
0:06:31I believe that's even new to iOS 13.2 or 13.1.
0:06:35But if you just write too much to the disk in a certain period,
0:06:38again, these limits, I don't think, are documented anywhere,
0:06:40which is a common problem with Apple these days,
0:06:42but I don't think there's any likelihood of doing this,
0:06:45but if you write too much to the disk, you get killed.
0:06:47And I was having this issue with a couple versions ago.
0:06:51I was updating the search index to Overcast too frequently,
0:06:56and it was causing a lot of disk writes,
0:06:58and I started getting killed during the early 13.2 betas,
0:07:01or whatever this was, 13.1,
0:07:04and I had to figure out, okay, well, how do I write to the disk? Less.
0:07:09And it's kind of hard when someone's downloading a bunch of,
0:07:12when they're downloading a bunch of stuff to their phone,
0:07:15it's kind of hard to avoid writing to the disk to the things they're downloading.
0:07:18But I could look at things like search indexing and say,
0:07:20all right, well, that's something I have control over,
0:07:22so I can at least reduce that.
0:07:25And so I submitted new versions that reduced search indexing,
0:07:28and sure enough, they did.
0:07:30I could see right in the graph on the metrics tab in the organizer,
0:07:33I can see the disk writes went way down after that update,
0:07:37and hopefully down to a point where I'm getting killed less.
0:07:40And so there's all sorts of tooling here, you know,
0:07:43some of which is helpful, some of which is not.
0:07:46Man, I sure wish that we would have more of this information accessible
0:07:51in the app at runtime before getting killed.
0:07:54And there actually is,
0:07:56there was a good article on NS Hipster this past week,
0:07:59there actually is a metrics kit, I believe it's called,
0:08:02that gives you access to some of this stuff at runtime,
0:08:04but it doesn't give you, as far as I can tell,
0:08:06it doesn't give you things like the warnings about, like,
0:08:09hey, you're going to get killed in a few seconds
0:08:11for using too much CPU time.
0:08:13Like, that's something, like,
0:08:14I would love to have a notification for that
0:08:17so I could do things like, hey, you know what,
0:08:18if I'm currently doing something optional that's burning CPU,
0:08:21just stop doing it, you know, stuff like that,
0:08:23stuff like, you know, watch trans codes and search indexing
0:08:25and stuff like that.
0:08:26Like, I do all sorts of crazy stuff,
0:08:28like if I think you're plugged into power
0:08:29and can afford the hit, but if you don't pay attention
0:08:34to this kind of stuff, you'll get reports from people
0:08:37just basically saying, like, hey, your app crashed
0:08:39while I was using it,
0:08:40or your app keeps crashing in the background
0:08:42and I don't know why.
0:08:44And there's plenty of reasons your app can be killed
0:08:48in the background that Apple doesn't really tell you
0:08:49much about, that at least the ones they will tell us about,
0:08:52we can at least do something about that
0:08:53and pay attention to these metrics
0:08:54and start looking at the logs and try to do something
0:08:57that might help this out.
0:08:59- Yeah, 'cause I think the thing that is,
0:09:00other than previously, ultimately,
0:09:02which I feel I found like I would have to do before,
0:09:05without having access to this kind of metrics,
0:09:07there's a little bit of just you are getting
0:09:10the sort of the hearsay reports version of this,
0:09:13which is just someone is reaching out
0:09:16via customer support or whatever
0:09:17and you're just kind of noticing a trend,
0:09:19'cause often these things aren't immediately obvious.
0:09:21Like, there are some that just are.
0:09:23Like, I recently, especially with working with SwiftUI,
0:09:26there's a bunch of things where like,
0:09:27between watchOS 6 and 6.1,
0:09:29there were some like dramatic changes
0:09:31in how SwiftUI rendered.
0:09:33And like, all of a sudden my UI was just broken,
0:09:36you know, on 6.1.
0:09:38So I had to like rewrite it and change it.
0:09:40And like, those kinds of things are great in some ways.
0:09:43Like, while I'm not excited that SwiftUI is still young
0:09:48and constantly changing, it is nice that like,
0:09:51here's this very definitive thing that a user will write in
0:09:53and say like, you know, this label is truncated.
0:09:57And like, on 6.0 it wasn't, on 6.1 it is.
0:10:00And like, it's the same code running.
0:10:02Like, great, that is a nice, easy to identify problem
0:10:04that is like, you know, I can deal with that.
0:10:07What was often tricky with a lot of these kinds of issues
0:10:10is where they're so amorphous that you're just kind of
0:10:14looking for these kind of general trends.
0:10:16Like, is, you know, say you have some operation
0:10:20that only happens on app launch.
0:10:22Like, there's a certain server call, say,
0:10:24that only happens on app launch,
0:10:25or typically happens on app launch,
0:10:26and you're seeing more of those calls to your server
0:10:30after an iOS update than maybe there's something to do
0:10:33with the app being launched in the background,
0:10:35or things like, I remember doing this kind of detective work before,
0:10:39but it's nice to have increased visibility into this.
0:10:42And one thing I will say too that I love about
0:10:45the new metrics that we have here
0:10:47is that it breaks down by like different device types.
0:10:51You can, as well as by like app version,
0:10:55so you can also see, like, I tried to make a change
0:10:57and, you know, to affect, you know,
0:10:59it should improve something.
0:11:00How does it affect it on a relatively new like 10s phone
0:11:04versus how does it detect it on a 5s phone?
0:11:07And like you can get a sense of how the impact is
0:11:10between those things, and also just I kind of love that,
0:11:12it's like, I think my favorite one of these new metrics
0:11:15is launch time, which isn't particularly what we're talking about
0:11:18in terms of like changes to iOS,
0:11:20but just is a new metric that came as part of these
0:11:22new things that are useful for other things,
0:11:24is like getting an actual real world sense
0:11:26of what the launch time is in seconds
0:11:28for a typical user on average for different devices
0:11:31is tremendously useful, because launch time, I think,
0:11:35is one of those things that is so hard to quantify yourself,
0:11:40because it's so dependent often on user,
0:11:43the actual user's data and their device
0:11:47and what else they're using,
0:11:48and there's lots of things that can go into launch time
0:11:51that you don't have control of or that are hard to simulate,
0:11:54and so it's really cool to know that, you know,
0:11:56like for on a 5s, my launch time is three or four seconds,
0:11:59but on a 10s, it's half a second,
0:12:01and like that's really cool to know.
0:12:03But it is interesting to play this detective game,
0:12:06I will say, that you kind of are often kind of looking for
0:12:08what is this trend, what is this thing that's happened,
0:12:11and obviously sometimes you'll know that there are obviously
0:12:14announced changes that are coming in iOS,
0:12:16but often there aren't,
0:12:17and you just kind of have to play this game of looking at it
0:12:19and be like, huh, between this and this version,
0:12:22what's changed and how is this,
0:12:25how is my system responding to it
0:12:27and what are some things that I'm doing
0:12:29that could be questionable, because often,
0:12:32I mean, it's like you said,
0:12:33sometimes this is the system's fault
0:12:35and sometimes it's our fault, like sometimes I feel like
0:12:37we can get away with things that maybe we shouldn't be,
0:12:40but, you know, we're relying on either a bug in the OS
0:12:44or just something that it is not enforcing.
0:12:47I think for a long time there was a bunch of things where,
0:12:50I think we've started to see a couple where there's calls
0:12:53that if you didn't make them on the main thread,
0:12:55you would see a log in Xcode that says,
0:12:58you're making this call not on the main thread,
0:13:02this behavior is not supported,
0:13:04in future versions this will fail,
0:13:06which is a really interesting thing to see
0:13:08when you see it, it's like I like when I see
0:13:11those kinds of messages, that it's like,
0:13:12I'm doing something that does technically work right now,
0:13:15but shouldn't work, and so it's like,
0:13:18I can be proactive and take advantage of those,
0:13:21and any time I see, like, I mean, I loved in,
0:13:24see in Core Data there's a thing where you can set it
0:13:26to be like thread-aware, and if you make any calls
0:13:31to things that are on the wrong thread,
0:13:33like, you know, your manage object context
0:13:36is being accessed from the wrong thread,
0:13:38you can have the debugger sort of essentially
0:13:41catch it and you'll hit a break point and say like,
0:13:44you're doing something bad here,
0:13:45I think there's a similar thing that you can do
0:13:47for accessing UIKit, not from the main thread,
0:13:50that you can, it can sort of prop up,
0:13:52essentially act as an exception in those cases,
0:13:55'cause I think those are often those kinds of edge case
0:13:57things that will work differently between versions of iOS,
0:14:02where you'll suddenly get caught out,
0:14:04that you were doing something that you weren't aware
0:14:06was problematic, but was problematic,
0:14:08but then, you know, it's like, it used to work,
0:14:11but suddenly it doesn't, like, I think I had one of these
0:14:13with iOS 13 where I was presenting a modal view controller,
0:14:17I think, and in certain circumstances it could be presented
0:14:20from a background thread if it was coming from a notification
0:14:24and that notification happened to come from a background thread,
0:14:26like, there was, you know, this sort of chain of events
0:14:28that could have happened where this was happening,
0:14:30and it worked on iOS 12, like, it would present
0:14:33and I never noticed, but on iOS 13 it would fail and crash,
0:14:36and, like, that was just one of those things that I was,
0:14:39I wasn't, you know, doing, I wasn't doing the appropriate call
0:14:42to send it, you know, to dispatch it back to the main thread,
0:14:45but, you know, now in 13 I was very aware of that
0:14:50and had to fix it.
0:14:51- Yeah, I've had, I've been bitten by a few of these things,
0:14:54I know about a year ago, or maybe a little more,
0:14:56I had a problem where if you, I had, you know,
0:15:01I had extensions running for my app and I had my main app
0:15:04and so I thought, hey, why don't I put the SQLite database file
0:15:08in the shared app container, that way the extensions
0:15:11and the main app can all be reading from the same database file
0:15:14and write into it and everything, and SQLite is good about,
0:15:16like, cross process, you know, synchronize access,
0:15:19so I knew that would be okay, so I thought, great,
0:15:21this should be fine, and I was getting all these weird crash reports
0:15:26and what turned out to be the reason was that if you are holding on to a,
0:15:31I believe a writable file handle in a shared app container,
0:15:36when your extension or main app gets suspended or terminated
0:15:41in the background, iOS will kill the app and make a crash log saying,
0:15:46hey, you actually crashed, like, as opposed to just a regular termination,
0:15:49and it took me forever to figure out why because that thing about, like,
0:15:54not having writable handles open in a shared app container,
0:15:57I don't think that was documented anyway, and it took me, I think,
0:16:02weeks to figure that one out and eventually ship an app update
0:16:04that just doesn't have the SQLite file there anymore
0:16:06and just communicates through other methods.
0:16:08For lots of reasons, don't put your SQLite file in the shared app container
0:16:12between extensions and your app, and so that one bit me pretty hard.
0:16:17I've also gotten hit in more recent times.
0:16:21Recent OSes, I believe they started with 12,
0:16:24but at least it's certainly present in 13, are very aggressive about
0:16:28if you open a background task and you don't close it,
0:16:33or if they call your expiration handler and you don't end the task
0:16:37in the expiration handler, they will kill the app with a crash,
0:16:41and that's especially coming up for a lot of people now with iOS 13
0:16:45because iOS 13 significantly reduced the amount of background time you have.
0:16:49It used to be about three minutes, and now I believe it's 30 seconds,
0:16:53something like that, and so the background task API
0:16:57is dramatically more aggressive in iOS 13,
0:17:00so we're seeing a lot of crashes from that,
0:17:02to the point where now, I did this a few months back.
0:17:05I actually changed all of my begin background task calls
0:17:08to use my own custom wrapper library that automatically will close the task
0:17:14if the calling code doesn't, just because there's nothing about my app
0:17:19that will break horribly if it gets suspended unexpectedly,
0:17:23so it's no big deal if the system suspends it,
0:17:26and I didn't cancel the background task,
0:17:29so now I had to actually make this wrapper class just to ensure that I can't do that.
0:17:35And of course, I audited all the ways I was using it too,
0:17:37and I hope I never actually need that fallback,
0:17:39but it's always good to have something like that.
0:17:41All sorts of stuff like that where the system is getting more and more strict
0:17:45over time, and a combination of Apple's engineering strictness,
0:17:50basically of throwing the problem back in our face,
0:17:53and their extreme lack of documentation on any of these things,
0:17:58and the fact that the conditions always change,
0:18:00make it so that we really have to be on our toes,
0:18:02and I don't think things necessarily should be this way,
0:18:05but they are, and we really have to be on our toes all the time,
0:18:08and every OS release, even a dot release,
0:18:12like even going from iOS 13.1 to 13.2, say,
0:18:15even dot releases change these requirements,
0:18:18and add more strict checking on things and everything.
0:18:21You never know when an OS release is going to all of a sudden
0:18:24start killing your app for a transgression that you weren't even aware of,
0:18:28or that used to not be a problem, and now is a problem.
0:18:32We are sponsored this week by Linode.
0:18:35With Linode, you can instantly deploy and manage an SSD server in the Linode cloud.
0:18:39You can get a server running in just seconds,
0:18:42with your choice of Linux distro, resources, and node location.
0:18:45It doesn't matter if you're working on your first server,
0:18:48or deploying a huge complex system, Linode is where to go.
0:18:52They have the fastest hardware network,
0:18:54with outstanding customer support if you ever need help,
0:18:56and it's super easy to launch a Linode cloud server.
0:18:59They now have block storage available in Newark, Fremont, Dallas, Atlanta,
0:19:02Frankfurt, London, and Singapore, soon to be released in Tokyo.
0:19:05Version 4 of Linode's REST API is out of beta,
0:19:08and includes an officially supported Python CLI.
0:19:11It's such a great host.
0:19:12I've got to say, Dave and I have been there forever,
0:19:15and I've been there for something like eight or nine years.
0:19:17All of Overcast is hosted there.
0:19:19I just absolutely love working with Linode.
0:19:21It's been a rock-solid host the entire time I've been there,
0:19:23and it's been the best value that I've been able to find in the market as well.
0:19:27So check it out.
0:19:29And also right now, Linode is hiring.
0:19:31If you want to learn more about that, go to linode.com/careers.
0:19:34Otherwise, for everyone else, check out their pricing options.
0:19:36They have options to suit everyone.
0:19:38Plans start at one gig of RAM for just $5 a month,
0:19:42and they have all sorts of other plans above that for various needs,
0:19:44including high-memory plans.
0:19:46And Linode has a special offer for you.
0:19:49Listeners of this show can go to linode.com/radar
0:19:52and use promo code radar2019 to get $20 towards any Linode plan.
0:19:57So on the one gig of RAM plan, that could be four months free.
0:20:00And with a seven-day money-back guarantee, you have nothing to lose.
0:20:03So give Linode a try today.
0:20:05That's linode.com/radar and promo code radar2019.
0:20:09To learn more, sign up and make the most of that $20 credit.
0:20:13Our thanks to Linode for their support of this show and all of Relay FM.
0:20:17Something that I found kind of interesting in this general topic too recently,
0:20:21I feel like Apple is increasingly using the crash termination
0:20:26as a way to enforce policy.
0:20:29That there was a term early in my career I'm working on iOS,
0:20:34I feel like crashes were usually directly my fault.
0:20:39I did something that was bad.
0:20:42Or in a more modern case, you could imagine in Swift,
0:20:45where if you use -- any time you use the exclamation point operator,
0:20:49you're asking for a crash because inevitably somehow that optional
0:20:54is going to turn out to be nil and it's going to crash.
0:20:56That was just your fault. That's just bad programming.
0:20:59But there weren't as many of these kind of situations
0:21:03where things are being -- policy is being enforced with a crash.
0:21:06But it's now, for example, if you make any privacy-related call
0:21:11inside your application and you don't include the appropriate
0:21:16P list entry with the privacy description text,
0:21:20your app will just immediately terminate.
0:21:23In some ways you could think, "Well, why doesn't the call just fail?"
0:21:26or something like that. It's like, no, Apple enforces that by a crash,
0:21:30by this hard, very aggressive version of that.
0:21:34And many of these resource constraints are enforced in the same way,
0:21:39that there is this very harsh, strong --
0:21:43you do something incorrect, your app is terminated,
0:21:47rather than just getting a not-authorized message
0:21:52or dealing with -- you can imagine softer versions of this.
0:21:56And in some ways, I will say, as a developer,
0:21:58there are parts of me that really like it, in the sense that
0:22:01if I'm doing something that I shouldn't be,
0:22:04often it is for lack of understanding about how to use something correctly,
0:22:09or I don't realize that I'm making a call that will actually
0:22:13deal with any of the privacy APIs.
0:22:15There are situations where things like that can happen.
0:22:18And in some ways it's nice to very strongly get my attention,
0:22:22because nothing gets your attention quite so strongly
0:22:24as the app immediately terminating.
0:22:27That's much more obvious than just the silent failure case.
0:22:33- It's like warnings versus errors.
0:22:35If your app crashes when you do something,
0:22:38you can't just delay fixing that for some future better time
0:22:42that will never come.
0:22:43You have to deal with that.
0:22:44It's forcing you to deal with it.
0:22:46- And in some ways, that's kind of nice.
0:22:50It's a little tricky when they happen in the between-the-
0:22:51It's tricky when they happen in the change in behavior,
0:22:58like the same code now crashes rather than just silently failing.
0:23:02That can be awkward when it happens,
0:23:04and especially when it happens in point updates
0:23:07or more minor things that are harder,
0:23:09like we don't have as much time with,
0:23:11or we don't necessarily look at as much.
0:23:13Because as much as Apple will usually provide us with a developer beta
0:23:17most at least of the major point releases,
0:23:21maybe not the minor point releases, ahead of time.
0:23:24It's also kind of tricky to necessarily always be running those.
0:23:27By all means, run any of the major versions.
0:23:29When iOS 13 came out at WWDC, I have it on a device,
0:23:32and I'm running my apps on it on day one
0:23:34and looking out for these kinds of things.
0:23:36But it's a little tricky for some of the times for the point releases.
0:23:38But I do kind of see where they're coming from,
0:23:40and I kind of like that this generally seems to be a new pattern
0:23:44that they're kind of heading towards,
0:23:46and if you do something wrong, like you were saying with some of the handlers
0:23:49and things where you kind of could have gotten away with it before,
0:23:52and they were a little bit more loosey-goosey about it,
0:23:55it's a different kind of model that I think ultimately
0:24:00will probably encourage higher general compliance and code quality.
0:24:05And as a philosophy, I'm not totally against,
0:24:09because it kind of necessitates this much more rapid improvement.
0:24:13But it's just awkward where sometimes they're happening
0:24:17for things that you don't understand.
0:24:19And I do kind of like, and in some ways it makes sense,
0:24:21that by making it a crash, there's the broadest amount of instrumentation
0:24:27possible for collecting information about that.
0:24:30Like, crash reporting, collecting crash reports
0:24:33is something that Apple does, that third-party frameworks do,
0:24:36that TestFlight does.
0:24:38By turning it into a crash, there's lots of instrumentation
0:24:42and kind of workflows around collecting that information
0:24:45and kind of knowing what happened that is already existing.
0:24:50And I mean, it's kind of funny in some ways that many of these policies
0:24:53are then enforced by the weird little paragraph in the middle of the crash report.
0:24:58Which is like, I don't think was necessarily like that section
0:25:02is kind of supposed to be this communication mechanism back and forth
0:25:06between the system and developers.
0:25:08But it is now.
0:25:10And there's a lot of information where I'll open up a crash report
0:25:12and there's this little paragraph in the middle.
0:25:14It's like, well, the watchdog process found that your application
0:25:18was using CPU for 2.04 seconds and the limit is this,
0:25:22and so you were killed after this amount of time.
0:25:24And we're having this little conversation about why I was killed.
0:25:28And that's interesting and that's useful.
0:25:30And I'm okay with it in some ways,
0:25:32but it is just something that I've noticed recently,
0:25:34that there's this trend towards you do something wrong
0:25:37and your app is killed rather than you do something wrong
0:25:39and it kind of silently fails.
0:25:41And overall I like it, but it is something that I think definitely to be aware of.
0:25:45And probably also just kind of something I've had to make peace with in a good way
0:25:50is for a long time my goal was to always have like zero crashes.
0:25:55Like if you open the analytics tab in iTunes Connect, say,
0:25:59in just like the crashes area, for a long time my goal was always to kind of get the crash rate down to zero.
0:26:06But with a lot of this kind of change, well it used to be in some ways.
0:26:11I've been over a year zero. I think I have like a thousand a day.
0:26:14Yeah, and I think I'm now at peace with that.
0:26:17Like the point I'm heading towards is that it used to be a reasonable goal.
0:26:20Now it isn't, and now it's more I think the crash,
0:26:23like there is telling you things sometimes that you have control over,
0:26:27sometimes that you don't.
0:26:28And the crash is more like a feedback mechanism.
0:26:31And you want overall, like if you see the crash rate going up,
0:26:34it's probably a bad thing. If you see it going down, it's probably a good thing.
0:26:37But the goal is not necessarily to get it to zero.
0:26:40The goal is for it to kind of slowly decrease over time.
0:26:43And if you see any like abrupt jumps in your crash rate,
0:26:47there's probably a lot of interesting logs with lots of paragraph text in them
0:26:50telling you things that you, new policies that you may not have been aware of,
0:26:54or just things that you need to be, you know, that need your immediate attention
0:26:58and that the system is telling you, you need to fix this right now.
0:27:01Yeah. And I think ultimately, I think using crashes this way from Apple's point of view,
0:27:06it makes sense to use it as like an enforcement mechanism for lots of things.
0:27:12Especially it makes sense, you know, as you mentioned how the tooling is so good,
0:27:15it makes a lot of sense for like line by line misuse of something.
0:27:20So like if you are literally like calling an API wrong or something,
0:27:24like that makes tons of sense.
0:27:26Where I think it needs more support around it is when it's about
0:27:30like general conditions being exceeded.
0:27:32You know, things like memory, CPU usage, disk rights,
0:27:36like where there is some limit that the system is enforcing
0:27:39and your app is just going to slowly approach it until it hits it and then get killed.
0:27:43That is where a crash report is pretty much useless to you
0:27:48because who knows where all the memory was going before the one line of code
0:27:52they happened to sample when they made their report.
0:27:54And so it's much more useful in cases like that to have a warning API first.
0:28:00To have something, some callback, some notification, some handler,
0:28:04something where the system tells you like, "Hey, you've reached 80% of this limit."
0:28:09Something like that before it kills you.
0:28:12Because then even if most apps never respond to that, fine,
0:28:16then it will be like the way it is now for them, although they will eventually get killed.
0:28:20But for those of us who want to do better, who want to avoid crashes
0:28:23and who might be doing optional work, please give us the support
0:28:28to actually respond to these conditions before our apps get killed.
0:28:32Because when they get killed, for resource usage basically,
0:28:38it's nearly impossible for us to do anything about that.
0:28:41Like what are we supposed to do with that information besides,
0:28:43"Well, I guess we'll try to use less CPU."
0:28:45How? Where? We don't know.
0:28:47But if we have a feedback mechanism before we get killed,
0:28:50we can add our own logging, we can respond to it, we can turn things off.
0:28:54It's so much better for everyone if we have that.
0:28:57Yeah, and it's also great when that is something that we can simulate.
0:29:00Yes.
0:29:01As well. Like, in the same way that we have the network link conditioner
0:29:04that can simulate network conditions, like being able to launch the app and say,
0:29:07"Launch me as though the system is under constraint right now,
0:29:11and let me see what will happen and how I'll be terminated
0:29:15and what behaviors I should expect."
0:29:17And anytime they give those kinds of tools to us,
0:29:20I find them invaluable to just get a sense of where...
0:29:24Otherwise you're doing these weird things that you're like,
0:29:27"Let me launch six other apps while I'm launching my app
0:29:30and start playing 4K video in the hopes that I'm creating a condition
0:29:33that will make my app be resource constrained."
0:29:38Which is not repeatable and is not particularly reliable either.
0:29:42Yeah, and there's some tooling around that, but it's very minimal.
0:29:45More would be a lot better.
0:29:47Anyway, thanks for listening, everybody, and we'll talk to you in two weeks.
0:29:50Bye.
0:29:51Bye.
0:29:51[BLANK_AUDIO]