JOGL crashes sometimes!

Hi, I have a big problem. I have programmed a complete little Framework which uses JOGL. It supports Fullscreen and
free 3D-Look Mouse (also Window Mode). It is very stable and JOGL does its part perfect. But sometimes…maybe each
30-40 runs , my Framework crashes when I terminate the programm. I get 2 different exceptions and sometimes
this “An unexpected error has been detected by Java Runtime Environment”.

Now I have no Idea what I have done wrong :frowning: Its import to eliminate this error cause this framework should replace glut and C
on my University.

This is my exception…I have no idea what it is:

Number one…sometimes on high Resolutions

Exception in thread “AWT-EventQueue-0” javax.media.opengl.GLException: Error mak
ing context current: 0
at com.sun.opengl.impl.windows.WindowsGLContext.makeCurrentImpl(WindowsG
LContext.java:169)
at com.sun.opengl.impl.windows.WindowsOnscreenGLContext.makeCurrentImpl(
WindowsOnscreenGLContext.java:66)
at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:134)

    at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1
  1. at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.
    

java:265)
at javax.media.opengl.GLCanvas.display(GLCanvas.java:130)
at javax.media.opengl.GLCanvas.paint(GLCanvas.java:142)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
at sun.awt.RepaintArea.paint(RepaintArea.java:224)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:301)
at java.awt.Component.dispatchEventImpl(Component.java:4486)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)

    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

…And sometimes I get this:

An unexpected error has been detected by Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d12b2c3, pid=5708, tid=4540

Java VM: Java HotSpot™ Client VM (1.6.0-b105 mixed mode, sharing)

Problematic frame:

C [awt.dll+0x12b2c3]

An error report file with more information is saved as hs_err_pid5708.log

If you would like to submit a bug report, please visit:

http://java.sun.com/webapps/bugreport/crash.jsp

Sometimes I get an disposed Component Exception too. But I cannot reproduce it at the moment.

JOGL works great and stable…but on terminating it crashes sometimes bad :frowning:

Here is my shutdown-Code:


public void shutdown()
    {
        if (animator!=null && dev != null)
        
            new Thread(new Runnable()
            {
                public void run()
                {
                    animator.stop();
          
                    try
                    {
                        EventQueue.invokeAndWait(new Runnable()
                        {
                            public void run()
                            {
                                if (displayModeSwitched==true && curDispMode != null)
                                {
                                    try
                                    {
                                        dev.setDisplayMode(curDispMode);
                                    }
                                    catch (Exception e)
                                    {
                                        // DEBUG AUSGABE
                                        System.out.println("Reset DisplayMode Error!\n");     
                                    }
                                }

                                if (fullScreen && fullScreenSwitched)
                                {
                                    try
                                    {
                                        dev.setFullScreenWindow(null);
                                    }
                                    catch (Exception e)
                                    {
                                        // DEBUG AUSGABE 
                                        System.out.println("Reset Fullscreen Error!\n");
                                    }
                                }
                            }
                        });
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                    }
          
                    System.exit(0);
                }
            }).start();
    }

Your termination logic seems OK. The key points are to stop the Animator and to make sure you aren’t doing any OpenGL rendering at the time the process is terminated. You may want to try hiding the window in the Runnable you run on the Event Dispatch Thread after switching out of full screen mode and before calling System.exit().

Thank u very much. It seems that it works. In the last 20-30 Times I terminated the programm, it has been terminated correctly.
I hope this was the solution for this problem :slight_smile: