From f2cfb6119a3663715ed2d572643949b3bef58662 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 7 Sep 2012 08:13:06 +0200 Subject: Cleanup shutdown mechanism ; Fix X11/ATI SIGV at shutdown ; EGLDisplayUtil: Check for leaked display handles GLProfile / all shutdown methods: Remove ShutdownType to remove complexity (not required) Proper shutdown sequence: GLProfile - GLDrawableFactory+ - GLContext - NativeWindowFactory - [X11Util, OSXUtil, ..] GLDrawableFactory: Always keep shutdown-hook alive, required for X11Util shutdown (@ JVMShutdown only) X11Util: Shutdown - @ JVMShutdown only - If GL vendor ATI: close pending X11 display connections in proper order of creation. This finally removes the SIGV when shutting down the JVM on X11 w/ ATI driver. EGLDisplayUtil: Add shutdown, allowing to validate whether leaked EGL display handles remain. --- .../junit/jogl/acore/TestShutdownCompleteAWT.java | 4 +- .../junit/jogl/acore/TestShutdownCompleteNEWT.java | 14 ++- .../junit/jogl/acore/TestShutdownSharedAWT.java | 124 -------------------- .../junit/jogl/acore/TestShutdownSharedNEWT.java | 127 --------------------- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 13 +-- .../jogl/demos/es2/newt/TestRedSquareES2NEWT.java | 13 +-- .../test/junit/newt/TestScreenMode01NEWT.java | 2 +- 7 files changed, 20 insertions(+), 277 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedNEWT.java (limited to 'src/test/com/jogamp/opengl') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java index 9f2820a37..976885de4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java @@ -93,12 +93,12 @@ public class TestShutdownCompleteAWT extends UITestCase { long t1 = System.nanoTime(); runTestGL(); long t2 = System.nanoTime(); - GLProfile.shutdown(GLProfile.ShutdownType.COMPLETE); + GLProfile.shutdown(); long t3 = System.nanoTime(); System.err.println("Total: "+ (t3-t0)/1e6 +"ms"); System.err.println(" GLProfile.initSingleton(): "+ (t1-t0)/1e6 +"ms"); System.err.println(" Demo Code: "+ (t2-t1)/1e6 +"ms"); - System.err.println(" GLProfile.shutdown(COMPLETE): "+ (t3-t2)/1e6 +"ms"); + System.err.println(" GLProfile.shutdown(): "+ (t3-t2)/1e6 +"ms"); } @Test diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java index b21ad5b5b..f376cd6d4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java @@ -48,8 +48,12 @@ public class TestShutdownCompleteNEWT extends UITestCase { static long duration = 300; // ms - protected void runTestGL() throws InterruptedException { - GLWindow glWindow = GLWindow.create(new GLCapabilities(GLProfile.getGL2ES2())); + protected void runTestGL(boolean onscreen) throws InterruptedException { + GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); + caps.setOnscreen(onscreen); + caps.setPBuffer(!onscreen); + + GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Gears NEWT Test"); @@ -82,19 +86,19 @@ public class TestShutdownCompleteNEWT extends UITestCase { GLProfile.initSingleton(); long t1 = System.nanoTime(); if(!initOnly) { - runTestGL(); + runTestGL(true); } long t2 = System.nanoTime(); if(glInfo) { System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, false).toString()); } long t3 = System.nanoTime(); - GLProfile.shutdown(GLProfile.ShutdownType.COMPLETE); + GLProfile.shutdown(); long t4 = System.nanoTime(); System.err.println("Total: "+ (t3-t0)/1e6 +"ms"); System.err.println(" GLProfile.initSingleton(): "+ (t1-t0)/1e6 +"ms"); System.err.println(" Demo Code: "+ (t2-t1)/1e6 +"ms"); - System.err.println(" GLProfile.shutdown(COMPLETE): "+ (t4-t3)/1e6 +"ms"); + System.err.println(" GLProfile.shutdown(): "+ (t4-t3)/1e6 +"ms"); } @Test diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedAWT.java deleted file mode 100644 index 3274ea820..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedAWT.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import java.awt.Frame; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; -import javax.media.opengl.awt.GLCanvas; - -import org.junit.Assert; -import org.junit.Test; - -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.Animator; - -public class TestShutdownSharedAWT extends UITestCase { - - static long duration = 300; // ms - - protected void runTestGL() throws InterruptedException, InvocationTargetException { - final Frame frame = new Frame("Gears AWT Test"); - Assert.assertNotNull(frame); - - final GLCanvas glCanvas = new GLCanvas(new GLCapabilities(GLProfile.getGL2ES2())); - Assert.assertNotNull(glCanvas); - frame.add(glCanvas); - frame.setSize(256, 256); - - glCanvas.addGLEventListener(new GearsES2(1)); - - Animator animator = new Animator(glCanvas); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(true); - }}); - animator.setUpdateFPSFrames(60, System.err); - animator.start(); - Assert.assertEquals(true, animator.isAnimating()); - Assert.assertEquals(true, glCanvas.isVisible()); - Assert.assertEquals(true, glCanvas.isDisplayable()); - - while(animator.isAnimating() && animator.getTotalFPSDuration()