Exception OpenGl_Window::CreateWindow: wglShareLists failed. Error code: 170 (The requested resource is in use)

Hi gentlemen, I have an exception in the OpenGl_Window constructor during render from another background thread.
The exception comes from wglShareLists(…) that return false and set GetLastError() to 170 (The requested resource is in use).

The main UI thread of my app use OCC to display geometry to user.

The thread that crash is using OCC with another viewer, another view, another AIS context... to generate images from geometry for a set of files in the background.

My environment is Windows 10 / OCC 7.5.0 / VS 2019.

Any idea is welcome.

Best regards.
Jerome.

Kirill Gavrilov's picture

The thread that crash is using OCC with another viewer, another view, another AIS context.

Does it use a dedicated OpenGl_GraphicDriver instance as well? Note that many samples have code line this:

static Handle(OpenGl_GraphicDriver) aDriver = new OpenGl_GraphicDriver();

which would create a global driver shared across Viewers (see "static"). This should be avoided in your multi-threaded case.

Jerome Monaco's picture

Hi Kirill and thanks for your prompt answer.
Yes this is the first thing I tried (sorry to have missed it in my email...) when I had first the problem, but same issue.
Does shared graphics attributes like Prs3d, Material aspects... can generate this kind of problem ?
Jerome.

Jerome Monaco's picture

Hi Kirill, I am a triple idiot, I missed a line in my code where I referencing the static graphic driver of the UI in place of the one I create especially for the thread... Really sorry for your time, OCC is working perfectly well.
Best regards.
Jerome.

Kirill Gavrilov's picture

Hi Jerome, no problem finding a bug in your own code ;).
Regards, Kirill.