VTK 与真实 X 一起工作,与 Xvfb 一起崩溃 [英] VTK works with real X, crashes with Xvfb
问题描述
我正在调试一个使用 VTK 库实现无头图像处理的 3rd 方 Python 脚本.当使用常规 X 窗口会话运行时,它按预期工作,瞬间闪烁一个窗口.当针对 Xvfb(内存中的虚拟帧缓冲区)运行时,它会崩溃.脚本是这样的(省略了绒毛):
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()
崩溃消息如下:
ERROR: In /builddir/build/BUILD/VTK/Rendering/vtkXOpenGLRenderWindow.cxx, line 404
vtkXOpenGLRenderWindow (0x26942e0): Could not find a decent visual
Segmentation fault (core dumped)
Xvfb 作为服务运行;它的命令行是:
Xvfb runs as a service; its command line is:
/usr/bin/Xvfb :99 -ac -extension GLX
DISPLAY
设置为 :99
用于测试.操作系统为 RHEL 6.
DISPLAY
is set for :99
for the testing. The OS is RHEL 6.
欢迎任何评论什么是视觉"以及如何在 Xvfb 中启用.
Any comments what's a "visual" and how do I enable one in Xvfb are welcome.
运行 glxinfo
给出了类似的消息:
Running glxinfo
gives a similar message:
Error: couldn't find RGB GLX visual or fbconfig
但是 GLX 扩展名就在命令行中.Xvfb 日志没有任何错误消息.
But the GLX extension is right there in the command line. The Xvfb log doesn't have any error messages.
但是当我执行 xdpyinfo -queryExtensions
时,没有列出 GLX.
but when I do xdpyinfo -queryExtensions
, GLX is not listed.
推荐答案
我使用 Xvfb 运行 selenium 测试,但我使用模块 xvfbwrapper,它是 Xvfb 的轻量级模块
I use Xvfb to run selenium tests, but I use the module xvfbwrapper, it's a lightweight module for Xvfb
代码下方:
from xvfbwrapper import Xvfb
display = Xvfb()
display.start()
[ yourcode ]
display.stop()
这篇关于VTK 与真实 X 一起工作,与 Xvfb 一起崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!