From 7140081033444abf95d2f8289eaa62ead41cf2e0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 29 Aug 2015 19:41:10 +0200 Subject: *AnimatorImpl: Catch concurrent pulling of GLAutoDrawable instances It may happen that an GLAutoDrawable is being pulled concurrently from the animators list, in which case an IndexOutOfBoundsException might be thrown. Example: [junit] *** AWTRobotUtil: UncaughtException (this Thread main-AWTAnimator#00) : Thread , java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 [junit] java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 [junit] at java.util.ArrayList.rangeCheck(ArrayList.java:653) [junit] at java.util.ArrayList.get(ArrayList.java:429) [junit] at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:68) [junit] at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:451) [junit] at com.jogamp.opengl.util.Animator$MainLoop.run(Animator.java:198) [junit] at java.lang.Thread.run(Thread.java:745) --- .../com/jogamp/opengl/util/AWTAnimatorImpl.java | 48 ++++++++++++---------- .../jogamp/opengl/util/DefaultAnimatorImpl.java | 13 ++++-- 2 files changed, 37 insertions(+), 24 deletions(-) (limited to 'src/jogl/classes/com') diff --git a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java index 76d64963f..9e9cc8e44 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java @@ -56,7 +56,7 @@ import com.jogamp.opengl.util.AnimatorBase.UncaughtAnimatorException; class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { // For efficient rendering of Swing components, in particular when // they overlap one another - private final List lightweights = new ArrayList(); + private final List lightweights = new ArrayList(); private final Map repaintManagers = new IdentityHashMap(); private final Map dirtyRegions = new IdentityHashMap(); @@ -64,34 +64,40 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { public void display(final ArrayList drawables, final boolean ignoreExceptions, final boolean printExceptions) throws UncaughtAnimatorException { - for (int i=0; i 0) { try { SwingUtilities.invokeAndWait(drawWithRepaintManagerRunnable); - } catch (final Exception e) { - e.printStackTrace(); + } catch (final Throwable t) { + t.printStackTrace(); } lightweights.clear(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java index 6cded29d9..d8c8465d9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java @@ -48,12 +48,19 @@ class DefaultAnimatorImpl implements AnimatorBase.AnimatorImpl { public void display(final ArrayList drawables, final boolean ignoreExceptions, final boolean printExceptions) throws UncaughtAnimatorException { - for (int i=0; i