Getting error wglMakeCurrent() has failed

Hello, I have a 3D application using OCC/V3d_View base on Qt 5.15...

The application run fine... but I have notice this error recently when I left my computer on with the application running all night, when I come back the next morning I got this error:

TKOpenGl.WinSystem | Type: Error | ID: 6 | Severity: High | Message:

  wglMakeCurrent() has failed. The handle is invalid.

TKOpenGl.WinSystem | Type: Error | ID: 6 | Severity: High |

  Message: wglMakeCurrent() has failed. The handle is invalid.


And then the V3d_View is all black and I can't see my model anymore.

Is this something that is known?  What can I activate to have more logging information so I can reproduce the problem and make a bug report if needed.

I use the following: Qt 5.15.12, OCC 7.7.0, Visual Studio 2019, Windows 11, NVidia RTX 3080

Here is the callstack I manage to grab:

1  OpenGl_Context::MakeCurrent           OpenGl_Context.cxx     726  0x7ffbf0fb8bd5 
2  OpenGl_Window::Activate               OpenGl_Window.cxx      755  0x7ffbf0f8e983 
3  OpenGl_Workspace::Activate            OpenGl_Workspace.cxx   158  0x7ffbf0f16061 
4  OpenGl_View::Redraw                   OpenGl_View.cxx        1641 0x7ffbf0f1dc12 
5  V3d_View::Redraw                      V3d_View.cxx           404  0x7ffbf0720df8 
6  AIS_ViewController::handleViewRedraw  AIS_ViewController.cxx 3158 0x7ffbf0903ff3 
7  prt::ViewController::handleViewRedraw prtviewcontroller.cpp  460  0x7ff660ffd901 
8  AIS_ViewController::HandleViewEvents  AIS_ViewController.cxx 3471 0x7ffbf08fd5e0 
9  AIS_ViewController::FlushViewEvents   AIS_ViewController.cxx 251  0x7ffbf08fd0dc 
10 prt::View3D::paintGL                  prtview3d.cpp          669  0x7ff660ff2260 
11 QOpenGLWidgetPrivate::invokeUserPaint qopenglwidget.cpp      895  0x7ffbda0dbf9f 
12 QOpenGLWidgetPrivate::render          qopenglwidget.cpp      916  0x7ffbda0dc062 
13 QOpenGLWidget::paintEvent             qopenglwidget.cpp      1328 0x7ffbda0da25a 

Any ideas?



gkv311 n's picture

I haven't heard about issues happening just because of long execution time. Consider checking the following scenarios:

  • Check system logs for possible graphic driver failures. OpenGL applications are not able to restore after system restarts GPU drivers.
  • Try locking / unlocking workstation with running application to see if it has any effect.
  • Try putting system into sleep / hibernation explicitly (if this is what might happened with your workstation at night).
  • Try collecting application logs with timestamps to see when first failure actually happened. Probably RAM / GPU memory statistics might be useful to detect GPU memory leaks.
  • If your system is a notebook with hybrid graphics, then try disabling auxiliary GPU to see if it solves the issue (maybe driver forced every saving mode somehow?).

If that is not the case, then maybe Qt does something wrong and tricky (recreated window for some reason? or recreated OpenGL context?). Try logging Qt events / check its documentation if QOpenGLWidget has such exceptional cases that should be treated somehow.