GLFW.glfwPollEvents() freezes on Mac


#1

I’m using LWJGL 3.1.6, and on the mac, GLFW freezes on glfwPollEvents(). The LWJGL HelloWorld example seems to work fine, and I don’t think my application is doing anything very different from that example. I’ve tried removing all my callback handlers with no luck.
It works on Windows. Does anybody have any tips for debugging this? Perhaps gotchas I should look for that could cause glfwPollEvents to hang?


#2

One thing to check as noted in the docs for glfwPollEvents is to ensure you are calling this from the main thread and not in a callback.


#3

debugging, it seems like we are on the main thread when it’s called, and it’s definitely not called in a glfw callback.
We’re adding the VM option: -XstartOnFirstThread

Are there any other vm options we need to consider?


#4

Ok, that took forever, but I found it!

If I ever call Toolkit.getDefaultToolkit().systemClipboard anywhere, the next poll events would hang (only on Mac).

So I’ve got some studying to do. Anybody have any insights why this is?


#5

I don’t know enough Java to be familiar with why this would be. Are you able to debug the glfwPollEvents() function C code with XCode at all?


#6

So I’ve been following the tutorial from https://vulkan-tutorial.com and have also been noticing my frame rate takes a hit every so often… after timing lots of part of my code thinking it was fence/semaphores related to rendering and trying to work out the cause… it ended up being that PollEvent was taking ~500ms every so often.
I have some solid repo steps. if you run the code from the end of the tutorial
https://vulkan-tutorial.com/Uniform_buffers/Descriptor_pool_and_sets.
When the app is running as long as I move the mouse I’m fine, as soon as I stop ~5secs after is when poll events takes 500ms, it then also normally takes the same on moving the mouse again… So I’m not sure if it’s macOS doing something after 5 seconds of idle that causes glfw to hang or maybe get spammed by so maybe events it take .5 sec, but the 5sec wait and the 0.5 sec poll event are pretty much always the same.


#7

Actually just after posting this, I realized my keyboard lights are set to turn off after 5 seconds, I changed it to 10 secs, and same repo as above but the freeze happened at 10 secs after moving mouse, so that seems to be the cause, the lights turning off cause poll event to take 500ms (probably the fade duration)?

I’ve submitted a issue on the glfw GitHub