Closed kappaOne closed 1 year ago
Hey @kappaOne,
Tested on Windows 11, Zulu JDK 18, latest Nvidia drivers:
Hi Spasi,
Thanks for the quick testing.
After some more testing, the hanging and slow down (and eventual crash) appears to be due to sudden 100% CPU usage on the main thread.
It appears that while resizing the GLFW window using the OpenGL Renderer, VSync continues to work (consistent fps) thus throttling the main thread (application loop) as normal.
However when using the Vulkan Renderer and resizing the window, the fps becomes uncapped causing main thread (application loop) to run at 100% causing the hanging and eventually crashing the driver/app. If you stop resizing the window before it hangs the vsync capped fps returns back to normal.
Adding a simple Thread.sleep() into the application loop prevents the hanging/crashing with the Vulkan renderer. I am leaning towards this being a driver bug or a problem with the way BGFX Vulkan renderer handles resizing here (such as causing vsync to disable during resizing).
While running without vsync the Vulkan Renderer can run at full fps without causing the 100% cpu usage (even during resizing), so something with the vsync flag is triggering this issue.
I've now tested on an intel card and can confirm that the issues doesn't happen there, therefore this is most likely a nvidia driver bug.
Version
3.3.2 (nightly)
Platform
Linux x64
JDK
Zulu OpenJDK 17
Module
BGFX, Vulkan, GLFW
Bug description
I am having issues using VSync with BGFX when the Vulkan backend is enabled.
When using BGFX, you can enable VSync using BGFX_RESET_VSYNC as a reset flag. Initially it appears to start and run fine, however when doing any window (GLFW specific) events, such as resizing or moving the window, the application begins to freeze and then eventually lead to a hang and/or crash.
Steps to reproduce: 1) Run the ExampleBGFX (NanoVG) demo. 2) Ensure the BGFX.BGFX_RESET_VSYNC is set as a reset flag, so that Vsync is enabled. 3) Ensure the Vulkan renderer is being used or select it manually using BGFX_RENDERER_TYPE_VULKAN with BGFXInit.type(), on linux it mostly appears to default to Vulkan. 4) Resize the window for a bit or drag it around and it will eventually cause the program to hang and/or crash.
I have reproduced the issue on multiple computers using Linux x64, however have not yet been able to test it on Windows or any AMD graphics cards (so if anyone could test this there that would also help narrow the issue down to whether its platform or graphics card specific).
The issue does not happen when using the OpenGL renderer, BGFX_RENDERER_TYPE_OPENGL, so appears to be Vulkan renderer specific. This may be an upstream issue however, best to first try narrow it down further.
Stacktrace or crash log output