[vtkusers] Multithreaded VTK application got X Errors

Benjamin Sobotta mayday at gmx.net
Mon Jul 14 10:50:15 EDT 2008


On Thursday 10 July 2008 20:41:20 Mo, Huaicai wrote:
> Hello,
>
> I have a Qt based VTK application on Linux. The main part of the
> application is just a loop in which it repeatedly receives new data, uses
> the new input data to create new geometry, and then update the graphics
> display. This all works fine, except the part that creates geometry by
> using the input data is kind of slow. Therefore, the response of user
> interaction with this GUI application and also the updating rate of the
> geometry display are too slow to be acceptable.
>
> In order to improve the performance, I tried to put the geometry generation
> into a separate QThread. The thread waits for new input data to come in,
> and then compute the geometry, finally emit a signal to notify the main
> thread that the new geometry is ready. The main thread will use the new
> geometry to update the graphics display. By the way, the new geometry is
> represented by "QVector<vtkProp3D*>". The application runs several times of
> the loop with the right graphics display, and then gets frozen. I'm
> attaching the error messages that I got at the bottom of this email.
>
> I'm using Qt4.4, Open sourced version on RedHat 5.2 Enterprise, VTK is
> 5.04. My graphics card is nVidia Quadro 1500. I'm not sure what do these
> errors mean. Is there any one have any clue about this problem? I
> appreciate your time.
>
> Thank you,
> Hank
>
> ---------------------------------------------------------------------------
>---------------------------------
>
> X Error: BadAccess (attempt to access private resource denied) 10
>   Extension:    128 (Uknown extension)
>   Minor opcode: 5 (Unknown request)
>   Resource id:  0x360002e
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x2!
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x20!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0xc0000001
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> Xlib: sequence lost (0x10360 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0xc0000001
> Xlib: sequence lost (0x10021 > 0x164b) in reply type 0x18!
> Xlib: sequence lost (0x10016 > 0x164b) in reply type 0x18!
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 8 (X_MapWindow)
>   Resource id:  0xbfe2a2a8
> Xlib: sequence lost (0x10016 > 0x164b) in reply type 0x18!
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> Xlib: sequence lost (0x1081f > 0x164b) in reply type 0x9c!
> Xlib: sequence lost (0x10021 > 0x164b) in reply type 0x18!
> Xlib: sequence lost (0x10016 > 0x164b) in reply type 0x18!
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> Xlib: sequence lost (0x10360 > 0x164b) in reply type 0x7!
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0
> Xlib: sequence lost (0x1081f > 0x164b) in reply type 0x9c!
> Xlib: sequence lost (0x10021 > 0x164b) in reply type 0x91!
> Xlib: sequence lost (0x10000 > 0x164b) in reply type 0x0!
> X Error: 0 0
>   Major opcode: 0 ()
>   Resource id:  0x0

Hi!

I'm not quite sure, but I believe the problem comes from two threads that 
simultaneously try to draw in the GUI. This can work out alright but doesnt 
necessarily have to, hence after some time the problem is more likely to 
occur.

I solved this problem by synchronizing the computing thread with the GUI 
drawing thread (main event loop).
Just sending a signal to the main thread will no yield the desired result, 
because the slots connected to a signal are executed by the same thread the 
emits the signal. At least that's what I found after some investigation. So 
actually you are _not_ telling the main thread to redraw but merely use the 
calculating thread. So I explicitly synchronized both threads using 
primitives from Qt.

HTH,

Benjamin



More information about the vtkusers mailing list