[vtkusers] vtk embedded in gtk can cause FC7 to hang indefinately

Joe Miller lpe540 at yahoo.com
Fri Jul 25 15:36:04 EDT 2008


Hi,

I've run into a problem where simply creating a vtk window embedded in a gtk window cause my Fedora Core 7 machine to hang indefinately. I've created a simple program where all it does is create a gtk window, attaches the vtk X window to the gtk window and renders a blank renderer. After running the program a couple of time (usually twice but sometime 4 or 5), the system will create a gtk window but no vtk window, and the x-server gets into some sort of deadlock. The issue seems to only occur when direct rendering is off (either through LIBGL_ALWAYS_INDIRECT  or by remote logging into another machine). Individually vtk or gtk applications run fine on the system, it's a matter of combining the two that causes the error. I've tried this on a number other systems with out any issue. In the systems message log the following error occurs multiple times

   [drm: radeon_cp_idle] *ERROR* radeon_cp_idle called without lock held

I was wondering if anyone has come across this error. Or if there's an obvious error in my code. I've included the application below since it's relatively small. A quick google search shows other people who have similar issues with this error code, but none quite seem to match mine. At least as far as I can tell.

I've tried this with
  VTK: 5.0.2 and the nightly build from 7/24/08
  GTK: 2.6.10
  XORG: 1.3 (server 1.3.0.0-17)

I appreciate any thoughts and feedback.

Thanks

-joe



#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include <iostream>
#include <GL/gl.h>

#include "gtk/gtk.h"
#include <gtk/gtkgl.h>
#include <gdk/gdkglconfig.h>
#include <gdk/gdkx.h>


using namespace std;

// render the contents of the renderer after the window has been exposed
void ExposeCallback (GtkWidget *widget, GdkEvent *event, gpointer data)
{
   if (event->type != GDK_EXPOSE)
      return;

   vtkRenderWindow *renWin = static_cast<vtkRenderWindow *>(data);

   GdkEventExpose* e = (GdkEventExpose*)event;
   gdk_window_begin_paint_region(widget->window, e->region);

   renWin->Render ();

   gdk_window_end_paint(widget->window);

   if ((glGetString(GL_VENDOR) != NULL) &&  (glGetString(GL_VERSION) != NULL))
      cerr << "VERSION: " << glGetString(GL_VENDOR) << " " << glGetString(GL_VERSION) << endl;
   else
      cerr << "NO VERSION\n";


}

int main ()
{
   int argc = 1;
   char *a0  =  (char*)"Test Program";
   char *a1  =  (char*)"\0";
   char **argv;
   argv = (char**)malloc(2*sizeof(char*));
   argv[0] = a0;
   argv[1] = a1;

   GtkWidget* window = NULL;
   GtkWidget* drawing_area = NULL;
   GdkGLConfig* glconfig = NULL;

   // create vtk window and renderer
   vtkRenderWindow *renWin = vtkRenderWindow::New ();
   vtkRenderer *ren = vtkRenderer::New ();

   // add renderer
   renWin->AddRenderer(ren);

   gtk_init_check(&argc, &argv);
   gtk_gl_init (&argc, &argv);


   // Initialize GTK
   glconfig = gdk_gl_config_new_by_mode (GdkGLConfigMode(GDK_GL_MODE_RGB |
                                         GDK_GL_MODE_DEPTH |
                                         GDK_GL_MODE_DOUBLE));

   if (glconfig == NULL)
   {
      glconfig = gdk_gl_config_new_by_mode (GdkGLConfigMode(GDK_GL_MODE_RGB |
                                          GDK_GL_MODE_DEPTH));
      if (glconfig == NULL)  exit(1);
   }

   // create a gtk window and drawing area
   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   drawing_area = gtk_drawing_area_new();

   gtk_widget_set_gl_capability(drawing_area, glconfig, NULL, TRUE,
                                   GDK_GL_RGBA_TYPE);

   gtk_container_add (GTK_CONTAINER (window), drawing_area);
   gtk_widget_realize (drawing_area);

   // set the vtk window to display in the gtk window
   renWin->SetWindowId((void*)GDK_WINDOW_XWINDOW(drawing_area->window));

   gtk_widget_show (drawing_area);
   gtk_widget_show(window);

   g_signal_connect (G_OBJECT (drawing_area), "expose_event",
                        G_CALLBACK(ExposeCallback), static_cast<void*> (renWin));

   gtk_main();

}


      



More information about the vtkusers mailing list