LWJGL 3.2.2 Mac OS X bug

Started by haubna, June 19, 2019, 12:51:33

Previous topic - Next topic

haubna

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!

KaiHH

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.

haubna


haubna

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

haubna

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

haubna

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.

spasi

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.

haubna

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

    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.