question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crashes when requested OpenGL context cannot be created

See original GitHub issue

Hello!

On a system with limited OpenGL support (specifically, in an X2go session without OpenGL core and ES3 profiles), PyVista (VTK?) doesn’t gracefully handle this lack of advanced technologies and crashes.

To Reproduce

On a Linux system with the following glxinfo |grep OpenGL output:

OpenGL vendor string: Mesa/X.org
OpenGL renderer string: llvmpipe (LLVM 12.0.0, 256 bits)
OpenGL version string: 3.1 Mesa 21.0.3
OpenGL shading language version string: 1.40
OpenGL context flags: (none)
OpenGL extensions:

(core and ES profiles missing), the following code snippets:

from pyvista import GPUInfo
GPUInfo()
from pyvista.utilities import check_depth_peeling
check_depth_peeling()

both result in:

2022-02-07 14:49:00.635 (  15.831s) [        E0112740]vtkXOpenGLRenderWindow.:266    ERR| vtkXOpenGLRenderWindow (0x55935b917270): Could not find a decent config

ERROR:root:Could not find a decent config
2022-02-07 14:49:00.636 (  15.832s) [        E0112740]vtkXOpenGLRenderWindow.:484    ERR| vtkXOpenGLRenderWindow (0x55935b917270): Could not find a decent visual

ERROR:root:Could not find a decent visual
[1]    2925781 abort (core dumped)

According to the docs, depth peeling requires ES3, which isn’t supported on this system.

I can reproduce this crash on the VTK level alone:

import vtk
w = vtk.vtkRenderWindow()
w.Render()

Expected behavior would be for things not to crash.


System Information:

# Get system info
import pyvista as pv
print(pv.Report())

Unfortunately, running this code leads to the same crash as reported above.

I’m using pyvista 0.7 with vtk 9.1.0 from conda-forge (their qt build variant; see recipe)

I verified that the installation itself is working in principle by running the above commands via X11 forwarding through SSH (ssh -X), and everything works as expected.

It should also be noted that rather complex 3D visualizations can be produced (tested with MNE-Python’s Coregistration UI, which generates an interactive skull surface with numerous overlays) as long as I don’t try to enable depth peeling (probably requesting other “advanced” features would produce the same issues; I’m just reporting here what I experienced so far 😃)

Any advice would be greatly appreciated!

Thanks, Richard

cc @GuillaumeFavelier @larsoner @agramfort

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:20 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
hoechenbergercommented, Feb 10, 2022

@GuillaumeFavelier Unfortunately, this produces the same error as soon as Render is called (using conda-forge’s qt build of VTK (i.e., no OSMesa support)

1reaction
GuillaumeFaveliercommented, Feb 9, 2022

What I found in vtkOpenGLRenderWindow.cxx in the function ReportCapabilities() is strangely similar to the gist 😄

const char* vtkOpenGLRenderWindow::ReportCapabilities()
{
  this->MakeCurrent();

  const char* glVendor = (const char*)glGetString(GL_VENDOR);
  const char* glRenderer = (const char*)glGetString(GL_RENDERER);
  const char* glVersion = (const char*)glGetString(GL_VERSION);

  std::ostringstream strm;
  if (glVendor)
  {
    strm << "OpenGL vendor string:  " << glVendor << endl;
  }
  if (glRenderer)
  {
    strm << "OpenGL renderer string:  " << glRenderer << endl;
  }
  if (glVersion)
  {
    strm << "OpenGL version string:  " << glVersion << endl;
  }

  strm << "OpenGL extensions:  " << endl;
  GLint n, i;
  glGetIntegerv(GL_NUM_EXTENSIONS, &n);
  for (i = 0; i < n; i++)
  {
    const char* ext = (const char*)glGetStringi(GL_EXTENSIONS, i);
    strm << "  " << ext << endl;
  }

  delete[] this->Capabilities;

https://github.com/Kitware/VTK/blob/master/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx#L261-L293

So I made another gist:

import vtk as _vtk

renderWindow = _vtk.vtkRenderWindow()
renderWindow.SetOffScreenRendering(True)
renderWindow.Render()

extension_name = "_ES3"

if renderWindow.SupportsOpenGL():
    caps = renderWindow.ReportCapabilities()
    caps = caps.split('\n')
else:
    caps = ""

ext_supported = [ext for ext in caps if extension_name in ext]
print(ext_supported)

https://gist.github.com/GuillaumeFavelier/02d7a51ef6aba3cae449bd33777d2c1d

This is what I have on my system:

['  GL_ARB_ES3_compatibility', '  GL_ARB_ES3_1_compatibility', '  GL_ARB_ES3_2_compatibility', '  GL_NV_ES3_1_compatibility']

Feel free to try it @hoechenberger

Read more comments on GitHub >

github_iconTop Results From Across the Web

Client crashes (Unable to create an Open GL context)
The error "Unable to create an Open GL context" appears when your graphics card or driver can't handle required OpenGL properly.
Read more >
Failed to create OpenGL context for format QSurfaceFormat ...
Attempting to launch ArcGIS Survey123 Connect fails, returning the following error message: Error: Failed to create OpenGL for format ...
Read more >
[HELP] Minecraft crash because OpenGL error
This issue may arise se due to compatibility issues. I suggest you to run the game in compatible mode and check if it...
Read more >
Failed to create OpenGL context on some Linux systems with ...
The moment I click Play it crashes. I haven't had this issue before today on this system or this OS, my guess is...
Read more >
Creating an OpenGL 4.3 Context Crashes GLX - Stack Overflow
This is a bit late, but I struggled with this problem recently (Still crashes when trying to create a opengl context thats not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found