VTK works with real X, crashes with Xvfb

♀尐吖头ヾ 提交于 2020-01-24 10:11:31

问题


I'm debugging a 3rd party Python script that implements headless image processing with the VTK library. When run with a regular X window session, it works as expected, flashing a window for a split second. When run against Xvfb (virtual framebuffer in memory), it crashes. The script goes like this (fluff omitted):

inname = args[0]
outname = args[1]

from vtk import *

reader = vtkPLYReader()
reader.SetFileName(inname)

gf = vtkGraphicsFactory
gf.SetOffScreenOnlyMode(1)
gf.SetUseMesaClasses(1)
if_ = vtkImagingFactory
if_.SetUseMesaClasses(1)

mapper = vtkPolyDataMapper()
mapper.SetInputConnection(reader.GetOutputPort())
actor = vtkActor()
actor.SetMapper(mapper)

renderer = vtkRenderer()
renderWindow = vtkRenderWindow()
renderWindow.SetSize(xsize, ysize)
renderWindow.SetOffScreenRendering(1)
renderWindow.AddRenderer(renderer)
renderer.AddActor(actor)
renderer.SetBackground(1, 1, 1)
renderWindow.Render()          #<------------ This line crashes

wif = vtkWindowToImageFilter()
wif.SetInput(renderWindow)
wif.Update()

writer = vtkPNGWriter()
writer.SetFileName(outname)
writer.SetInput(wif.GetOutput())
writer.Write()

The crash message goes:

ERROR: In /builddir/build/BUILD/VTK/Rendering/vtkXOpenGLRenderWindow.cxx, line 404
vtkXOpenGLRenderWindow (0x26942e0): Could not find a decent visual

Segmentation fault (core dumped)

Xvfb runs as a service; its command line is:

 /usr/bin/Xvfb :99 -ac -extension GLX

DISPLAY is set for :99 for the testing. The OS is RHEL 6.

Any comments what's a "visual" and how do I enable one in Xvfb are welcome.

EDIT: Running glxinfo gives a similar message:

Error: couldn't find RGB GLX visual or fbconfig

But the GLX extension is right there in the command line. The Xvfb log doesn't have any error messages.

EDIT2: but when I do xdpyinfo -queryExtensions, GLX is not listed.


回答1:


I use Xvfb to run selenium tests, but I use the module xvfbwrapper, it's a lightweight module for Xvfb

Below the code:

from xvfbwrapper import Xvfb
display = Xvfb()
display.start()
[ yourcode ]
display.stop()


来源:https://stackoverflow.com/questions/21141212/vtk-works-with-real-x-crashes-with-xvfb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!