ScreenSpaceLines3D.OnRender bug?

Topics: Developer Forum, User Forum
Aug 16, 2007 at 1:46 PM
I have a EntityVisual3D : ModelVisual3D which has an Entity property and Update method.
When I set EntityVisual3D.Entity to my internal geometry entity representation, EntityVisual3D.Update is called and it clears Content and Children and fills Content or adds Children according to entity type (curve, surfave, solid, ...). The problem is when I use ScreenSpaceLines3D as a child in EntityVisual3D. When I add an instance of EntityVisual3D with ScreenSpaceLines3D child to Viewport3D it render well for the first time, but it fails after EntityVisual3D.Update call - ScreenSpaceLines3D.OnRender throws an exception, because it is called on old ScreenSpaceLines3D removed from WPF visual tree, so ViewportVisual3D is not found.
Who calls private ScreenSpaceLines3D.OnRender - mys stack says "external code"? Why is it called for ScreenSpaceLines3D disconnected from visual tree?

Marek
Aug 24, 2007 at 9:12 PM
The ScrenSpaceLine3D.OnRender event is called by WPF because the ScrenSpaceLine3D was attached to the rendering queue.
The issue is that you are removing the ScreenSpaceLine from the Viewport3D, but it remains attached to the rendering queue. In other words the ScrenSpaceLine3D is attached to the rendering queue but never detached. Once the rendering event is fired the ScrenSpaceLine3D attempts to compute a bunch of transformation based on the camera's projection matrix, but there is no camera because the ScrenSpaceLine3D was removed from the ViewPort.
If everythign makes sense to you so far a possibel solution for you would be to modify the ScreenSpaceLine3D to support detach from the rendering event after the object is unparented or destroyed.
BTW there are bigger problems related to the fact that the line remains in the rendering engine and uses lots of CPU cycle, and creates a memory leak.
I'm pretty sure that I have red a post where they announced that this issue was fixed (by implementing a proper distructor / dispose mechanism) but I haven't see the code for it yet.
Aug 28, 2007 at 7:17 AM
Yes, you are right.
I have added IDisposable to ScrenSpaceLine3D to disconnect OnRender when disposed.
I have uploaded it to Patches, but then I have found there is already the same patch ;-)
Jun 24, 2008 at 7:48 PM
Where can this patch be found?

rolfik wrote:
Yes, you are right.
I have added IDisposable to ScrenSpaceLine3D to disconnect OnRender when disposed.
I have uploaded it to Patches, but then I have found there is already the same patch ;-)



Jun 26, 2008 at 6:50 AM
Have a look at http://www.codeplex.com/3DTools/SourceControl/PatchList.aspx.
Jun 26, 2008 at 4:34 PM

Thanks for the info.  I have tried both patches and still get a memory leak when using ScreenSpaceLines3D.

 

 

 


Oct 5, 2011 at 2:40 PM
kbeal2k wrote:

Thanks for the info.  I have tried both patches and still get a memory leak when using ScreenSpaceLines3D.

 

 

 

 


Me too. Reading this post looks like we have to explicit call the Dispose - I just still do not know where we should call this Dispose.