[Issue 583] New - A disposed Graphics2D remains in Canvas3D after removal and addtion

View: New views
13 Messages — Rating Filter:   Alert me  

[Issue 583] New - A disposed Graphics2D remains in Canvas3D after removal and addtion

by paasiala :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583
                 Issue #|583
                 Summary|A disposed Graphics2D remains in Canvas3D after remova
                        |l and addtion
               Component|java3d
                 Version|1.5.1
                Platform|All
              OS/Version|All
                     URL|
                  Status|NEW
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P3
            Subcomponent|j3d-core
             Assigned to|issues@java3d
             Reported by|paasiala






------- Additional comments from paasiala@... Tue May 13 12:05:55 +0000 2008 -------
When a Canvas3D is removed and then added back to a container, the Graphics2D
object returned by getGraphics2D() is disposed. This is caused by a bug in
Canvas3D's freeContextResources method. In that method the Graphics2D referred
by graphics2D field, but the field value is not nullified. When getGraphics2D()
method is called after that, the Graphics2D returned is not usable and the
following exception is thrown:

Exception occurred during Canvas3D callback:
java.lang.IllegalStateException: Cannot use Graphics2D object after dispose() is
called
        at javax.media.j3d.J3DGraphics2DImpl.flush(J3DGraphics2DImpl.java:141)
        at com.solibri.sae.cad.java3d.Immcanvas.postRender(Immcanvas.java:166)
        at javax.media.j3d.Renderer.doWork(Renderer.java:1426)
        at javax.media.j3d.J3dThread.run(J3dThread.java:275)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 583] A disposed Graphics2D remains in Canvas3D after removal and addtion

by paasiala :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583






------- Additional comments from paasiala@... Tue May 13 12:09:08 +0000 2008 -------
The following diff fixes the issue:

cvs diff -- Canvas3D.java (in directory
D:\users\ppa\development\Java3D\src\j3d-core\src\classes\share\javax\media\j3d\)
Index: Canvas3D.java
===================================================================
RCS file: /cvs/j3d-core/src/classes/share/javax/media/j3d/Canvas3D.java,v
retrieving revision 1.45
diff -r1.45 Canvas3D.java
4857a4858
>                 graphics2D = null;


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 583] A disposed Graphics2D remains in Canvas3D after removal and addtion

by paasiala :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583






------- Additional comments from paasiala@... Tue May 13 12:42:09 +0000 2008 -------
The previous patch didn't fix everything, since the dispose method was called
from elsewhere (Finalizer). I added an isDisposed() method to J3DGraphics2DImpl
and I'm checking that in the getGraphics2D() method of Canvas3D. I'll post a
patch soon.

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 583] A disposed Graphics2D remains in Canvas3D after removal and addtion

by paasiala :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583



User paasiala changed the following:

                What    |Old value                 |New value
================================================================================
     Attachment is patch|                          |Created an attachment (id=
                        |                          |355)
Suggested fix

--------------------------------------------------------------------------------




------- Additional comments from paasiala@... Tue May 13 12:48:34 +0000 2008 -------
Created an attachment (id=355)
Suggested fix


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 583] A disposed Graphics2D remains in Canvas3D after removal and addtion

by kcr-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583






------- Additional comments from kcr@... Tue May 13 18:55:43 +0000 2008 -------
Two things. First, please attach a simple test program showing the bug.

Second, the following part of your proposed fix is not safe:

4857a4858
>                 graphics2D = null;

Since the actual disposal may be queued up for execution by another thread, and
not complete when graphics2D.dispose() returns, it isn't safe for the calling
thread to set it to null.

I think a safer fix would be to just set canvas.graphics2d to null in
doDispose(), right after setting hasBeenDiposed to true (line 930):

        canvas3d.graphics2D = null;

This one-line fix should be safe and complete. Let us know if you see a problem
with this.



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 583] A disposed Graphics2D remains in Canvas3D after removal and addtion

by kcr-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583



User kcr changed the following:

                What    |Old value                 |New value
================================================================================
             Assigned to|issues@java3d             |kcr
--------------------------------------------------------------------------------
        Target milestone|not determined            |1.5.2
--------------------------------------------------------------------------------




------- Additional comments from kcr@... Tue May 13 20:44:04 +0000 2008 -------
Set target milestone to 1.5.2

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 583] A disposed Graphics2D remains in Canvas3D after removal and addtion

by paasiala :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583






------- Additional comments from paasiala@... Thu May 15 09:03:09 +0000 2008 -------
That one line fix seems promising. I tried to create a simple test program, but
couldn't duplicate this yet. When I implemented the one line fix, it worked for
a couple of removal/additions, but then I got the following:

java.lang.NullPointerException
        at javax.media.j3d.Renderer.doWork(Renderer.java:765)
        at javax.media.j3d.J3dThread.run(J3dThread.java:275)

DefaultRenderingErrorListener.errorOccurred:
CONTEXT_CREATION_ERROR: Renderer: Error creating immediate mode Canvas3D
graphics context
graphicsDevice = Win32GraphicsDevice[screen=1]
canvas = com.solibri.sae.cad.java3d.Immcanvas[canvas0,0,0,1280x957]

That seems to come from line 765 in Renderer.class:
        canvas.graphics2D.doDispose();

I try to add an NPE check around that to see if it'd fix that problem.



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 583] A disposed Graphics2D remains in Canvas3D after removal and addtion

by paasiala :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583






------- Additional comments from paasiala@... Thu May 15 09:23:37 +0000 2008 -------
Created an attachment (id=356)
Fix according to kcr suggestion


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 583] A disposed Graphics2D remains in Canvas3D after removal and addtion

by paasiala :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583






------- Additional comments from paasiala@... Thu May 15 09:24:53 +0000 2008 -------
I added a patch that seems to work.

https://java3d.dev.java.net/nonav/issues/showattachment.cgi/356/patch-582.diff



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 583] A disposed Graphics2D remains in Canvas3D after removal and addtion

by kcr-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583



User kcr changed the following:

                What    |Old value                 |New value
================================================================================
                  Status|NEW                       |STARTED
--------------------------------------------------------------------------------




------- Additional comments from kcr@... Thu May 15 18:56:12 +0000 2008 -------
Good catch of the NPE. The root cause of this is a missing check for
hasBeenDisposed in the dispose() method, so I'll add that in addition to the
null check that you suggested. I will commit the fix today, and it will be in
tomorrow's daily build.


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 583] A disposed Graphics2D remains in Canvas3D after removal and addtion

by kcr-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583



User kcr changed the following:

                What    |Old value                 |New value
================================================================================
                  Status|STARTED                   |RESOLVED
--------------------------------------------------------------------------------
              Resolution|                          |FIXED
--------------------------------------------------------------------------------




------- Additional comments from kcr@... Mon May 19 20:23:31 +0000 2008 -------
Mark as fixed in 1.5.2-beta2

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 583] A disposed Graphics2D remains in Canvas3D after removal and addtion

by paasiala :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583



User paasiala changed the following:

                What    |Old value                 |New value
================================================================================
                  Status|RESOLVED                  |VERIFIED
--------------------------------------------------------------------------------




------- Additional comments from paasiala@... Tue May 20 08:01:01 +0000 2008 -------
Thanks.

We tested this on Windows XP 32 and Vista 64 platforms without problems.

I mark the bug verified.

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 583] A disposed Graphics2D remains in Canvas3D after removal and addtion

by kcr-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://java3d.dev.java.net/issues/show_bug.cgi?id=583






------- Additional comments from kcr@... Thu Jun 19 15:21:29 +0000 2008 -------
*** Issue 510 has been marked as a duplicate of this issue. ***

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...