Re: Use of AppKit in command-line app on headless node
Re: Use of AppKit in command-line app on headless node
- Subject: Re: Use of AppKit in command-line app on headless node
- From: "Michael Ash" <email@hidden>
- Date: Mon, 11 Aug 2008 16:50:00 -0400
On Mon, Aug 11, 2008 at 2:58 PM, Rick Hoge <email@hidden> wrote:
>
>
>> I am trying to factor some frameworks so that code used in a
>> document-based Cocoa app can be shared with command-line tools that might
>> run on a headless node (no window server).
>>
>> I've seen some discussion in the past on questions such as whether NSImage
>> and related classes can be used headless. It seems that this works, but
>> it's necessary to initialize and NSApplication instance for the classes to
>> work correctly.
>
>
> I noticed that there is some useful info relating to this topic in the
> documentation on Agents and Daemons at
>
> http://developer.apple.com/technotes/tn2005/tn2083.html#SECLIVINGDANGEROUSLY
>
> It does say that AppKit is not daemon-safe, but my testing suggests that if
> (as suggested in the technote) you avoid sensitive methods it should be ok
> (more info would be welcome).
I'm curious as to whether you really read the thing....
"A routine might behave differently depending on its input parameters.
For example, an image decompression routine might work for some types
of images and fail for others."
"The behavior of any given framework, and the routines within that
framework, can change from release-to-release."
In other words, you're playing with fire in a gasoline-soaked shed.
Just because you haven't been burned horribly *yet* doesn't mean you
won't be.
AppKit requires a window server connection, full stop. To the extent
that it functions without one, this behavior is unsupported,
unreliable, and highly risky. Don't do it.
In case you didn't know, having a window server connection isn't the
same as being a GUI app, however. You just need to be able to connect
to it. Realistically, this means either having a user who's logged in
to the GUI and always running as that user, or running as root and not
logging in or out.
And lastly, as far as I know you must initialize NSApplication before
touching AppKit in any other way. Like the window server requirement,
you may be able to get away without doing it sometimes but you should
never rely on it.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden