Re: Isolated process for each NSDocument of my app

2013-06-14 Thread Daniele Margutti

On 14 Jun 2013, at 03:00, Graham Cox graham@bigpond.com wrote:

 No offence, but when a programmer says this, all they're doing is revealing 
 their own inexperience. I mean that in a friendly way; I've been there many 
 times myself.
 
 There *is* a way, you just have to figure it out (or ask someone to help you 
 figure it out).

No offence guy, but seriusly I can’t. We have a compatible UIKit layer which 
can run on OS X. In order to mantain compatibility I need to handle 
UIApplication and UIScreen singleton; morehower I need to manage UIAppearance. 
This thing can’t work on with multiple projects at the same time so in order to 
work with it I need to isolate each project/UIKit instance/process from the 
other.
___

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

Re: Isolated process for each NSDocument of my app

2013-06-14 Thread Kyle Sluder
On Jun 14, 2013, at 1:15 AM, Daniele Margutti m...@danielemargutti.com wrote:

 
 No offence guy, but seriusly I can’t. We have a compatible UIKit layer which 
 can run on OS X. In order to mantain compatibility I need to handle 
 UIApplication and UIScreen singleton; morehower I need to manage 
 UIAppearance. This thing can’t work on with multiple projects at the same 
 time so in order to work with it I need to isolate each project/UIKit 
 instance/process from the other.

So your response to a problem entirely of your own making is to try to whip a 
system framework into doing something it is very much not designed to do.

Step back and take a deep breath. You need to remove your blinders and 
rationally analyze your options.

AppKit simply does not and will not work the way you want it to. You can't just 
split code into subprocesses when that code might be sharing untold amounts of 
state and memory. It would be *astronomically* more difficult to accomplish 
this than it would be to 1) either fix your UIKit clone or 2) just stop 
treating the Mac as a second-class citizen and use AppKit natively for your UI. 
Both of those are under your control; the code within AppKit is not.

--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

Re: Isolated process for each NSDocument of my app

2013-06-14 Thread Alex Zavatone
The model you are mentioning seems a lot like multiple users accessing a 
database on a remote server.

In this analogy, the database is your document.  The users accessing that one 
database are the other apps that are accessing it.



On Jun 13, 2013, at 2:29 PM, Daniele Margutti wrote:

 
 On 13 Jun 2013, at 20:05, Tom Davie tom.da...@gmail.com wrote:
 
 The best way is to write an application that's stable.  The only reason 
 browsers started doing this was because they had to deal with 3rd party code 
 (e.g. flash) that was giving them a terrible reputation for instability.  If 
 you're controlling the entire app, you have no reasonable reason to do this. 
  Simply fix your crasher bugs instead.
 
 Overall stability is not my reason to evaluate this kind of a architecture; 
 for a particular reason each document should interact with an external 
 singleton class but each singleton must be unique around the app; think about 
 UIApplication on iOS; I need to work with a similar thing so I need to “run” 
 multiple projects and each one must see a single instance of this object. I 
 cannot change this kind for several reason, so an architecture like this 
 could be a great answer to enable multiple documents support in my 
 application.
 ___
 
 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/zav%40mac.com
 
 This email sent to z...@mac.com

___

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

Re: Isolated process for each NSDocument of my app

2013-06-14 Thread Jens Alfke

On Jun 14, 2013, at 1:15 AM, Daniele Margutti m...@danielemargutti.com wrote:

 No offence guy, but seriusly I can’t. We have a compatible UIKit layer which 
 can run on OS X. In order to mantain compatibility I need to handle 
 UIApplication and UIScreen singleton; morehower I need to manage 
 UIAppearance. This thing can’t work on with multiple projects at the same 
 time so in order to work with it I need to isolate each project/UIKit 
 instance/process from the other.

I’m going to ignore the issue of whether it even makes sense to try to bash 
code and UI designed for iOS into running on Mac OS. Apps that are ported 
across platforms by brute force this way rarely work well.

At a technical level, I think your best bet is to use state-switching. Use a 
model where one app instance is active at a time. Each one has its own 
instances of the singletons (UIApplication, etc.) and when an app instance is 
active, the singleton accessors like [UIApplication application] return the 
object matching that app instance.

Now you have only one piece of global state, the current-app-instance. What you 
need to do is switch that appropriately based on which app is going to be 
running next. The obvious thing is before handing an event, determine which app 
it’s aimed at (probably based on which app owns the appropriate NSWindow) and 
set that one.

The harder task is to set the current-app when other runloop-based calls 
happen, like timers and delayed-performs and NSURLConnection delegate calls and 
so forth. Wrapping all of those APIs would be a real pain.

One possible solution is to create a new thread with its own runloop for each 
app instance, and always run it on that thread. Then in fact you can resolve 
all your singletons by using the NSThread dictionary to look up state. You just 
have to handle events by looking up the target app’s thread, posting the event 
to that thread’s runloop, and then blocking till it completes. (This also 
avoids trouble with thread-safety because it ensures that only one of those app 
UI threads can be handling UI events at a time.)

This still sounds challenging, but it’ll be a million times easier than trying 
to run multiple processes.

—Jens
___

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

Re: Isolated process for each NSDocument of my app

2013-06-14 Thread Scott Ribe
On Jun 14, 2013, at 11:17 AM, Jens Alfke wrote:

 This also avoids trouble with thread-safety because it ensures that only one 
 of those app UI threads can be handling UI events at a time.

But isn't it still true that many UI-oriented APIs can only be safely called on 
the main thread, regardless of anything you may do to prevent more than one 
thread at a time running the UI?

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice





___

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


Re: Isolated process for each NSDocument of my app

2013-06-14 Thread Graham Cox

On 14/06/2013, at 6:15 PM, Daniele Margutti m...@danielemargutti.com wrote:

 No offence guy, but seriusly I can’t. We have a compatible UIKit layer which 
 can run on OS X. In order to mantain compatibility I need to handle 
 UIApplication and UIScreen singleton; morehower I need to manage 
 UIAppearance. This thing can’t work on with multiple projects at the same 
 time so in order to work with it I need to isolate each project/UIKit 
 instance/process from the other.


That's exactly the sort of thing I'm referring to - for whatever reason your 
design is incorrect, so you're now trying to fix that by adding more 
incorrectness.

The split between your controller and view layer is in the wrong place. By 
refactoring you can replace your view layer by a native OSX one and not attempt 
to add a layer ON TOP of your view layer to make Mac OSX look like UIKit.

While I haven't had much experience on iOS yet, I have made a few simple apps 
that work across iOS and Mac OS and by and large these share 70% or more of the 
controller and model code. Most of the view stuff comes from xibs and so in 
reality there isn't that much code that differs. I would accept that your app 
is a lot more complicated than mine, but nevertheless the right approach should 
make cross-platform deployment reasonably straightforward. It's much easier 
than, say, Windows/Mac cross-platform, at least the whole thing can be in Cocoa.

--Graham



___

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

Isolated process for each NSDocument of my app

2013-06-13 Thread Daniele Margutti
Hi guys,
While I’m making an app (it’s docs based) I would to have a separated process 
for each opened NSDocument.
The main idea is to have the main app which launch a process for each opened 
NSDocument/NSWindow and forward all messages to foreground window/process.
In this case each process is isolated from the others as like with Safari.
What’s the best way to accomplish it on OS X?
Thanks a lot
Daniele
___

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

Re: Isolated process for each NSDocument of my app

2013-06-13 Thread Jens Alfke

On Jun 13, 2013, at 3:52 AM, Daniele Margutti m...@danielemargutti.com wrote:

 In this case each process is isolated from the others as like with Safari.
 What’s the best way to accomplish it on OS X?

There is no [public] support for running parts of the GUI of an app in separate 
processes. It requires things like sending events over IPC and maintaining 
shared-memory window/view buffers. I’m somewhat familiar with the way Chrome 
does it, having worked on Chrome for a few years, and it is very complex and 
messy. (You can check out the Chromium source and look through it if you want.) 
I’m sure Safari’s implementation is too, unless they’re using some hypothetical 
private AppKit APIs for cross-process events/views.

The short answer is that this would be very difficult to do, and you’ve have to 
become intimately familiar with XPC, the low levels of AppKit event handling, 
CoreGraphics, shared memory, etc. etc.

On the plus side, if you accomplished it and made it into a reusable framework, 
you’d be a hero.

—Jens
___

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

Re: Isolated process for each NSDocument of my app

2013-06-13 Thread Tom Davie
The best way is to write an application that's stable.  The only reason
browsers started doing this was because they had to deal with 3rd party
code (e.g. flash) that was giving them a terrible reputation for
instability.  If you're controlling the entire app, you have no reasonable
reason to do this.  Simply fix your crasher bugs instead.


On Thu, Jun 13, 2013 at 12:52 PM, Daniele Margutti
m...@danielemargutti.comwrote:

 Hi guys,
 While I’m making an app (it’s docs based) I would to have a separated
 process for each opened NSDocument.
 The main idea is to have the main app which launch a process for each
 opened NSDocument/NSWindow and forward all messages to foreground
 window/process.
 In this case each process is isolated from the others as like with Safari.
 What’s the best way to accomplish it on OS X?
 Thanks a lot
 Daniele
 ___

 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/tom.davie%40gmail.com

 This email sent to tom.da...@gmail.com
___

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

Re: Isolated process for each NSDocument of my app

2013-06-13 Thread Daniele Margutti

On 13 Jun 2013, at 20:05, Tom Davie tom.da...@gmail.com wrote:

 The best way is to write an application that's stable.  The only reason 
 browsers started doing this was because they had to deal with 3rd party code 
 (e.g. flash) that was giving them a terrible reputation for instability.  If 
 you're controlling the entire app, you have no reasonable reason to do this.  
 Simply fix your crasher bugs instead.

Overall stability is not my reason to evaluate this kind of a architecture; for 
a particular reason each document should interact with an external singleton 
class but each singleton must be unique around the app; think about 
UIApplication on iOS; I need to work with a similar thing so I need to “run” 
multiple projects and each one must see a single instance of this object. I 
cannot change this kind for several reason, so an architecture like this could 
be a great answer to enable multiple documents support in my application.
___

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

Re: Isolated process for each NSDocument of my app

2013-06-13 Thread Jens Alfke

On Jun 13, 2013, at 11:29 AM, Daniele Margutti m...@danielemargutti.com wrote:

 Overall stability is not my reason to evaluate this kind of a architecture; 
 for a particular reason each document should interact with an external 
 singleton class but each singleton must be unique around the app; think about 
 UIApplication on iOS; I need to work with a similar thing so I need to “run” 
 multiple projects and each one must see a single instance of this object. I 
 cannot change this kind for several reason, so an architecture like this 
 could be a great answer to enable multiple documents support in my 
 application.

I think you’ll find it easier to refactor your code to avoid depending on a 
global/singleton*, than to implement low-level system functionality to split 
your app across processes.

—Jens

* which you should do anyway; that’s a bad design.
___

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

Re: Isolated process for each NSDocument of my app

2013-06-13 Thread Daniele Margutti

On 13 Jun 2013, at 21:04, Jens Alfke j...@mooseyard.com wrote:

 
 On Jun 13, 2013, at 11:29 AM, Daniele Margutti m...@danielemargutti.com 
 wrote:
 
 Overall stability is not my reason to evaluate this kind of a architecture; 
 for a particular reason each document should interact with an external 
 singleton class but each singleton must be unique around the app; think 
 about UIApplication on iOS; I need to work with a similar thing so I need to 
 “run” multiple projects and each one must see a single instance of this 
 object. I cannot change this kind for several reason, so an architecture 
 like this could be a great answer to enable multiple documents support in my 
 application.
 
 I think you’ll find it easier to refactor your code to avoid depending on a 
 global/singleton*, than to implement low-level system functionality to split 
 your app across processes.


That’s not possible due to some important reason I can’t explain here :( Belive 
me, if it was the right way I would have used them :(


___

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

Re: Isolated process for each NSDocument of my app

2013-06-13 Thread Tom Davie

On 13 Jun 2013, at 20:29, Daniele Margutti m...@danielemargutti.com wrote:

 
 On 13 Jun 2013, at 20:05, Tom Davie tom.da...@gmail.com wrote:
 
 The best way is to write an application that's stable.  The only reason 
 browsers started doing this was because they had to deal with 3rd party code 
 (e.g. flash) that was giving them a terrible reputation for instability.  If 
 you're controlling the entire app, you have no reasonable reason to do this. 
  Simply fix your crasher bugs instead.
 
 Overall stability is not my reason to evaluate this kind of a architecture; 
 for a particular reason each document should interact with an external 
 singleton class but each singleton must be unique around the app; think about 
 UIApplication on iOS; I need to work with a similar thing so I need to “run” 
 multiple projects and each one must see a single instance of this object. I 
 cannot change this kind for several reason, so an architecture like this 
 could be a great answer to enable multiple documents support in my 
 application.

So really, what you're saying is Someone stuck a singleton where a singleton 
shouldn't be (anywhere at all), and now I'm screwed that I need more than one 
of them.  Your solution to this should be to not use a singleton (ever), 
rather than to try and hack about the application structure to carry on using a 
singleton.

Tom Davie
___

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

Re: Isolated process for each NSDocument of my app

2013-06-13 Thread Kyle Sluder
On Thu, Jun 13, 2013, at 12:06 PM, Daniele Margutti wrote:
 That’s not possible due to some important reason I can’t explain here :(

It's far more possible than trying to slice portions of your app into
subprocesses.

--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

Re: Isolated process for each NSDocument of my app

2013-06-13 Thread Graham Cox

On 14/06/2013, at 5:06 AM, Daniele Margutti m...@danielemargutti.com wrote:

 That’s not possible


No offence, but when a programmer says this, all they're doing is revealing 
their own inexperience. I mean that in a friendly way; I've been there many 
times myself.

There *is* a way, you just have to figure it out (or ask someone to help you 
figure it out).

--Graham
___

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