I have a utility library that uses glfw internally. I’ve used this library to write a number of applications that work fine. I have another application that is launched via a Process.Start() function from inside a .NET Windows service. In this case, I see a crash in glfwInit(). I’m able to run other applications using my utility library on this same computer without issue. The only other glfw call prior to this is a call to glfwSetErrorCallback(). Any ideas what the problem could be?
My first guess is that the service does not have the required privileges to open a window.
I searched for “starting a process from a windows service” and found this stackoverflow which seems to confirm that:
I’m a .NET developer myself and I have some bad experiences with crashes on glfwInit which often resulted in days of cursing, frustration and devil worshiping as long as the bloody thing would run. Eventually it did though.Therefore I would like to see if I can help you.
First of all, can you share the error logs in the event viewer, if any? And if not, can you figure what error code the service crashes with? Should be a 0x000 thing. And are you able to debug the service using Visual Studio? Are you using the old .NET framework or .NET Core? And if so, which version? Are you pInvoking the GLFW methods or are you using a 3rd party library? Actually, can you share source code with us?
With kind regards,
It’s not the service that crashes, it’s the application that launches from the service. The service itself works fine. The application is an ordinary unmanaged 64 bit WIndows C++ program.
The service has no problem starting the application or opening non-OpenGL windows. The problem only arises when the program gets to the part that calls glfwInit(). The GLFW portion of the program is just for a specific feature that renders to an off-screen buffer.
I’m not sure, but my understanding is that services do not have access to user’s session - thus to current GPU hardware acceleration. That means application will load only Microsoft GDI software implementation for OpenGL. But glfw documentation explicitly states that it does not support it: https://www.glfw.org/docs/latest/group__window.html#ga5c336fddf2cbb5b92f65f10fb6043344
If you’re OK with software rendering, you can compile Mesa library - that will provide opengl32.dll that you can place next to application, then it should work fine.