[vtkusers] VTK+JAVA Crash in mouse events
Shyam Prakash
ramakrishna.prakash at quest-global.com
Wed Nov 19 08:39:25 EST 2003
Jeff,
I tried the modified code that you sent me. After much effort,
the code crashed with following dump.
Function=vtkMergePoints::InsertUniquePoint+0xDC
Library=d:\VTKBinary\vtkFiltering.dll
Source file = D:\VTK-4.2.2\Filtering\vtkMergePoints.cxx : 111
Current Java thread:
at vtk.vtkGenericRenderWindowInteractor.MouseMoveEvent_2(Native
Method)
at
vtk.vtkGenericRenderWindowInteractor.MouseMoveEvent(vtkGenericRenderWind
owInteractor.java:19)
at vtk.vtkCanvas.mouseDragged(vtkCanvas.java:209)
and
Function=vtkPolyDataToImageStencil::IsTypeOf+0x7A18B
Library=d:\VTKBinary\vtkHybrid.dll
Current Java thread:
at vtk.vtkGenericRenderWindowInteractor.MouseMoveEvent_2(Native
Method)
at
vtk.vtkGenericRenderWindowInteractor.MouseMoveEvent(vtkGenericRenderWind
owInteractor.java:19)
One thing I have noticed is the crash happens in the presence of the
plane widget. Without it, I could not simulate the crash(even after a
hard try). So I guess it is not only the gc() that is causing the
problem. Do we need to check for "rendering" boolean value of
vtkPanel.java before calling iren.MouseMoveEvent() or others like
Lock();
If(!rendering){
iren.MouseMoveEvent();
}
UnLock();
I did this, but no improvements.
Thanks
Shyam
-----Original Message-----
From: Jeff Lee [mailto:jeff at cdnorthamerica.com]
Sent: Wednesday, November 19, 2003 6:02 PM
To: Shyam Prakash
Subject: Re: [vtkusers] VTK+JAVA Crash in mouse events
Shyam Prakash wrote:
>Jeff,
> I guess I need to get my self out of java-centric thinking. This
>is how I understand from you. "It is best to make all the
actors/mappers
>method level variables or make sure I don't re-instantiate the class
>level actor variable until I remove it from the renderer". Can I please
>have your comments.
>
>
Just print out the reference count of your actor in your previous code,
and you'll see what's happening - it stays at 1 the whole time,
meanwhile you were creating all these new actors - where do they go?
When you assing a new value, the old one is eligible for garbage
collection. If you don't want this to happen, don't reuse ivars like
that, or clean up after yourself by removing the unrefrenced object from
whatever is using it (like the renderer and the planewidget).
-Jeff
>Thanks
>Shyam
>
>-----Original Message-----
>From: Jeff Lee [mailto:jeff at cdnorthamerica.com]
>Sent: Wednesday, November 19, 2003 5:16 PM
>To: Shyam Prakash
>Cc: vtkusers at public.kitware.com
>Subject: Re: [vtkusers] VTK+JAVA Crash in mouse events
>
>
>
>Shyam Prakash wrote:
>
>
>
>>Jeff,
>> The program that I sent you was just to demonstrate my problem.
>>Your idea of actors getting gc'ed while they are still in renderer
>>
>>
>could
>
>
>>be a possibility. But then I can not convince my self how this could
>>happen as the actor still has a reference to the renderer. Do you have
>>any idea?
>>
>>
>>
>>
>The way you coded it, as I recall, was to assign an ivar called actor =
>new vtkActor() and then added it to the renderer. The next time you do
>this, the previous actor has no more references (even though the
>Renderer in c++ added a consumer, this is not the same as adding a
>reference). Since you added the old one, but did not remove it, the
>object was finalized while still in the renderer, causing the errors.
>In short, the actor doesn't have a reference to the renderer, only a
>list of consumers.
>-Jeff
>
>
>
>>Thanks
>>Shyam
>>
>>-----Original Message-----
>>From: vtkusers-admin at vtk.org [mailto:vtkusers-admin at vtk.org] On Behalf
>>Of Jeff Lee
>>Sent: Tuesday, November 18, 2003 8:06 PM
>>To: Shyam Prakash
>>Cc: vtkusers at public.kitware.com
>>Subject: Re: [vtkusers] VTK+JAVA Crash in mouse events
>>
>>I think the main problem was that your actors were getting gc'ed while
>>the mouse was moving. You should be careful to remove actors from the
>>renderer which might be garbage collected for any reason.
Furthermore,
>>
>>
>
>
>
>>you were creating a new plane widget every time the action was
>>
>>
>triggered
>
>
>>- was that your intent? If so, you need to remove the old one from
the
>>
>>
>
>
>
>>renderer first. In the future, if you see this type of behavior, it
is
>>
>>
>
>
>
>>almost guaranteed to be related to some object unwittingly being a
>>candidate for garbage collection, and the object gets deleted while
>>still in the renderer. I attached a better-behaving version of your
>>code, but it may not be what you intended.
>>-Jeff
>>
>>Shyam Prakash wrote:
>>
>>
>>
>>
>>
>>>Hello,
>>>
>>> I had encountered this problem earlier too. The program
>>>suddenly crashes in mouseMove, mouseDrag,mousePress or mouseRelease
>>>events with a message similar to the message given below.
>>>
>>>
>>>
>>>Current Java thread:
>>>
>>> at vtk.vtkGenericRenderWindowInteractor.MouseMoveEvent_2(Native
>>>Method)
>>>
>>> at
>>>
>>>
>>>
>>>
>>>
>>vtk.vtkGenericRenderWindowInteractor.MouseMoveEvent(vtkGenericRenderWi
n
>>
>>
>d
>
>
>>owInteractor.java:19)
>>
>>
>>
>>
>>> at vtk.vtkCanvas.mouseDragged(vtkCanvas.java:209)
>>>
>>> at
>>>
>>>
>>>
>>>
>>java.awt.Component.processMouseMotionEvent(Component.java:5182)
>>
>>
>>
>>
>>> at java.awt.Component.processEvent(Component.java:4935)
>>>
>>>
>>>
>>>I am not sure what exactly could be the problem. I am using vtk 4.2.2
>>>on Windows2k with jdk 1.4.1_02. Attached is a sample code. When I run
>>>this code, it often crashes in my machine when I rotate the model
>>>vigorously(in combination with resizing the window). My gut feeling
is
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>>it could be because of the presence of vtkImplicitPlaneWidget. Is
>>>there anyway I can avoid this?
>>>
>>>
>>>
>>>Thanks
>>>
>>>Shyam
>>>
>>>
>>>
>>>
>>>
>>_______________________________________________
>>This is the private VTK discussion list.
>>Please keep messages on-topic. Check the FAQ at:
>>
>>
><http://public.kitware.com/cgi-bin/vtkfaq>
>
>
>>Follow this link to subscribe/unsubscribe:
>>http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>>
>>
>>
>>
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>
More information about the vtkusers
mailing list