Gaëtan
Gaëtan

Reputation: 863

Weird error when closing a JavaFX window running OpenGL content

I have a JavaFX application which contains a SwingNode with an OpenGL app in it. Most of the time, everything is fine, but sometimes when I close the window I get this error:

Catched Exception on thread AWT-EventQueue-0
javax.media.nativewindow.NativeWindowException: DC not released: GDISurface[ displayHandle 0x0
, surfaceHandle 0xffffffffe201277c
, size 2560x1361
, UOB[ OWNS_SURFACE | OWNS_DEVICE | WINDOW_INVISIBLE ]
, WindowsWGLGraphicsConfiguration[DefaultGraphicsScreen[WindowsGraphicsDevice[type .windows, connection decon, unitID 0, handle 0x0, owner false, NullToolkitLock[]], idx 0], pfdID 7, ARB-Choosen true,
    requested GLCaps[rgba 8/8/8/8, opaque, accum-rgba 0/0/0/0, dp/st/ms 24/0/0, one, mono  , hw, GLProfile[GL4bc/GL4bc.hw], on-scr[.]],
    chosen    GLCaps[wgl vid 7 arb: rgba 8/8/8/8, opaque, accum-rgba 0/0/0/0, dp/st/ms 24/0/0, one, mono  , hw, GLProfile[GL4bc/GL4bc.hw], offscr[fbo]]]
, surfaceLock <4a7b3290, 6de653ec>[count 1, qsz 0, owner <AWT-EventQueue-0>]
, GDIDummyUpstreamSurfaceHook[ 2560x1361]
, upstreamSurface false ], isWindow false, werr 0, thread: AWT-EventQueue-0
    at jogamp.nativewindow.windows.GDISurface.unlockSurfaceImpl(GDISurface.java:121)
    at jogamp.nativewindow.ProxySurfaceImpl.unlockSurface(ProxySurfaceImpl.java:226)
    at jogamp.opengl.GLDrawableImpl.unlockSurface(GLDrawableImpl.java:334)
    at jogamp.opengl.GLContextImpl.release(GLContextImpl.java:354)
    at jogamp.opengl.GLContextImpl.release(GLContextImpl.java:316)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1132)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:994)
    at javax.media.opengl.awt.GLJPanel$OffscreenBackend.doPaintComponent(GLJPanel.java:1731)
    at javax.media.opengl.awt.GLJPanel.paintComponent(GLJPanel.java:538)
    at javax.swing.JComponent.paint(JComponent.java:1056)
    at javax.swing.JComponent.paintChildren(JComponent.java:889)
    at javax.swing.JComponent.paint(JComponent.java:1065)
    at sun.swing.JLightweightFrame$3.paint(JLightweightFrame.java:309)
    at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210)
    at javax.swing.RepaintManager.paint(RepaintManager.java:1275)
    at javax.swing.JComponent._paintImmediately(JComponent.java:5158)
    at javax.swing.JComponent.paintImmediately(JComponent.java:4969)
    at javax.swing.JComponent.paintImmediately(JComponent.java:4950)
    at javax.swing.RepaintManager$4.run(RepaintManager.java:831)
    at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
    at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
    at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
    at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

I searched what it could be about, but I can't find anything. Does anybody have an idea of why this happens ? Here is the code I use to close the app:

// Close operation
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
    @Override
    public void handle(WindowEvent t) {
        Platform.exit();
        System.exit(0);
    }
});

Upvotes: 0

Views: 186

Answers (1)

Volzy
Volzy

Reputation: 64

i am not sure but you are doing Platform.exit() that force Application.lauch() to return so you should put System.exit() in the main() function, because JavaFX runtime close when you do Platform.exit() and stop() method is called but in the same time System.exit() is called

Upvotes: 1

Related Questions