[HN Gopher] Restarting macOS apps automatically on crash
       ___________________________________________________________________
        
       Restarting macOS apps automatically on crash
        
       Author : alin23
       Score  : 26 points
       Date   : 2023-09-01 19:50 UTC (1 days ago)
        
 (HTM) web link (notes.alinpanaitiu.com)
 (TXT) w3m dump (notes.alinpanaitiu.com)
        
       | prmoustache wrote:
       | solution looking for a problem
        
         | [deleted]
        
       | ChrisMarshallNY wrote:
       | I'm not really a fan of auto-restart on crash. In some cases, it
       | could cause damage.
       | 
       | 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.
        
         | [deleted]
        
           | [deleted]
        
       | cryptonector wrote:
       | > Bonus: restart on hang
       | 
       | This is not good for battery life. I'm not sure how to
       | heuristically detect hangs in a power-friendly way.
        
         | [deleted]
        
       | nottheengineer wrote:
       | "My software crashes so often that it's worth the time to
       | automate restarting it" is what I'd expect of a windows user. Has
       | macOS really gotten that bad over the last few years? I remember
       | being forced to use it a long time ago and while it was very
       | limited and special, nothing ever crashed or was visibly buggy.
        
         | dagmx wrote:
         | If you don't know why the app is crashing, then you don't know
         | enough to blame the OS or the ecosystem. That's true of any
         | operating system. Apps aren't magically crash free because
         | they're on a Mac. Dereferencing an invalid pointer can still
         | segfault you just as quickly.
        
         | [deleted]
        
         | dylan604 wrote:
         | Why is the assumption the OS is the fault and not the app doing
         | something it shouldn't be doing so the system slaps it? If the
         | OS was at fault, would not the OS be crashing rather than the
         | app. To me, it sounds like the OS is working nicely with a
         | misbehaving app.
         | 
         | 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
        
         | FirmwareBurner wrote:
         | _> "My software crashes so often that it's worth the time to
         | automate restarting it" is what I'd expect of a windows user. _
         | 
         | This is insulting even for windows users.
        
           | fortran77 wrote:
           | That's why I flagged it.
        
             | labster wrote:
             | Yes, but it's also funny, and not mean-spirited or targeted
             | at a specific person. Windows users are in no way a
             | protected class.
        
         | tom_ wrote:
         | Which OS do you use? It sounds like it can't be Linux! Looking
         | forward to hearing about this crash-free nirvana.
        
           | prmoustache wrote:
           | The only app that has been crashing or freeze, on my Fedora
           | box these last few years is a Microsoft app: Edge.
        
         | fortran77 wrote:
         | MacOS applications are just like applications on any other
         | platform. Why the juvenile Windows bashing?
        
           | brailsafe wrote:
           | No they're not, otherwise we'd use those other platforms.
        
             | fortran77 wrote:
             | I use Windows.
        
         | crazygringo wrote:
         | 100% of crashes on my M1 MBA occur in applications when
         | accessing files over SMB network shares. One every couple of
         | days. I have to restart about once every week or two because it
         | borks the system completely.
         | 
         | 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.
        
           | ComputerGuru wrote:
           | It's faulty app logic, assuming an io error cannot occur
           | accessing a filesystem. They'll also crash if you have disk
           | issues or driver problems. The important thing is they may
           | not even realize they're calling into a function or routine
           | that can access the fs for something!
           | 
           | 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.
        
             | brailsafe wrote:
             | That and sandboxing effects with perhaps improperly
             | accessed bookmark data
             | 
             | 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.
        
           | nottheengineer wrote:
           | SMB really is hell. I write business software and our admins
           | do what they can to avoid using it because it's very hard to
           | know when it fails.
           | 
           | 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.
        
           | pram wrote:
           | Stuff like this with NFS was my living nightmare for years.
           | On Linux it would put processes into the D state and you'd
           | have to restart the entire machine to fix anything.
        
       | bandergirl wrote:
       | I expecting to see logic to detect crash loops. What happens
       | then?
        
         | tempodox wrote:
         | Exactly, I wouldn't be comfortable just blindly auto-restarting
         | an app after a crash. macOS offers a "Relaunch" button in these
         | situations, so you can restart it interactively. That's good
         | enough for me.
        
       | saagarjha wrote:
       | One should be careful about what they put in a signal handler.
       | Doing complex things like calling into Foundation, especially in
       | a signal handler that indicates something has really gone wrong,
       | is probably not a good idea.
        
         | cryptonector wrote:
         | I came here for this. Signal handlers have to do only async-
         | signal-safe things.
        
       | alberth wrote:
       | Reminds my how Basecamp use to restart their Rails app 400
       | times/day.
       | 
       | https://dhh.dk/posts/31-myth-2-rails-is-expected-to-crash-40...
        
       ___________________________________________________________________
       (page generated 2023-09-02 23:01 UTC)