Core dump on Solaris x86 with GLJPanel

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Core dump on Solaris x86 with GLJPanel

Attila Barcsik
Hi!

I've run into some problems with GLJPanel on Solaris ( x86 and x86_64 ), and I'm not sure if it's my fault or GLJPanel's. The same application runs and exits on linux without errors, but on Solaris it produces core dump on regular exit. Is this problem only related to Solaris?

x86.log
x86_64.log

Best Regards,
Attila
Reply | Threaded
Open this post in threaded view
|

Re: Core dump on Solaris x86 with GLJPanel

gouessej
Administrator
makeCurrent is called while the GLJPanel is being destroyed. I don't know why it crashes only on Solaris. Do you use an animator?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Core dump on Solaris x86 with GLJPanel

Attila Barcsik
There is an animator object, but it was stopped all the time. I've just created the Animator instance it and nothing more, never actually started it. There is also a listener for window closing which will stop it if it's running like this:

this.addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent e) {
        new Thread(new Runnable() {
          @Override
          public void run() {
            if (animator.isAnimating()) {
              animator.stop();
            }
            System.exit(0);
          }
        }).start();
      }
    });

All repaint were called from action listeners and setter methods manually.

( Why an animator if i call repaints manually? I have a FPS display, and if it's enabled, I start the animator for showing accurate fps value. Maybe it would be a better idea to have an animator always + some boolean needToRepaint flag? )
Reply | Threaded
Open this post in threaded view
|

Re: Core dump on Solaris x86 with GLJPanel

gouessej
Administrator
Yes your last suggestion is the best one on my view. I have personally done this (using always an animator + a mutable boolean flag to know whether a redraw is needed) and it works reliably (except when I set the auto swap buffer mode to false, I wrote a bug report about this problem).
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Core dump on Solaris x86 with GLJPanel

Attila Barcsik
I've implemented this fail-safe solution with the always on animator + flag ( + an additional flag for dispose only to be executed once + manual call to GLProfile.shutdown() before exit )  and it works like a charm ( solaris/linux ).

Just need to be careful with the life cycle! All OpenGL windows must go through these steps:

When starting the mother application call GLProfile.initSingleton() before anything!
for ( any OpenGL window which is started by the mother application ) {
  1. create drawable/animator etc.
  2. start animator
  3. render render... all flags are true ( if render data is the same renderFlag can be set to false to spare CPU time until something changes in the data )
  4. just before closing this OpenGL window: stop animator & renderFlag=false  immediately!
  5. when it goes through dispose(), it must set disposedFlag=true so dispose() cannot be executed twice.
}
Before closing the mother application call GLProfile.shutdown() manually!

JVM obviously does not works the same way on different platforms, so do not trust it ;).


Still, it's unclear to me how can everything work without these hacks on linux and don't on solaris. // nevermind

Reply | Threaded
Open this post in threaded view
|

Re: Core dump on Solaris x86 with GLJPanel

Wade Walker
Administrator
The solution you described just sounds like good programming practice  Anytime you have a multithreaded program (which you do once there is an animator), you have to take special care, and since Java uses the native OS threads, they can behave differently on each platform.

For the kind of program you describe, where you only redraw on user action or model change (instead of constant redraw like in a videogame), I've always done those without an animator. I just use the windowing system's dirty region/paint event system, and do a GL render on the paint event. The FPS counter is only updated during rendering, so it stays at its last value until the user moves something again.
Reply | Threaded
Open this post in threaded view
|

Re: Core dump on Solaris x86 with GLJPanel

gouessej
Administrator
You can do almost the same thing with an animator by setting the render flag to true, it avoids forcing the rendering in several places in the source code (I assume you just call display()), the rendering is then done always on the same thread without making the context current when it could be avoided.
Julien Gouesse | Personal blog | Website