So we purchased a new laptop with a GeForce GPU so that we can reproduce, investigate and fix this problem..
At first the problem didn't reproduce, but then, I found that as it was a laptop with GeForce + Intel integrated graphics, I needed to go to the Nvidia Control Panel, and set it to use Nvidia both in global settings and in per application settings for Pro Tools. I believe that this step is unneccessary for PCs that have only an Nvidia GPU..
Then the problem successfully reproduced, but sadly it doesn't consistently crash.. if I try it for 20 times or so.. then I do get a crash.
The crash happened in nvoglv64 code while the OpenGL Rendering Thread was in a call to wglMakeCurrent, while the main thread was waiting for the rendering thread to finish in the destructor of my view calling the context's detach method.
I couldn't find anything fishy, but one thing that did come to my mind is that this specific call to wglMakeCurrent in the OpenGL Rendering Thread is probably not even necessary, as all this thread does pretty much is render using this context to my OpenGL component, so it probably doesn't even change contexts.. So if it's an unnecessary call that seems to cause the crashe, what happens if we avoid it? so in OpenGLContext::NativeContext::makeActive I added a check to see if it's already active, avoiding a call in that case..
bool makeActive() const noexcept
{
if (isActive())
return true;
return wglMakeCurrent (dc, renderContext) != FALSE;
}
With this workaround (fix??) I couldn't produce the crashes anymore.
For now I'll send this version to some unsatisfied costumers to see if it resolves the problems for them too. Will update on that.
Another possibly interesting finding:
When trying to reproduce this problem on this new laptop, trying to figure out how to force it to use its Nvidia driver+gpu, before succeeding using the Nvidia Control Panel as described above, I tried disabling the driver for the Intel Integrated Graphics in the device manager, assuming that without the intel driver the machine will use the nvidia one.. (btw this doesn't seem like a really good state as the Nvidia Control Panel refuses to open giving a message that this computer does not use the nvidia gpu..)
In this state, when closing the plugin window, instead of crashing, it becomes stuck for 10 seconds.. the stopThread for the rendering thread fails the 10 seconds timeout and reaches the place in the code with comment "very bad karma if this point is reached".. Meanwhile the rendering thread is stuck at a loop in clearGLError() called from CachedImage::RenderFrame.
donno if this is useful data, not sure even how healthy is this state where the intel driver is disabled..
Any thoughts?
Cheers! Yair