[vtkusers] Java Problem in cleaning of a rendering window

Laurent Peters Laurent.Peters at telemis.com
Fri May 19 08:52:19 EDT 2006


My java application crashes when the GC finalizes a rendering window.
The problem can be reproduced with the Java examples of 
http://ij-plugins.sourceforge.net/vtk-examples/index.html
 
The examples must be modified in order to remove all references to the
rendering window and its component.
Ohterwise the GC would not free them. I modified vtkCanvas and added the
following lines:

    public void removeNotify() {
        super.removeNotify();
        ren=null;
        cam = null;
        lgt = null;
        rw=null;
        iren=null;
    }
 
I added a System.out.println in the finalize of the vtkObjectBase, to be
able to trace easily the finalized objects.
 
When the GC finalizes the vtkGenericRenderWindowInteractor or the
vtkRenderWindow,
the java program exits with the following error:
 
Finalize:vtk.vtkRenderWindow
Finalize:vtk.vtkGenericRenderWindowInteractor
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=4844,
tid=4488
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2_11-b06 mixed mode)
# Problematic frame:
# C  0x00000000
#
# An error report file with more information is saved as hs_err_pid4844.log
#
# If you would like to submit a bug report, please visit:
#    <http://java.sun.com/webapps/bugreport/crash.jsp>
http://java.sun.com/webapps/bugreport/crash.jsp
#
 
In the vtk logs, the following error is reported:
 
ERROR: In \working\tools\Vtk5.0\Rendering\vtkWin32OpenGLRenderWindow.cxx,
line 238
vtkWin32OpenGLRenderWindow (08E6C540): wglMakeCurrent failed in
MakeCurrent(), error: The handle is invalid.
 
When I trace the C Code, I find that the program exits in the call to
glDisable((GLenum)cur_light),
in the following function:
 
void vtkWin32OpenGLRenderWindow::Clean()
{
  vtkRenderer *ren;
  GLuint id;
  
  /* finish OpenGL rendering */
  if (this->ContextId) 
    {
    this->MakeCurrent();
 
    /* first delete all the old lights */
    for (short cur_light = GL_LIGHT0; cur_light < GL_LIGHT0+VTK_MAX_LIGHTS;
cur_light++)
      {
      glDisable((GLenum)cur_light);
      }
    
...
 
I tried to remove all props from the rendering window before its
finalisation, but it does not help.
 
Can anybody help me? With a patch, a workaround or some advice.
 
Thanks in adavance!
 
Laurent 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060519/950daeb4/attachment.htm>


More information about the vtkusers mailing list