#2005 [BUG] AWT/Swing apps don't work on Mac

davedes Fri 17 Aug 2012

EDIT - Found the problem. It's not just a LWJGL issue -- Swing apps (like swing.fan in examples) won't work on Macs because fanlaunch enters compatibility mode with "-XstartOnFirstThread", which in turn interferes with AWT (and thus Swing/LWJGL/etc). If SWT is not going to be used, this switch shouldn't be included. This switch is still needed for SWT/FWT apps, otherwise an "Illegal thread access" SWTException will be raised.

--

Howdy,

Been trying to set up Fantom to work with LWJGL. Here's my simple test application:

LWJGL Test

This works fine on Windows. I recently started testing on Mac and have been running into problems -- the window starts to hang/freeze (at which point I usually need to force quit). The output looks like this:

java[59035:80f] [Java CocoaComponent compatibility mode]: Enabled
java[59035:80f] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
java[59035:1ba03] *** -[NSConditionLock unlock]: lock (<NSConditionLock: 0x143cc0> '(null)') unlocked when not locked
java[59035:1ba03] *** Break on _NSLockError() to debug.

A search reveals that SWT and Mac has some issues with LWJGL/AWT: http://jmonkeyengine.org/groups/general-2/forum/topic/solved-jme2-mac-helios-swt-problems http://stackoverflow.com/questions/2386875/opening-a-lwjgl-window-from-a-swt-app-on-mac

The common solution is to "remove SWT dependencies" from the class-path. I have tried deleting Fantom's SWT dependencies in lib/java/ext, but to no avail.

Is there a way to run Fantom without any SWT dependency? Is there somewhere else that SWT dependencies might be stored in the Fantom directory?

I'll give it another go tonight once I'm back on my Mac, but I figured I would post this here in case anybody else has run into the same issue as me.

brian Fri 17 Aug 2012

I think if you just removed fwt.pod and the SWT code from lib/java then that would be clean. But what are you using for AWT then? I guess Java FFI and not fwt.

davedes Sat 18 Aug 2012

I've tried removing fwt.pod, gfx.pod, and all SWT dependencies within the "lib/java/ext" folder. This didn't seem to fix the problem, though, and it still goes into "Compatibility Mode."

For example, this simple script:

using [java] java.awt::Toolkit as TK
class Main {
  Void main()
  {
        TK.getDefaultToolkit()
  }
}

Will result in the following:

2012-08-17 20:08:09.420 java[25762:1707] [Java CocoaComponent compatibility mode]: Enabled
2012-08-17 20:08:09.422 java[25762:1707] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000

So I dug a little deeper, and found this in fanlaunch:

# MAC OS X we have to set to set a special flag
# to ensure that SWT will run correctly
if $darwin; then
  osFlags="-XstartOnFirstThread"
fi

Everything works when I comment/remove the above code. Maybe this switch could be moved to a more visible config file?

davedes Sat 18 Aug 2012

Just an update... Running into the same issue when I try using the NetBeans Fantom plugin. Can't for the life of me figure out why it's entering compatibility mode, after all SWT dependencies are removed and the fanlaunch shell edited... :\

EDIT: It seems hardcoded. Bummer.

Problematic plugin code...

Login or Signup to reply.