-
Notifications
You must be signed in to change notification settings - Fork 5.5k
GLFW_PLATFORM_ERROR on launching a simple lwjgl app #2680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can reproduce this on my system (arch, kde, wayland, all latest.) too. I tried, but failed to find the cause. But posting the progress here anyway, as it might be useful. With the normal glfw (installed by system or built from this repo), everything works fine. I tried a minimal C example and it all works fine. Run lwjgl with system glfwSo, I decided to run the kotlin example with system's
I can verify that system library is chosen, but due to lacking the IME symbols, it fails to load.
Check lwjgl's glfw forkAnyway, I cloned https://github.com/LWJGL-CI/glfw , which seems to be the fork that Try running kotlin example with lwjgl's glfw fork (custom built)So, I updated the options to point to the new *-Dorg.lwjgl.glfw.libname=/home/user/projects/glfw/libglfw.so (this is built from lwjgl's fork) And it loads successfully (yay, so I am loading the fork's library with IME symbols linked):
Still a failure? More debuggingBut we get the same egl error again. After editing the glfw source to add more context to errors, I found that the error triggers when setting the current context to null. So, the callstack leading to error is: The same _glfw.egl.display pointer is used to set the window current and to detach the current context (by setting the null as current at the end) in Anyway, I tried to reduce the variables and came up with this short snippet. import org.lwjgl.glfw.*
import org.lwjgl.system.MemoryUtil
fun main() {
GLFWErrorCallback.createPrint(System.err).set()
if (!GLFW.glfwInit()) {
println("Unable to initialize GLFW")
}
println(GLFW.getLibrary().path)
val window = GLFW.glfwCreateWindow(800, 600, "Foo", 0, 0)
if (window == MemoryUtil.NULL) {
println("Failed to create GLFW window")
}
println("making $window current")
GLFW.glfwMakeContextCurrent(window)
println("making null current")
GLFW.glfwMakeContextCurrent(0);
} If you run this example, you will see the error only trigger once at window creation and then, once at "making null current". Just for sanity, I also checked if it was running on main-thread with I also verified that choosing x11 platform
I don't know kotlin/java, so, this is as far as I can go. The error only triggers with kotlin/jvm, while I can verify that using C (or Rust) has no problems on wayland (or x11 + egl). |
@dougbinks This is a duplicate of #2510 (same error, with more comments) |
According to libgdx/gdx-liftoff#206 , this might be a wayland + nvidia specific issue? The solution is to set env var I can't believe I wasted so much time on debugging this, and it turns out to be a nvidia driver bug 😭 I think this issue can be closed or maybe merged with #2510 . |
From what I can understand this issue does not occur when using GLFW with C, and thus could well be an LWJGL specific issue. For the moment I will mark this as external unless it can be replicated with pure C code. |
@dougbinks This bug is not LWJGL-specific. It reproduces in upstream GLFW with:
The only difference seems to be that, whatever heuristic the Nvidia driver uses to enable threaded optimizations defaults to enabled with Java applications, but defaults to disabled with the GLFW examples. |
Thanks, that's useful extra information - I think this is still external then, but likely a driver issue. |
I can reproduce those results, turning off that env var makes it run fine. |
Error:
Problem:
After printing the above error, Wayland does seem to create a window according to the taskbar, but it's permanently invisible and can't be focused, doesn't respond to keystrokes, etc.
Code snippet used
The text was updated successfully, but these errors were encountered: