<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>898</bug_id>
          
          <creation_ts>2013-11-07 09:58:05 +0100</creation_ts>
          <short_desc>Can&apos;t control Animator from EDT/Animator thread - notifyAll() not always called in AnimatorBase.finishLifecycleAction(..)</short_desc>
          <delta_ts>2013-11-07 11:34:54 +0100</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Jogl</product>
          <component>core</component>
          <version>2</version>
          <rep_platform>All</rep_platform>
          <op_sys>all</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>---</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Sven Gothel">sgothel</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          <cc>sgothel</cc>
          
          <cf_type>---</cf_type>
          <cf_scm_refs>3e1924e73d583d344b45839bed3a7bd51751a019</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3289</commentid>
    <comment_count>0</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2013-11-07 09:58:05 +0100</bug_when>
    <thetext>Copied from forum post:
  &lt;http://forum.jogamp.org/Can-t-control-Animator-from-EDT-Animator-thread-tp4030500.html&gt;
from &apos;kosukek&apos; [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&apos;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&apos;ve been using JOGL v2.0-r11 for about a year now and it&apos;s been working quite well. However since v2.0.2 when Animator.start()/stop()/pause()/resume() is called on EDT/Animator thread it doesn&apos;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&apos;s a snippet to reproduce the issue. On v2.0-r11, this repeats animation cycle. On v2.0.2 or higher, calling Animator&apos;s member methods generates exceptions and resume() won&apos;t restart the cycle as expected(tested on JDK6/7, Windows x64).

public class NewJFrame extends javax.swing.JFrame {

    static {
        System.setProperty(&quot;jogl.debug.Animator&quot;, Boolean.TRUE.toString());
    }

    public NewJFrame() {
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        //Layout
        setMinimumSize(new Dimension(100, 100));
        getContentPane().setLayout(new BorderLayout());
        GLCanvas panel = new GLCanvas();
        getContentPane().add(panel, BorderLayout.CENTER);
        pack();
        //Animator
        final Animator animator = new Animator();
        animator.add(panel);
        //GLEventListener
        panel.addGLEventListener(new GLEventListener() {
            long startTime = System.nanoTime();

            @Override
            public void init(GLAutoDrawable glad) {
            }

            @Override
            public void dispose(GLAutoDrawable glad) {
            }

            @Override
            public void display(GLAutoDrawable glad) {
                System.out.println(&quot;display()&quot;);
                long time = System.nanoTime();
                if (animator.isAnimating() &amp;&amp; time - startTime &gt; 100e6) {
                    animator.pause();
                    System.out.println(&quot;animator.pause()&quot;);
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            if (animator.isPaused()) {
                                startTime = System.nanoTime();
                                animator.resume(); //Doesn&apos;t work on v2.0.2 or higher
                                System.out.println(&quot;animator.resume()&quot;);
                            }
                        }
                    });
                }
            }

            @Override
            public void reshape(GLAutoDrawable glad, int i, int i1,
                    int i2, int i3) {
            }
        });
        //Start animation
        animator.start();
        System.out.println(&quot;animator.start()&quot;);
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            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.

Sincerely,

+++</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3290</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2013-11-07 11:34:54 +0100</bug_when>
    <thetext>3e1924e73d583d344b45839bed3a7bd51751a019
Apply best efford on Animator operation&apos;s finishLifecycleAction(..) in !blocking mode, i.e. notifyAll() if waitCondition holds and test again</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>