[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Simple SWT App launched with OSGi Launcher hangs on Mac OS X

Thanks Tom,

That was exactly the information that I needed.

Patrick


On Aug 30, 2007, at 4:34 PM, Thomas Watson wrote:

The issue is on Mac the SWT event loop must run on the main thread. That is a pretty hard thing to do in an OSGi environment. When a bundle is activated it has no idea what thread is activating it. Even if the bundle knew the activating thread was the main thread it would never want to actually run the SWT event loop in the BundleActivator.start method because that would hang the Bundle.start() operation. Instead the bundle should spawn a separate thread to run the SWT event loop, but that thread will not be the main thread so SWT will fail to work on Mac.

In Eclipse we have the notion of an Eclipse Application which are defined by an extension to the org.eclipse.core.runtime.applications extension point. By default Eclipse Applications are run on the main thread. This is accomplished by the boot strap code (EclipseStarter) which has access to the main thread and waits for an application to be launched. This is the sample RCP application works on Mac. When using the -Declipse.ignoreApp=true option you are telling the bootstrap code to forget about launching an eclipse application on the main thread which allows the main thread to completely go away.

You have two options

1) Install the application model from eclipse. This includes 3 bundles (org.eclipse.equinox.common, org.eclipse.equinox.registry, org.eclipse.equinox.app). Then create an extension to org.eclipse.equinox.app and implement IApplication. In IApplication.start you can start the SWT event loop. You would add the three extra bundles to your osgi.bundles list and be sure to start the org.eclipse.equinox.app bundle. Also be sure to not use the eclipse.ignoreApp=true option.

osgi.bundles=org.eclipse.equinox.commom,org.eclipse.equinox.registry,org.eclipse.equinox.app@start,org.eclipse.swt.carbon.macosx_3.3.0.v3346.jar,org.eclipse.swt_3.3.0.v3346g.jar@start,org.eclipse.swt.sample_1.0.0.jar@start

You also need to tell the application model about your application with the program argument -application <your app extension id>

2) Use the org.eclipse.osgi.service.runnable.ApplicationLauncher service published by EclipseStarter (when not using eclipse.ignoreApp=true) to run the SWT event loop on the main thread. This is the same way the Eclipse Application model launches things on the main thread.

HTH.

Tom


<graycol.gif>
Patrick Dempsey ---08/30/2007 02:44:36 PM---I have a very simple SWT sample bundle (attached). It has both a main and a bundle activator so it can be run stand-alone or u

<ecblank.gif>

To
<ecblank.gif>

equinox-dev@xxxxxxxxxxx
<ecblank.gif>

cc
<ecblank.gif>

<ecblank.gif>

Subject
<ecblank.gif>

[equinox-dev] Simple SWT App launched with OSGi Launcher hangs on Mac OS X
<ecblank.gif>
<ecblank.gif>

I have a very simple SWT sample bundle (attached).  It has both a main and a bundle activator so it can be run stand-alone or under Equinox. 

I am trying to run on an Intel MacBook 10.4.10 with Eclipse 3.3 GA version

It runs fine stand-alone, it runs fine if I invoke java 
java -Declipse.ignoreApp=true -Dosgi.noShutdown=true -XstartOnFirstThread -jar plugins/org.eclipse.osgi_3.3.0.v20070530.jar -console

If I run it just about every other way I can think of, I get the spinning beachball and the Icon in the Dock shows "Application Not Responding"
I tried running:
1. as a Open Run Dialog...->OSGi Framework with 
Program arguments: -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -console
VM arguments: -Declipse.ignoreApp=true -Dosgi.noShutdown=true -XstartOnFirstThread
2. from the command line 
java -Declipse.ignoreApp=true -Dosgi.noShutdown=true -XstartOnFirstThread -jar plugins/org.eclipse.osgi_3.3.0.v20070530.jar -console
config.ini:
osgi.bundles=org.eclipse.swt.carbon.macosx_3.3.0.v3346.jar,org.eclipse.swt_3.3.0.v3346g.jar@start,org.eclipse.swt.sample_1.0.0.jar@start
3.  with the Eclipse.app
config.ini:
osgi.bundles=org.eclipse.swt.carbon.macosx_3.3.0.v3346.jar,org.eclipse.swt_3.3.0.v3346g.jar@start,org.eclipse.swt.sample_1.0.0.jar@start
eclipse.ini:
-noExit
-console
15001
-vmargs
-Declipse.ignoreApp=true
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts

Am I missing a command line option to make this work?  Or is there something special I need to do in the SWT code to make this work?

I also tried the RCP example that is packaged with Eclipse to see if all SWT applications have this problem but that ran just fine, and the UI did not hang.  

I checked bugzilla and found launcher bugs dealing with swing, swt, launcher interactions but none with just the launcher and SWT.

Attached is com.eclipse.swt.sample.src.zip which contains the project com.eclipse.swt.sample and the binary bundle com.eclipse.swt.sample_1.0.0.jar[attachment "org.eclipse.swt.sample.src.zip" deleted by Thomas Watson/Austin/IBM]
Thanks,
Patrick

_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev

<graycol.gif>
<pic27008.gif>
<ecblank.gif>
_______________________________________________

equinox-dev mailing list