英文:
LWJGL GLFW hangs on native glfwInit call
问题
I originally posted this question on GameDev stackexchange however I'll also ask the question here to try and get more outreach, especially since I wasn't sure my problem was specific to game development since it's a problem with a Java native call.
在过去的几个月中,我一直在使用LWJGL逐步创建自己的游戏引擎,仅供个人使用,我从开发者ThinMatrix的代码中提取了一些片段,以此来学习并构建引擎时尽可能多地了解。只是最近,当我从IntelliJ启动引擎进行测试时,出现了奇怪的行为:
-
在我点击运行大约6-10次之后,随后的运行窗口突然需要大约60秒才能出现。
-
每次重新启动计算机后,这种挂起都会重置,我又可以运行6-10次,然后再次每次都会挂起。
-
我确定问题出现在
glfwInit
函数上,具体是在调用本机方法时:@NativeType("int") public static boolean glfwInit() { long __functionAddress = Functions.Init; return invokeI(__functionAddress) != 0; // 此处 }
-
我还注意到,只有在我尝试使用STBTrueType库在我的引擎中实现文本支持时,这个问题才开始出现。在那之前,一切都很正常。我尝试删除了TrueType代码,但问题并没有解决。
以下是我尝试过的一些方法:
- 清除我的临时文件夹,以防存在错误或损坏的文件。
- 两次重新编译和重建整个LWJGL库。
- 从GLFW源代码构建
glfw.dll
,并用前者替换本机库中的glfw.dll
。 - 重新安装Java,并升级JDK版本(从13.0.2到14.0.2)。
- 即使我怀疑不会起作用,也尝试切换IDE。
- 更新NVIDIA驱动程序并重新安装它们。
我对可能的原因感到困惑,如果您认为有必要,我非常乐意分享代码、线程转储或调试信息。这是带有最新“有问题”代码的Github存储库(“有问题”代码之所以加引号是因为我不确定代码是否是问题所在)。
非常感谢您的任何指导。
P.S:请告诉我是否更适合在StackOverflow上提问,而不是在这里。
英文:
I originally posted this question on GameDev stackexchange however I'll also ask the question here to try and get more outreach, especially since I wasn't sure my problem was specific to game development since it's a problem with a Java native call.
For the past months I've been working on creating my own game engine for personal use in LWJGL using pieces here and there, especially from developer ThinMatrix's rightfully credited code, to learn as much as I can while building it. Only recently there has been strange behavior happening when I launch the engine from IntelliJ for testing:
-
After about 6-10 individual times I click run, all subsequent runs suddenly take about 60 seconds for the window to appear.
-
Whenever I restart my PC this hanging resets and I have another 6-10 runs before it hangs everytime again.
-
I located the issue to
glfwInit
, more specifically at the call to the native method:@NativeType("int") public static boolean glfwInit() { long __functionAddress = Functions.Init; return invokeI(__functionAddress) != 0; // Right here }
-
I also noticed that this issue only started when I attempted to implement text support in my engine using the STBTrueType library. It was perfectly fine before that. I tried removing the TrueType code but it didn't fix it.
Here's a list of things I've tried:
- Clearing my temp folder in case a buggy or corrupted file was present.
- Recompiling and rebuilding the entire LWJGL jars twice.
- Building
glfw.dll
from the GLFW sources and replacing theglfw.dll
in the native jars with the former. - Reinstalling Java and actually upgrading JDK versions (from 13.0.2 to 14.0.2)
- Switching IDEs even if I suspected it wouldn't work.
- Updating my NVIDIA drivers, and reinstalling them.
I'm quite confused as to what it could be, and I'd be more than happy to share code, thread dumps, or debug info if you deem it necessary. Here is the Github repository with the latest, "faulty" code (fault in quotes because I'm not too sure the code is the problem.)
Thank you very much for any guidance.
P.S: Please tell me if this is better asked in StackOverflow instead of here.
答案1
得分: 1
I fixed the issue, it turns out it wasn't even related to anything to do with programming, or STBTrueType, or the library itself. The problem was as pointed out in this StackOverflow post, where this hanging behavior was due to a faulty driver or, in my case, my keyboard USB being plugged in the "wrong" USB port. I moved my computer at the same time I started working on text in my engine, hence why I wrongly linked the issue with the TrueType library. If you're having the same issue, look at the aforementioned post or if that doesn't work, look for a peripheral that might cause interference.
英文:
So I fixed the issue, it turns out it wasn't even related to anything to do with programming, or STBTrueType, or the library itself. The problem was as pointed out in this StackOverflow post, where this hanging behavior was due to a faulty driver or, in my case, my keyboard USB being plugged in the "wrong" USB port. I moved my computer at the same time I started working on text in my engine, hence why I wrongly linked the issue with the TrueType library. If you're having the same issue, look at the aforementioned post or if that doesn't work, look for a peripheral that might cause interference.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论