summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-09-07 08:13:06 +0200
committerSven Gothel <[email protected]>2012-09-07 08:13:06 +0200
commitf2cfb6119a3663715ed2d572643949b3bef58662 (patch)
tree7a31217a343c16e81549fab8beed1a1012e13156 /src/jogl/classes/javax/media/opengl
parentffcfd35929407c75308ab41883463bc8c8a89b91 (diff)
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.
Diffstat (limited to 'src/jogl/classes/javax/media/opengl')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java36
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java29
2 files changed, 19 insertions, 46 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index acda45bff..9fd895c1f 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -55,7 +55,6 @@ import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.ProxySurface;
import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook;
-import javax.media.opengl.GLProfile.ShutdownType;
import jogamp.opengl.Debug;
@@ -106,6 +105,7 @@ public abstract class GLDrawableFactory {
// Shutdown hook mechanism for the factory
private static boolean factoryShutdownHookRegistered = false;
private static Thread factoryShutdownHook = null;
+ private static volatile boolean isJVMShuttingDown = false;
/**
* Instantiate singleton factories if available, EGLES1, EGLES2 and the OS native ones.
@@ -176,21 +176,24 @@ public abstract class GLDrawableFactory {
}
}
- protected static void shutdown(ShutdownType shutdownType) {
+ protected static void shutdown() {
if (isInit) { // volatile: ok
synchronized (GLDrawableFactory.class) {
if (isInit) {
isInit=false;
- unregisterFactoryShutdownHook();
- shutdownImpl(shutdownType);
+ shutdownImpl();
}
}
}
}
- private static void shutdownImpl(ShutdownType shutdownType) {
+
+ private static void shutdownImpl() {
+ // Following code will _always_ remain in shutdown hook
+ // due to special semantics of native utils, i.e. X11Utils.
+ // The latter requires shutdown at JVM-Shutdown only.
synchronized(glDrawableFactories) {
for(int i=0; i<glDrawableFactories.size(); i++) {
- glDrawableFactories.get(i).destroy(shutdownType);
+ glDrawableFactories.get(i).destroy();
}
glDrawableFactories.clear();
@@ -198,6 +201,8 @@ public abstract class GLDrawableFactory {
nativeOSFactory = null;
eglFactory = null;
}
+ GLContext.shutdown();
+ NativeWindowFactory.shutdown(isJVMShuttingDown);
}
private static synchronized void registerFactoryShutdownHook() {
@@ -206,7 +211,8 @@ public abstract class GLDrawableFactory {
}
factoryShutdownHook = new Thread(new Runnable() {
public void run() {
- GLDrawableFactory.shutdownImpl(GLProfile.ShutdownType.COMPLETE);
+ isJVMShuttingDown = true;
+ GLDrawableFactory.shutdownImpl();
}
});
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@@ -218,20 +224,6 @@ public abstract class GLDrawableFactory {
factoryShutdownHookRegistered = true;
}
- private static synchronized void unregisterFactoryShutdownHook() {
- if (!factoryShutdownHookRegistered) {
- return;
- }
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- Runtime.getRuntime().removeShutdownHook(factoryShutdownHook);
- return null;
- }
- });
- factoryShutdownHookRegistered = false;
- }
-
-
protected GLDrawableFactory() {
synchronized(glDrawableFactories) {
glDrawableFactories.add(this);
@@ -244,7 +236,7 @@ public abstract class GLDrawableFactory {
protected void enterThreadCriticalZone() {};
protected void leaveThreadCriticalZone() {};
- protected abstract void destroy(ShutdownType shutdownType);
+ protected abstract void destroy();
/**
* Retrieve the default <code>device</code> {@link AbstractGraphicsDevice#getConnection() connection},
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 513ccd101..23d789afd 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -198,44 +198,25 @@ public class GLProfile {
getProfileMap(device, true);
}
- /**
- * Shutdown type for {@link GLProfile#shutdown(ShutdownType)}.
- * <p>
- * {@link #SHARED_ONLY} For thread based resources only, suitable for eg. {@link java.applet.Applet Applet} restart.<br>
- * {@link #COMPLETE} Everything.<br>
- * </p>
- */
- public enum ShutdownType {
- /* Shared thread based resources only, eg. for Applets */
- SHARED_ONLY,
- /* Everything */
- COMPLETE;
- }
-
/**
* Manual shutdown method, may be called after your last JOGL use
* within the running JVM.<br>
* It releases all temporary created resources, ie issues {@link javax.media.opengl.GLDrawableFactory#shutdown()}.<br>
* The shutdown implementation is called via the JVM shutdown hook, if not manually invoked.<br>
* <p>
- * This method shall not need to be called for other reasons than issuing a proper shutdown of resources.
+ * This method shall not need to be called for other reasons than issuing a proper shutdown of resources at a defined time.
* </p>
- * @param type the shutdown type, see {@link ShutdownType}.
*/
- public static void shutdown(ShutdownType type) {
+ public static void shutdown() {
initLock.lock();
try {
if(initialized) { // volatile: ok
initialized = false;
if(DEBUG) {
- System.err.println("GLProfile.shutdown(type: "+type+") - thread "+Thread.currentThread().getName());
+ System.err.println("GLProfile.shutdown() - thread "+Thread.currentThread().getName());
Thread.dumpStack();
}
- GLDrawableFactory.shutdown(type);
- if(ShutdownType.COMPLETE == type) {
- GLContext.shutdown();
- }
- NativeWindowFactory.shutdown();
+ GLDrawableFactory.shutdown();
}
} finally {
initLock.unlock();
@@ -1480,7 +1461,7 @@ public class GLProfile {
if(DEBUG) {
System.err.println("Info: GLProfile.init - EGL/ES2 ANGLE disabled");
}
- eglFactory.destroy(ShutdownType.COMPLETE);
+ eglFactory.destroy();
eglFactory = null;
hasEGLFactory = false;
} else {