summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-11-10 05:15:12 +0100
committerSven Gothel <[email protected]>2011-11-10 05:15:12 +0100
commitd237bde81beb9fc7bcd04b500a59360b63477285 (patch)
tree3cd3ab7a534edc84c6d03c19ee7403848c49e65e /src/jogl/classes/com/jogamp/opengl/util
parent51ad6992e068f25d86d2c9e085bd7ec6f49d2432 (diff)
Animator: Limit wait for condition in finishLifecycleAction() via timeout
While impl. recreation for offscreen surfaces @ WindowImpl.setSize(), commit 51ad6992e068f25d86d2c9e085bd7ec6f49d2432, it appears Animator deadlocks in some cases. finishLifecycleAction() [blocks until pause() .. is accomplished] queries whether we are even able to wait using skipWaitForCompletion(). The latter method can only query if we are on the animation thread or AWT-EDT, etc, but not if we have traversed through a 3rd party thread, eg NEWT EDT. This patches limits the wait with a timeout of 20frames @ 60Hz (20*16ms).
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/Animator.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
index 16aac957a..47f0ea586 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
@@ -59,7 +59,9 @@ import javax.media.opengl.GLAutoDrawable;
*/
public class Animator extends AnimatorBase {
-
+ /** timeout in milliseconds, 20 frames @ 60Hz, limiting {@link #finishLifecycleAction(Condition)} */
+ private static long TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION = 20*16;
+
protected ThreadGroup threadGroup;
private Runnable runnable;
private boolean runAsFastAsPossible;
@@ -241,18 +243,21 @@ public class Animator extends AnimatorBase {
// dependencies on the Animator's internal thread. Currently we
// use a couple of heuristics to determine whether we should do
// the blocking wait().
+ boolean to = false;
boolean doWait = !impl.skipWaitForCompletion(animThread);
if (doWait) {
- while (condition.result()) {
+ while (!to && condition.result()) {
+ long td = System.currentTimeMillis();
try {
- wait();
+ wait(TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION);
} catch (InterruptedException ie) { }
+ to = (System.currentTimeMillis() - td) >= TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION;
}
}
if(DEBUG) {
System.err.println("finishLifecycleAction(" + condition.getClass().getName() + "): finished - waited " + doWait +
", started: " + isStartedImpl() +", animating: " + isAnimatingImpl() +
- ", paused: " + isPausedImpl() + ", drawables " + drawables.size());
+ ", paused: " + isPausedImpl() + ", drawables " + drawables.size() + ", timedout "+to);
}
}