Hello Guest

LWJGL 3.2.2 Mac OS X bug

  • 7 Replies
  • 5047 Views
LWJGL 3.2.2 Mac OS X bug
« on: June 19, 2019, 12:51:33 »
So I don't know why but my game still keeps crashing even though I use -XstartOnFirstThread. Here is a screenshot with all the information I have. Everything gets created on the main thread for sure!

*

Offline KaiHH

  • ****
  • 334
Re: LWJGL 3.2.2 Mac OS X bug
« Reply #1 on: June 19, 2019, 13:04:16 »
You get a "is only safe to invoke on the main thread" error message. So, you are _definitely_ not calling all GLFW windowing methods on the main thread!
Please use the https://github.com/LWJGLX/debug Java agent when running your application. It will tell you, where you are calling a method which requires to be called on the main thread.

Re: LWJGL 3.2.2 Mac OS X bug
« Reply #2 on: June 19, 2019, 13:15:20 »
I'll check it again.
« Last Edit: June 19, 2019, 13:23:47 by haubna »

Re: LWJGL 3.2.2 Mac OS X bug
« Reply #3 on: June 19, 2019, 14:04:35 »
I've checked every single GLFW call now and everything is on the main thread. The game works fine on Windows and Linux. The crash occurs on this call:

Code: [Select]
GLFW.glfwCreateWindow(width, height, title, MemoryUtil.NULL, MemoryUtil.NULL);

Re: LWJGL 3.2.2 Mac OS X bug
« Reply #4 on: June 19, 2019, 14:27:18 »
I guess it crashes here because in the screenshot above it says "GLFW can only be used for offscreen rendering.". So creating a visible window causes a crash. But I am doing everything you have to do to let it run on the main thread on OS X

Re: LWJGL 3.2.2 Mac OS X bug
« Reply #5 on: June 19, 2019, 15:11:07 »
I've tried the SpaceGame Demo from LWJGL3. Still the same error. Now it's officially a LWJGL/GLFW/OpenJDK 12/Mac OS X bug.
« Last Edit: June 19, 2019, 15:13:11 by haubna »

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: LWJGL 3.2.2 Mac OS X bug
« Reply #6 on: June 19, 2019, 19:08:12 »
Move -XstartOnFirstThread before the -jar argument. Currently you're passing it as an argument to the application's main method, instead of an argument to the JVM.

Re: LWJGL 3.2.2 Mac OS X bug
« Reply #7 on: June 20, 2019, 08:43:11 »
I feel so dumb. Thanks that works but now occurs another problem.
It seems that I don't get the core profile that I request through GLFW.
My window hints are these:

Code: [Select]
GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3
GLFW.GLFW_CONTEXT_VERSION_MINOR, 2
GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE
GLFW.GLFW_OPENGL_FORWARD_COMPAT, GLFW.GLFW_TRUE

Then i check the version with GL11

Code: [Select]
GL.createCapabilities();
System.err.println("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION));
System.err.println("Device: " + GL11.glGetString(GL11.GL_RENDERER));

It returns the 4.1 on Mac
OpenGL version: 4.1 INTEL-12.9.22
Device: Intel(R) Iris(TM) Graphics 6100

On windows it returns
OpenGL version: 3.2.0 NVIDIA 416.34
Device: GeForce GTX 1080 Ti/PCIe/SSE2

When I try to use the GL Core class on Mac they return null and don't work but on Windows and Linux they work like a charm.
For example this returns null even though the GL11 class returned a proper string

Code: [Select]
System.err.println("OpenGL version: " + GL32C.glGetString(GL32C.GL_VERSION));
System.err.println("Device: " + GL32C.glGetString(GL32C.GL_RENDERER));

Maybe I am doing something wrong I don't know honestly. For me it looks like it doesn't get the proper OpenGL context.

Update:
Those are the supported versions returned by GL.createCapabilities()
    1.1 true
    1.2 true
    1.3 true
    1.4 true
    1.5 true
    2.0 true
    2.1 true
    3.0 true
    3.1 true
    3.2 true
    4.0 true
    4.1 true
    4.2 false
    4.3 false

Also using the GL32C.glCreateShader(type); always returns 0 (shader creation failed). So it probably has to do something with the OpenGL context.

Update 2:
Fixed it. I had a static Toolkit.getDefaultToolkit().getScreenResolution() call which starts AWT and kills the context or something like that. That took me a while.
« Last Edit: June 20, 2019, 10:24:11 by haubna »