Shutting down Java3D

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Shutting down Java3D

runiter
Is there a proper way to shut down Java3D before calling System.exit()?

When I call System.exit() I get the following exception so it makes me think perhaps I need to shutdown Java3D before calling System.exit():

com.jogamp.opengl.GLException: Error making context 0x40000 current on Thread J3D-Renderer-1, drawableWrite 0x2f011187, drawableRead 0x2f011187, werr: 0, WindowsWGLContext [Version 4.6 (Compat profile, arb, compat[ES2, ES3, ES31, ES32], FBO, hardware) - 4.6.0 NVIDIA 432.00 [GL 4.6.0, vendor 432.0.0 (NVIDIA 432.00)], options 0x7c03, this 0x6a3a1c, handle 0x40000, isShared false, jogamp.opengl.gl4.GL4bcImpl@146cb8a,
         quirks: [NoDoubleBufferedBitmap, NoSurfacelessCtx],
        Drawable: ResizeableImpl[Initialized true, realized true, texUnit 0, samples 8,
        Factory   jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory@1315fe,
        Handle    0x2f011187,
        Caps      GLCaps[wgl vid 9 arb: rgba 8/8/8/8, opaque, accum-rgba 16/16/16/16, dp/st/ms 24/0/8, sample-ext default, dbl, mono  , hw, GLProfile[GL4bc/GL4bc.hw], offscr[fbo]],
        fboI back 0, front 0, num 1,
        FBO front read 2, FBO[name r/w 2/2, init true, bound true, size 894x862, samples 0/32, modified false/false, depth RenderAttachment[type DEPTH, format 0x81a6, samples 0, 894x862, name 0x3, obj 0x1c1bf4], stencil null, colorbuffer attachments: 1/8, with 1 textures: [TextureAttachment[type COLOR_TEXTURE, target GL_TEXTURE_2D, level 0, format 0x8058, 894x862, border 0, dataFormat 0x80e1, dataType 0x8367; min/mag 0x2600/0x2600, wrap S/T 0x812f/0x812f; name 0x1, obj 0x1eaac1], null, null, null, null, null, null, null], msaa[null, hasSink false, dirty true], state OK, obj 0x1b7e760],
        FBO back  write 1, FBO[name r/w 1/2, init true, bound true, size 894x862, samples 8/32, modified false/false, depth RenderAttachment[type DEPTH, format 0x81a6, samples 8, 894x862, name 0x2, obj 0x11592af], stencil null, colorbuffer attachments: 1/8, with 0 textures: [ColorAttachment[type COLOR, format 0x8058, samples 8, 894x862, name 0x1, obj 0x586647], null, null, null, null, null, null, null], msaa[TextureAttachment[type COLOR_TEXTURE, target GL_TEXTURE_2D, level 0, format 0x8058, 894x862, border 0, dataFormat 0x80e1, dataType 0x8367; min/mag 0x2600/0x2600, wrap S/T 0x812f/0x812f; name 0x1, obj 0x1eaac1], hasSink true, dirty true], state OK, obj 0x1f2f4c2],
        Surface   GDISurface[ displayHandle 0x0
, surfaceHandle 0x2f011187
, size 894x862
, UOB[ OWNS_SURFACE | OWNS_DEVICE | WINDOW_INVISIBLE ]
, WindowsWGLGraphicsConfiguration[DefaultGraphicsScreen[WindowsGraphicsDevice[type .windows, connection decon, unitID 0, handle 0x0, owner false, NullToolkitLock[obj 0xa5ad8b]], idx 0], pfdID 9, ARB-Choosen true,
        requested GLCaps[rgba 8/8/8/8, opaque, accum-rgba 16/16/16/16, dp/st/ms 24/0/8, sample-ext default, dbl, mono  , hw, GLProfile[GL4bc/GL4bc.hw], offscr[fbo]],
        chosen    GLCaps[wgl vid 9 arb: rgba 8/8/8/8, opaque, accum-rgba 16/16/16/16, dp/st/ms 24/0/8, sample-ext default, dbl, mono  , hw, GLProfile[GL4bc/GL4bc.hw], offscr[fbo]]]
, surfaceLock <5b9ba3, 107e6b8>[count 2, qsz 0, owner <J3D-Renderer-1>]
, GDIDummyUpstreamSurfaceHook[pixel 894x862]
, upstreamSurface false ]]]
        at jogamp.opengl.windows.wgl.WindowsWGLContext.makeCurrentImpl(WindowsWGLContext.java:442)
        at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:840)
        at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:648)
        at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:586)
        at org.jogamp.java3d.JoglPipeline.useCtx(JoglPipeline.java:7264)
        at org.jogamp.java3d.Canvas3D.useCtx(Canvas3D.java:4861)
        at org.jogamp.java3d.Canvas3D.makeCtxCurrent(Canvas3D.java:2423)
        at org.jogamp.java3d.Canvas3D.makeCtxCurrent(Canvas3D.java:2406)
        at org.jogamp.java3d.Renderer.doWork(Renderer.java:997)
        at org.jogamp.java3d.J3dThread.run(J3dThread.java:271)
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Shutting down Java3D

philjord

During a regular life cycle the Java3D system is cleanly tidied up at the end of it's life by the AWT system calling the
Canvas3D.removeNotify();

This is an overridden method of Canvas which shuts down the 3d renderer system nicely.

removeNotify() is a blocking call so if you are shutting down in a hard manner where the length of time you have to clean up may be short and you need a non-blocking call that will tidy up somewhat, then you can call
Canvas3D.stopRenderer();

which will tell the 3d Renderer thread to shut down but won't block the calling thread.

Note there is also
SimpleUniverse.cleanup();
Which will release some memory, but is not useful during a forced shutdown.

I hope this helps.
Phil.
Reply | Threaded
Open this post in threaded view
|

Re: Shutting down Java3D

runiter
Beautiful, "Canvas3D.removeNotify()" did the trick. Thank you.
I'm calling it from Javafx thread instead of AWT thread. But it seem to work fine regardless.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D