Restarting macOS apps automatically on crash
notes.alinpanaitiu.com
notes.alinpanaitiu.com
It’s refreshing to see your users never angrily contact you to fix crashes you can’t fix and that your only answer is not “sorry you will have to just relaunch the app”
Your unfounded assumptions are a delight, indeed I must be doing something wrong and maybe just didn’t put in the work into fixing these errors, and after 6 years of developing the same app and looking at the Sentry dashboard every day and talking to users through email/Discord/Twitter/Reddit/forums and looking at their video recordings and deciphering their explanations and sending them betas and custom utilities that definitely reproduce how the crash is not a user error… sorry, what was I saying?
God damn it man, it’s this thing every day here.
I just wanted to share a readily made solution for people that are in desperate need of it and have exhausted all other possibilities. I’m not trying to make everyone create crash loops and bringing systems to a grind.
Your application may crash due to:
- hangs / spins - memory corruption - programmer error / faulty logic (think loooping infinitely) - thermals / memory usage
Let launchd handle restarting your application by allowing the user a “Relaunch” button
https://dhh.dk/posts/31-myth-2-rails-is-expected-to-crash-40...
This is not good for battery life. I'm not sure how to heuristically detect hangs in a power-friendly way.
But when I'm not connected to an SMB drive, I don't think I've had a single crash in years.
I have no idea if it's something in the SMB driver itself that's crashing, or assumptions inside of application logic that fail in certain SMB scenarios.
But from a dev perspective, that's probably a driver level issue because that's where you want to handle or propagate errors instead of crashing.
All io access needs to be recoverable or catchable for your app not to crash. You’d be surprised how much background fs activity there can be in apps (or indirectly triggered by apps!) all the time.
I'm building a macos app now, and only because I wasn't catching fs access error did I realize I needed to handle folder access carefully when using bookmarks in core data.
So many areas where rust makes me deal with a result or option that are easy to take for granted. It’s a strong reminder of the number of things we should be treating as possible error cases
And when the crash happens, it’s obvious why
Maybe the better question would be if the OS SDK is to a state that doing naughty things is easier to do, but again, that's not the OS
This is insulting even for windows users.
Humor is more complex to get right, it needs some punchline or an arc within the context where your initial expectations are subverted, in order to be funny, not just "windows users are like X".
Listen to Garrison Keillor’s old radio shows, and amidst the long story arcs are little tribalist jokes between the Christian denominations (and Unitarians?), and among the different peoples of Scandanavia. Like this one, the jokes rely on the implicit context inflating the difference between people on the basis of tribalism. And being a part of the subculture, the audience all knows this.
The same is true in sports comedy, and sports is nothing if not petty tribalism. And while you may not actually have to be a masochist to be a Mets fan… wait, bad example. Anyways exaggerated differences based on self-assigned fandoms is how this all works. Just like operating systems.
It's as funny as calling Mac users Sheeple.
Minor teasing is a part of the theory of humor, as proposed by Immanuel Kant. I don’t purport to go all the way on superiority theory, but insult comedy is a part of comedy nonetheless. I personally dislike it but I do recognize it as humor.
Incidentally regarding the part of my previous comment that’s a joke: the joke is not the insult. The joke is a surprise theory one, that I was going to make a statement about sports, but at the last minute I reversed by pretending the example was true. The butt of the joke is myself, talking myself out of a coherent point.
Of course by analyzing it you ruin it for most people, but there we are.
Also, something being humorous requires it to be funny and get people laugh, but I don't think many are laughing as making fun of Windows users jokes have been stale since the days of Windows Vista, Mac VS PC ads were the rage, and Steve Jobs still had a pulse.
If that canned joke still makes you laugh in 2023, maybe your sense of humor is bad.
I don't recall ever having an issue that was fixed by restarting an application though. If it doesn't work, I read the error message to figure out why it doesn't work and fix that. No "just try again, it might work this time" like on windows, which I enjoy.
I consider a crash -any crash, to be my fault. This includes things like yanking out the power cord (which probably will just stop the program counter, as opposed to careening off into the weeds).
No matter how abusive the user is, no matter how out-of-band their behavior, my software should never crash.
I love crashes. They tend to be easy to fix (of course, thread collisions are another matter). If I can reliably reproduce a crash, I can usually fix it in a few minutes.
In iOS, Apple makes it impossible to quit an app. I have heard of developers deliberately forcing a crash to do that, but, if Apple catches you doing it, they'll yank the app. They won't approve apps they can get to crash. In fact, they have, in the past, found crashes that I missed.
Just better off, writing software that can handle always-on, and that doesn't crash.
It used to be that a single tech support call cost us any profit from 3 copies of the product.
Things are different now though - the frameworks on platforms have orders of magnitude more surface and complexity. And most small companies don’t offer 1-1 support anymore.
Swift helps a lot. It has a lot of safety in it. I haven’t had a memory leak in ages.
Also, Xcode has gotten really good at letting me know when I have a future crash.
So “unsafe” is relative.
In any case, memory leaks are sloppy, and I have a personal aversion to writing sloppy code.
But it's still a bad look, and Apple won't approve an app, if they can get it to crash -regardless of the reason.
1. Crashes aren’t unsafe. They’re actually preferable for both Swift and rust than getting into an unsafe state with incorrect data. So in that sense, crashes are the seen as safe, just undesirable as an outcome.
2. Memory leaks can’t be unsafe any more than a badly optimized algorithm.
But yes, they’re sloppy and should be avoided. I just contend that there’s no real case where I think they should be considered unsafe from the model of a programming language.
They might be unsafe from the model of a context specific use. E.g you wouldn’t want a memory leak locking up your system in vehicular automation. But I’d fall back to it just being sloppy programming if that state is achieved.