husker-dev / openglfx

OpenGL implementation for JavaFX
Apache License 2.0
80 stars 10 forks source link

Native crash when calling OpenGLCanvas.create (WinUtils.hasDXInterop) #44

Closed streamingdv closed 8 months ago

streamingdv commented 8 months ago

Hi, I recently got a new AMD Test PC and tried to run my application on it but it seems it immediately crashes when I try to create a OpenGLCanvas

final OpenGLCanvas canvas = OpenGLCanvas.create(LWJGLExecutor.LWJGL_MODULE, OpenGLCanvas.CORE_PROFILE);

I know there was some kind of refactoring and bug fixes ongoing last couple of months so maybe this is already fixed in the upcoming new version but not sure. I ran my project on a Windows 11 PC. I attach here the crash logs

hs_err_pid9608.log

Is this something which is already known? If not any more information I can provide?

husker-dev commented 8 months ago

Hi! It looks like your graphics card doesn’t support dx_nv_interop, or does it unexpectedly. You can check it in some GL tool applications. As I remember, I have changed the way of detecting it, but I'll try to figure out this problem.


I have some problems with Linux natives compilation and free time to solve it. So, I don’t know when I can release a new version. Anyway, thanks for the interest 🙂

streamingdv commented 8 months ago

Okay, I think it should support it but anyway even if not then a crash should not happen :) What kind of tools can I use to check if dx_nv_interop is available?

Okay I see, yeah no worries I will keep on testing my application once the new version is ready.

streamingdv commented 8 months ago

@husker-dev another question, I mainly use your project for rendering my real time stream. Besides the problem I already reported it works great (one of the best JavaFX projects I found in the recent years 👍).

My program is built like that, that the stream is rendered in a separate Stage which gets closed when the streaming session ends (but the overall program doesn't exit). So the OpenGLCanvas (with LWJGL) can be generated (and destroyed) multiple times during the lifetime of my application. I'm currently extensively testing my app and it's rendering engines and it seems that memory grows with everyone creation of the OpenGLCanvas. I'm not yet 100% sure the leak is caused by OpenGLFX but it seems it doesn't happen with my other rendering approaches. Is there a way to release native OpenGL resources once the OpenGLCanvas gets destroyed? Is this even necessary or am I using the canvas in a way that was never intended?

Edit: I found that there is the onDispose event but it never gets called, I checked the current source code but the fireDisposeEvent inside the OpenGLCanvas is not used or called by any part of the OpenGLFX project. So how to release native resources within the OpenGL context?

husker-dev commented 8 months ago

@streamingdv You can install OpenGL Extensions Viewer to check you extensions.

WGL_NV_DX_interop is under NV group.

image

image

streamingdv commented 8 months ago

Okay will check, you might be right that it isn't supported. But I guess it should not crash upon performing the check in OpenGLFX (but might not occur anymore on the unreleased master branch)

streamingdv commented 8 months ago

@husker-dev FYI, I was away from the test PC for two weeks but I checked now again the support for WGL_NV_DX_interop and indeed the GPU supports that on the test device but calling the function WinUtils.hasDXInterop is crashing the application.

OpenGLExtensionViewer1 OpenGLExtensionViewer2

husker-dev commented 8 months ago

@streamingdv can you test the current master branch to see if this crash still exist? You can just clone repo and run :LWJGL task in gradle

streamingdv commented 8 months ago

@husker-dev I did some further testing the last couple of days and the issue seems not really related to the lib. The problem only exists when I execute the program via IntelliJ. When I build it via the javapackager plugin and when I execute the compiled exe on the same PC with the bundled JVM everything runs totally fine. I don't know what it is but so far whenever I execute a OpenGLFX method the program crashes (within IntelliJ). The reason why I don't think its directly related to OpenGLFX is that I can also reproduce the error when I set the prism order to

System.setProperty("prism.order", "es2,sw");

Which triggers to load my custom compiled javafx.graphics.jar which also leads to a crash. Weird thing is that everything else works when I execute my compiled exe application with the bundled JVM (same bundled java version as my JAVA_HOME) and so far I could not reproduce this problem on any other machine. I think this issue can be closed for now as it basically works as it should when I fully deploy my program. Let me know what you think.

husker-dev commented 8 months ago

I think it's a driver issue. Namely with OpenGL. When library is checking for WGL_NV_DX_interop support, it creates a temporary OpenGL context, which possibly causes a crash. So, I think this issue can be closed.

streamingdv commented 8 months ago

@husker-dev probably yes but I have no explanation then why it works on the same PC outside of IntelliJ. It uses the same JVM and same parameters and it just works as it should, just not when executed via IntelliJ, which is weird 😅