[SOLVED] LWJGL3 hangs on OS X

Hi guys,

I’m trying to run the lwjgl3 module on my MacBook Pro (10.14.6). I have JDK 14.0.1, and also set JVM option -XstartOnFirstThread.

Here is my settings;

public static void main(String args[]) {
    GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();

    AppSettings setting = new AppSettings(true);
    setting.setFullscreen(true);
    setting.setFrameRate(60);
    setting.setFrequency(device.getDisplayMode().getRefreshRate());

    HelloPhysics app = new HelloPhysics();
    app.setShowSettings(false);
    app.setSettings(setting);
    app.start();
}

No error is thrown, everything seems to run but there is no windows shown. It just hangs, and the game does not start. Even though I use default options, the settings dialog does not appear.

No Gradle error, here is the Gradle running image:

When I switch to LWJGL2 (jme3-lwjgl module) everything works.

Macs, lwjgl3 (more specifically glfw), and AWT (see above) don’t get along as far as I understand it.

What happens if you don’t set the frame rate but set vsync instead (the better way)?

The following two setups have the same behavior (no action, no windows shown):

   public static void main(String args[]) {
        GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();

        AppSettings setting = new AppSettings(true);
        setting.setFullscreen(true);
        setting.setFrequency(device.getDisplayMode().getRefreshRate());
        setting.setVSync(true);

        HelloPhysics app = new HelloPhysics();
        app.setShowSettings(false);
        app.setSettings(setting);
        app.start();
    }

AND

public static void main(String args[]) {
    HelloPhysics app = new HelloPhysics();
    app.setShowSettings(true);
    app.start();
}

It’s like, app is running, but somehow the app window can’t get created.

What is the distributor for your jdk?

Many Oracle & OpenJDK builds late in the java11 release cycle and later seem to have issues with LWJGL3.

Try a jdk from AdoptOpenJDK, which seems not to have this issue. If it still doesn’t work, try downgrading to jdk11. (still from AdoptOpenJDK)

Maybe pspeed referred to this line, that lose it altogether to avoid initializing AWT.

And this wont work. The settings dialog is AWT (Swing).

As far as I know. Some stuff from AWT can be used that are… headless? Or somehow don’t create any contexts or whatever it is that messes the LWJGL 3.

Yes, thank you! This setup worked (OpenJDK 11/14, AdoptOpenJDK 11/14):

public static void main(String[] args) {
    AppSettings setting = new AppSettings(true);
    setting.setFullscreen(true);
    setting.setFrameRate(60);
    setting.setVSync(true);

    HelloPhysics app = new HelloPhysics();
    app.setShowSettings(false);
    app.setSettings(setting);
    app.start();
}
2 Likes