LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: haubna on June 19, 2019, 12:51:33

Title: LWJGL 3.2.2 Mac OS X bug
Post by: haubna 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!
Title: Re: LWJGL 3.2.2 Mac OS X bug
Post by: KaiHH 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.
Title: Re: LWJGL 3.2.2 Mac OS X bug
Post by: haubna on June 19, 2019, 13:15:20
I'll check it again.
Title: Re: LWJGL 3.2.2 Mac OS X bug
Post by: haubna 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:


GLFW.glfwCreateWindow(width, height, title, MemoryUtil.NULL, MemoryUtil.NULL);
Title: Re: LWJGL 3.2.2 Mac OS X bug
Post by: haubna 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
Title: Re: LWJGL 3.2.2 Mac OS X bug
Post by: haubna 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.
Title: Re: LWJGL 3.2.2 Mac OS X bug
Post by: spasi 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.
Title: Re: LWJGL 3.2.2 Mac OS X bug
Post by: haubna 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:


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


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


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()

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.