Bug 898 - Can't control Animator from EDT/Animator thread - notifyAll() not always called in AnimatorBase.finishLifecycleAction(..)
Summary: Can't control Animator from EDT/Animator thread - notifyAll() not always call...
Alias: None
Product: Jogl
Classification: JogAmp
Component: core (show other bugs)
Version: 2
Hardware: All all
: --- enhancement
Assignee: Sven Gothel
Depends on:
Reported: 2013-11-07 09:58 CET by Sven Gothel
Modified: 2013-11-07 11:34 CET (History)
1 user (show)

See Also:
Type: ---
SCM Refs:
Workaround: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Sven Gothel 2013-11-07 09:58:05 CET
Copied from forum post:
from 'kosukek' [via jogamp]


In our application we play short animations on GLCanvas here and there, but most of the time the canvas remains static and doesn't require frequent repaints. We use Animator class to refresh the canvas during an animation, then after a while Animator.pause() is called to go back to static mode.

We've been using JOGL v2.0-r11 for about a year now and it's been working quite well. However since v2.0.2 when Animator.start()/stop()/pause()/resume() is called on EDT/Animator thread it doesn't seem to work. Had a quick look at AnimatorBase.finishLifecycleAction() and probably the difference from v2.0-r11 might be that notifyAll() is not always called. On v2.0-r11, it seems notifyAll() is unconditionally called once at least.

Here's a snippet to reproduce the issue. On v2.0-r11, this repeats animation cycle. On v2.0.2 or higher, calling Animator's member methods generates exceptions and resume() won't restart the cycle as expected(tested on JDK6/7, Windows x64).

public class NewJFrame extends javax.swing.JFrame {

    static {
        System.setProperty("jogl.debug.Animator", Boolean.TRUE.toString());

    public NewJFrame() {
        setMinimumSize(new Dimension(100, 100));
        getContentPane().setLayout(new BorderLayout());
        GLCanvas panel = new GLCanvas();
        getContentPane().add(panel, BorderLayout.CENTER);
        final Animator animator = new Animator();
        panel.addGLEventListener(new GLEventListener() {
            long startTime = System.nanoTime();

            public void init(GLAutoDrawable glad) {

            public void dispose(GLAutoDrawable glad) {

            public void display(GLAutoDrawable glad) {
                long time = System.nanoTime();
                if (animator.isAnimating() && time - startTime > 100e6) {
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            if (animator.isPaused()) {
                                startTime = System.nanoTime();
                                animator.resume(); //Doesn't work on v2.0.2 or higher

            public void reshape(GLAutoDrawable glad, int i, int i1,
                    int i2, int i3) {
        //Start animation

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);

I am wondering if we should avoid using Animator altogether in this kind of situation. I understand NEWT should do a better job but we need to stick to GLCanvas for now.


Comment 1 Sven Gothel 2013-11-07 11:34:54 CET
Apply best efford on Animator operation's finishLifecycleAction(..) in !blocking mode, i.e. notifyAll() if waitCondition holds and test again