Some steps towards headless on OS X

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Some steps towards headless on OS X

Mark Smith
Hi all,

The underlying problem with headless mode in OS X seem to be that we always create a window, even when we run in the background, as we do in headless mode*. Marking the process as background only will remove the icon, menu etc. but it will not stop us from creating that window.

Maybe I don't know enough about how Squeak/Pharo works right now but it looks like quite a lot of work to change this. And the code isn't pretty ;).

Anyway I'd like to keep working on this but I've hit a wall. I can handle the Cocoa side but don't know anything about the VM's setup process etc. Could someone clarify this? Or maybe there are some docs?

Also –

What do you guys think about building a headless VM without any of the UI stuff in it?

It might be simpler/cleaner than what we have now.

All the best,

Mark

* Creating the window is almost the first thing we do!

We do it before we know if we're running headless…


Reply | Threaded
Open this post in threaded view
|

Re: Some steps towards headless on OS X

Sean P. DeNigris
Administrator
Mark Smith wrote
Marking the process as background only will remove the icon, menu etc. but it will not stop us from creating that window.
...
Anyway I'd like to keep working on this but I've hit a wall
Are your changes publicly available anywhere?
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Some steps towards headless on OS X

Mark Smith

On 3 Jun 2012, at 18:27, Sean P. DeNigris wrote:

>
> Mark Smith wrote
>>
>> Marking the process as background only will remove the icon, menu etc. but
>> it will not stop us from creating that window.
>> ...
>> Anyway I'd like to keep working on this but I've hit a wall
> Are your changes publicly available anywhere?

I didn't make many changes yet. The machinery is already there but isn't functional.

If you set the LSBackgroundOnly key in Info.plist to YES and run headless you will see that the icon and menu bar are gone… only the window remains :).

With this change in place –

When the VM is not run in headless mode it it brings itself into the foreground. Unfortunately this cannot work the other way around because foreground processes cannot become background processes (we'll have to ask Apple why that is exactly :).

When the VM is run in headless mode it stays in the background, but our window will be visible.


If we can change the VM such that no window is created in headless mode then everything should function as we expect. That's where I get lost.  The obvious thing to try (which I tried ;) is to not create a window, but then the VM doesn't start and the application just exits [normally]. I have no idea why starting the VM would have anything to do with the creation of a window but this seem to be the case.


That said Mac applications aren't exactly friendly to headless operation. That is that they're sort-of-intended to be graphical.

The other solution would be to make a headless VM, similar in operation to perl/python/ruby... which is really what we want.

I think ;).

> --
> View this message in context: http://forum.world.st/Some-steps-towards-headless-on-OS-X-tp4633047p4633048.html
> Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: Some steps towards headless on OS X

Sean P. DeNigris
Administrator
Mark Smith wrote
The obvious thing to try (which I tried ;) is to not create a window
For giggles, I changed main() to:
...
#import <sqSqueakOSXApplication.h>

int main(int argc, char **argv, char **envp)
{
        extern int argCnt;
        extern char **argVec;
        extern char **envVec;
       
        argCnt = argc;
        argVec= argv;
        envVec = envp;
       
    NSAutoreleasePool * pool = [NSAutoreleasePool new];
   
    NSRunLoop *runLoop = [NSRunLoop mainRunLoop];
    sqSqueakOSXApplication* app = [sqSqueakOSXApplication new];
    [app setupEventQueue];
    [runLoop performSelector: @selector(runSqueak)
             target: app
             argument: nil
             order: 1
             modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]];
   
    [runLoop run];
   
    [pool release];
    return 0;
}

This starts the interpret loop, but seems to get stuck in primitiveFindHandlerContext(), which gets called from initStackPagesAndInterpret()

p.s. for testing, you can pass in the headless flag and image file via Product->Edit Scheme->Arguments
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Some steps towards headless on OS X

Stefan Marr-3
Guys, you are probably better off on the VM mailing list.

And I am certainly also interested in a headless Cocoa VM. (Esteban already forgot about my nagging apparently :-P)

FW:

On 04 Jun 2012, at 00:02, Sean P. DeNigris wrote:

>
> Mark Smith wrote
>>
>> The obvious thing to try (which I tried ;) is to not create a window
>>
>
> For giggles, I changed main() to:
> ...
> #import <sqSqueakOSXApplication.h>
>
> int main(int argc, char **argv, char **envp)
> {
> extern int argCnt;
> extern char **argVec;
> extern char **envVec;
>
> argCnt = argc;
> argVec= argv;
> envVec = envp;
>
>    NSAutoreleasePool * pool = [NSAutoreleasePool new];
>
>    NSRunLoop *runLoop = [NSRunLoop mainRunLoop];
>    sqSqueakOSXApplication* app = [sqSqueakOSXApplication new];
>    [app setupEventQueue];
>    [runLoop performSelector: @selector(runSqueak)
>             target: app
>             argument: nil
>             order: 1
>             modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]];
>
>    [runLoop run];
>
>    [pool release];
>    return 0;
> }
>
> This starts the interpret loop, but seems to get stuck in
> primitiveFindHandlerContext(), which gets called from
> initStackPagesAndInterpret()
>
> p.s. for testing, you can pass in the headless flag and image file via
> Product->Edit Scheme->Arguments
>
> --
> View this message in context: http://forum.world.st/Some-steps-towards-headless-on-OS-X-tp4633047p4633080.html
> Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
>

--
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: +32 2 629 2974
Fax:   +32 2 629 3525