From 07a4801f3b5bfd4fba9a1a4a542ce2f2eae4396a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 5 Aug 2014 23:01:28 +0200 Subject: Bug 1039 - Specify behavior of GLEventListener Exceptions occurring while GLAutoDrawable processing [part-2] In case of an exception thrown within an GLEventListener called off-thread by Animator: - Animator shall stop - Animator shall forward the exception GLDrawableHelper shall also flush all queued GLRunnable tasks in case of an exception, so that another thread waiting until it's completion is notified and continues processing. --- .../classes/com/jogamp/opengl/util/Animator.java | 36 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'src/jogl/classes/com') diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index ae09d81a4..634e83353 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -132,6 +132,8 @@ public class Animator extends AnimatorBase { @Override public void run() { + GLException displayCaught = null; + try { synchronized (Animator.this) { if(DEBUG) { @@ -158,7 +160,14 @@ public class Animator extends AnimatorBase { if ( exclusiveContext && !drawablesEmpty && !ectCleared ) { ectCleared = true; setDrawablesExclCtxState(false); - display(); // propagate exclusive change! + try { + display(); // propagate exclusive change! + } catch (final Throwable t) { + displayCaught = GLException.newGLException(t); + stopIssued = true; + isAnimating = false; + break; // end pause loop + } } isAnimating = false; Animator.this.notifyAll(); @@ -185,7 +194,14 @@ public class Animator extends AnimatorBase { } } // sync Animator.this if (!stopIssued) { - display(); + try { + display(); + } catch (final Throwable t) { + displayCaught = GLException.newGLException(t); + stopIssued = true; + isAnimating = false; + break; // end animation loop + } } if (!stopIssued && !runAsFastAsPossible) { // Avoid swamping the CPU @@ -201,16 +217,32 @@ public class Animator extends AnimatorBase { if( exclusiveContext && !drawablesEmpty ) { setDrawablesExclCtxState(false); display(); // propagate exclusive change! + try { + display(); // propagate exclusive change! + } catch (final Throwable t) { + if( null == displayCaught ) { + displayCaught = GLException.newGLException(t); + } else { + GLException.newGLException(t).printStackTrace(); + } + } } synchronized (Animator.this) { if(DEBUG) { System.err.println("Animator stop on " + animThread.getName() + ": " + toString()); + if( null != displayCaught ) { + System.err.println("Animator caught: "+displayCaught.getMessage()); + displayCaught.printStackTrace(); + } } stopIssued = false; pauseIssued = false; animThread = null; isAnimating = false; Animator.this.notifyAll(); + if( null != displayCaught ) { + throw displayCaught; + } } } } -- cgit v1.2.3