jmonkeyengine: Lwjgl-3.3.0 GLFW cannot create a GL window on armhf

I have tested jme3-lwjgl3 dependency with :

  1. Lwjgl-3.3.0 GLFW and natives, the GLFW cannot create the GL window :
pi@raspberrypi:~/NativeJmeTemplate/output/run $ ./run.sh 
Run
..................................
Dec 09, 2021 12:44:14 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.5.0-alpha1
 * Branch: HEAD
 * Git Hash: dc91668
 * Build Date: 2021-11-14
Dec 09, 2021 12:44:16 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 3.3.0 build 21 context running on thread jME3 Main
 * Graphics Adapter: GLFW 3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic shared
Dec 09, 2021 12:44:16 PM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: Broadcom
 * Renderer: V3D 4.2
 * OpenGL Version: 2.1 Mesa 19.3.2
 * GLSL Version: 1.20
 * Profile: Compatibility
Dec 09, 2021 12:44:16 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.ogre.MeshLoader
Dec 09, 2021 12:44:16 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.ogre.SkeletonLoader
Dec 09, 2021 12:44:16 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.ogre.MaterialLoader
Dec 09, 2021 12:44:16 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.ogre.SceneLoader
Dec 09, 2021 12:44:16 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.fbx.FbxLoader
Dec 09, 2021 12:44:16 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.gltf.GltfLoader
Dec 09, 2021 12:44:16 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.gltf.BinLoader
Dec 09, 2021 12:44:16 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.gltf.GlbLoader
Dec 09, 2021 12:44:16 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.audio.plugins.OGGLoader
Dec 09, 2021 12:44:16 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.NullPointerException
	at org.lwjgl.system.Callback.get(Callback.java:190)
	at org.lwjgl.glfw.GLFWWindowSizeCallback.create(GLFWWindowSizeCallback.java:36)
	at org.lwjgl.glfw.GLFWWindowSizeCallback.createSafe(GLFWWindowSizeCallback.java:45)
	at org.lwjgl.glfw.GLFW.glfwSetWindowSizeCallback(GLFW.java:3139)
	at com.jme3.input.lwjgl.GlfwMouseInput.initCallbacks(GlfwMouseInput.java:243)
	at com.jme3.input.lwjgl.GlfwMouseInput.initialize(GlfwMouseInput.java:184)
	at com.jme3.app.LegacyApplication.initInput(LegacyApplication.java:337)
	at com.jme3.app.LegacyApplication.initialize(LegacyApplication.java:640)
	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:198)
	at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:524)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:640)
	at com.jme3.system.lwjgl.LwjglWindow.create(LwjglWindow.java:477)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:491)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:443)
	at com.jme3.app.SimpleApplication.start(SimpleApplication.java:126)
	at test.TestJni.main(TestJni.java:18)

Dec 09, 2021 12:44:16 PM com.jme3.app.LegacyApplication handleError
SEVERE: Failed to destroy context
java.lang.NullPointerException
	at org.lwjgl.system.Callback.get(Callback.java:190)
	at org.lwjgl.glfw.GLFWErrorCallback.create(GLFWErrorCallback.java:40)
	at org.lwjgl.glfw.GLFWErrorCallback.createSafe(GLFWErrorCallback.java:49)
	at org.lwjgl.glfw.GLFW.glfwSetErrorCallback(GLFW.java:1288)
	at com.jme3.system.lwjgl.LwjglWindow.destroyContext(LwjglWindow.java:436)
	at com.jme3.system.lwjgl.LwjglWindow.deinitInThread(LwjglWindow.java:624)
	at com.jme3.system.lwjgl.LwjglWindow.lambda$initInThread$12(LwjglWindow.java:494)
	at java.base/java.lang.Thread.dispatchUncaughtException(Thread.java:2002)

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  20 (X_GetProperty)
  Resource id in failed request:  0x1a00061
  Serial number of failed request:  1818
  Current serial number in output stream:  1818

Seems that GLFW cannot find the graphics adapter :

INFO: LWJGL 3.3.0 build 21 context running on thread jME3 Main

  • Graphics Adapter: GLFW 3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic shared

I believe that this is a lwjgl issue, but we are expecting its from jme until proved otherwise.

  1. Lwjgl-3.2.3 GLFW and natives, the app works fine with a non null graphics adapter :

image

Sorry i am not on the pi now to copy this stack trace, but this is the important finding.

forum thread : https://hub.jmonkeyengine.org/t/jme3-5-0-alpha-on-armhf/45207/2?u=pavl_g

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 18 (18 by maintainers)

Most upvoted comments

The root cause of the GLXBadFBConfig crash was that the RPi doesn’t support OpenGL 3.2 . Back in January, PR #1752 made 3.2 the default.

The workaround was to set the renderer to “LWJGL-OpenGL2” in main(). With that workaround, I was able to run TestJaime, both with LWJGL 3.2.3 and LWJGL 3.3.1 . I was also able to reproduce the original NPE (in Callback.java line 190) using LWJGL 3.3.0 .

Closing this issue.

I added a commit on my fork that may fix your issue: https://github.com/Ali-RS/jmonkeyengine/commit/5dc3e27d388da9290e967185874920386e6465e0

can you give it a try, please?

should we set opengl to 2

That’s way outside my area of expertise, so I leave that to others to decide.

The issue is persistent with lwjgl-3.3.0, but it has been resolved on lwjgl-3.3.1

Based on your testing, it’s clear we can solve the “Callback.java” NPE in the v3.5 branch by simply backporting https://github.com/jMonkeyEngine/jmonkeyengine/commit/ae750c0696c561774ea8271d521b9bc40a2be0ee (upgrading LWJGL to v3.3.1). My own tests confirm this.

The NPE was a regression relative to JME 3.4.1. Therefore, we should backport the fix ASAP and publish a JME 3.5.2 release. I’ll start the process.

Now that I have RPi hardware, I’m seeing a similar issue with current “master” branch JMonkeyEngine (which uses lwjgl-3.3.1): GLFW fails to create a window. However, the stack trace is different than the one reported above:

Apr 13, 2022 11:23:15 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.6.0-SNAPSHOT
 * Branch: master
 * Git Hash: 3d979df
 * Build Date: 2022-04-13
Apr 13, 2022 11:23:16 PM com.jme3.app.LegacyApplication handleError
SEVERE: GLX: Failed to create context: GLXBadFBConfig
java.lang.Exception: GLX: Failed to create context: GLXBadFBConfig
	at com.jme3.system.lwjgl.LwjglWindow$1.invoke(LwjglWindow.java:229)
	at org.lwjgl.glfw.GLFWErrorCallbackI.callback(GLFWErrorCallbackI.java:43)
	at org.lwjgl.system.JNI.invokePPPP(Native Method)
	at org.lwjgl.glfw.GLFW.nglfwCreateWindow(GLFW.java:2024)
	at org.lwjgl.glfw.GLFW.glfwCreateWindow(GLFW.java:2197)
	at com.jme3.system.lwjgl.LwjglWindow.createContext(LwjglWindow.java:294)
	at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:582)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:704)
	at java.base/java.lang.Thread.run(Thread.java:834)

Apr 13, 2022 11:23:16 PM com.jme3.app.LegacyApplication handleError
SEVERE: Failed to create display
java.lang.RuntimeException: Failed to create the GLFW window
	at com.jme3.system.lwjgl.LwjglWindow.createContext(LwjglWindow.java:296)
	at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:582)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:704)
	at java.base/java.lang.Thread.run(Thread.java:834)

Apr 13, 2022 11:23:16 PM com.jme3.system.lwjgl.LwjglWindow run
SEVERE: Display initialization failed. Cannot continue.

Yes, I will try to prepare a testcase for lwjgl-3.3.1 by the next week.

I added a commit on my fork that may fix your issue

I doubt it fixes the problem. I hope I’m wrong of course. But this is very good fix nevertheless. Could also cause a memory leak since the MouseInput hijacked the callback but actually never even bothered to close it like the Window tried to. Good stuff!