Relaunch in my case isn't about crash recovery, its about preventing user waits 
and preventing crashes in the first place.

Examples of situations where auto relaunch is desirable:
- user changes a preference which essentially invalidates every object in every 
nib
   - color preferences
   - resetting prefs ( clearing NSUserDefaults, deleting all cached files )
- making the user wait for timeouts is unacceptable
  In my app,  only one NSDocument is open at a time, because it specifies a 
network of servers.
  It is ok to interrupt any threaded transaction in progress, but it is time 
consuming to synchronize the deletion of those threads.
  For example, if a background threaded NSURLRequest has a 5-second timeout, 
then the user might have to wait 5 seconds to close the
  current NSDocument and open the new one.  Either that or I have to write 
special unmaintainable code for every imaginable edge-case.
  Annoying for the user, and wasted development resources on my part.

  If I call execve() when switching to a different NSDocument, cleanup happens 
in 5 milliseconds (once save to disk is done), and relaunch happens in less 
than 2 seconds.
  Why make the user wait for longer?

While I admire apps that have the budget to reconfigure on the fly, it 
typically takes a long time for them to be stable.
Take for example, the apple usb-ethernet driver...
  https://discussions.apple.com/thread/3957141?start=0&tstart=0

Keith Knauber
Senior Software Engineer
Production Resource Group
8617 Ambassador Row, Suite 120
Dallas, Texas 75247
214-819-3145 Phone
214-477-3928 Mobile
214-630-5867 Fax
kknau...@prg.com
www.prg.com

On Dec 18, 2012, at 11:47 AM, Kyle Sluder wrote:

On Dec 18, 2012, at 9:27 AM, Keith Knauber <kknau...@prg.com> wrote:

> Automatic relaunch of your app is such a basic software requirement,

It is?


> and apple has never published a clean method for accomplishing this.

Ape's crash reporter offers to relaunch the app.

> There are situations when a relaunch of an app is much safer, faster, and 
> fault tolerant than an approach which kills every background thread,
> deletes all your NSDocument objects, and open a new NSDocument.

The desired user experience is that after a relaunch NSDocumentController 
reopens all the documents that were open at the time of the crash.

> 
> - (void) applicationWillTerminate:(NSNotification *)notification
> {
>  … do clean-up tasks like NSUserDefaults synchronize, etc. …
> 
>  if ( !  userWantsRelaunch  )
>     return;

This won't be executed if you crash, and you certainly shouldn't trap all 
exceptions and go through the normal quit process to make it do so.

Are you trying to auto relaunch for reasons other than a crash? If so, why?

If it's for software update reasons, then self-exec is not a good idea because 
the old version app will likely remain mapped and will be relaunched. Better to 
have a helper script that waits for the process to quit and the file to be 
replaced before actually doing the launching.

I can't really think of any reason other than crash or self-update where 
relaunching the app is the correct user experience.

--Kyle Sluder



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to