Can JOGL do multiple GLCanvas ?

Hi,

I am using the Xith framework and try to get more than one
JPanel with a 3D scene up and running. However, as soon as
there is more than one view rendered the process starts
leaking memory at a rate of about several MB per view.render
call. This leaves my machine unusable within a few seconds.

Since there is no OutOfMemoryError from the java side I suspect it must be somewhere else.

Has anyone experienced similar problems or has more than one GLCanvas active without any problem.

Any ideas where to look for the source of this problem ?

Thanks, Ca$

What OS and graphics card are you using? Are you using the GLCanvas or GLJPanel widget? Are you running with the latest version of JOGL?

Multiple GLCanvases should work fine. There have been issues with past JOGL releases tickling bugs in some vendors’ graphics drivers but most of these seem to have been resolved. If you could, try specifying the system property -DJOGL_SINGLE_THREADED_WORKAROUND=true with the latest JOGL release and see if it works around the problem.

thanks for the hint, I will try it out.

OS is Suse Linux 9.1, Card is Nvidia FX5200 and Ti4600, JOGL version was b04, JDK5 (1.5), driver is latest Nvidia 6629.

I could not get the b09 release working due to a JOGL Exception “Could not make context current” on the FX5200, but I will try now with my old Ti4600 card.

Thanks,
Ca$

update:

just installed the latest JOGL release. But now I can’t run anything because of the following exception:

Exception in thread “X3d[myUniverse]” net.java.games.jogl.GLException: Error making context current
at net.java.games.jogl.impl.x11.X11GLContext.makeCurrent(X11GLContext.java:154)
at net.java.games.jogl.impl.x11.X11OnscreenGLContext.makeCurrent(X11OnscreenGLContext.java:111)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:203)
at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:186)
at net.java.games.jogl.GLCanvas.display(GLCanvas.java:74)
at com.xith3d.render.jogl.CanvasPeerImpl.render(CanvasPeerImpl.java:1162)
at com.xith3d.scenegraph.View.renderOnce(View.java:592)
at ext.xith3d.base.XithWorld.updatePostwork(XithWorld.java:210)
at kernel.math.geom3dv2.World3d.update(World3d.java:220)

OS: Suse 9.1 Graca: nv Ti4600 Driver: 6629

Any ideas ?

Thanks

Could you please specify


-Djogl.verbose -Djogl.debug.GLContext -DJOGL_SINGLE_THREADED_WORKAROUND=true

and post the output?

sorry, I don’t seem to get more output :frowning:

I tried it now using the jogl demos:

java -Djogl.verbose -Djogl.debug.GLContext -DJOGL_SINGLE_THREADED_WORKAROUND=true demos.gears.Gears
CANVAS GL IS: net.java.games.jogl.impl.x11.X11GLImpl
CANVAS GLU IS: net.java.games.jogl.impl.GLUImpl
Exception in thread “Thread-1” net.java.games.jogl.GLException: Error making context current
at net.java.games.jogl.impl.x11.X11GLContext.makeCurrent(X11GLContext.java:154)
at net.java.games.jogl.impl.x11.X11OnscreenGLContext.makeCurrent(X11OnscreenGLContext.java:111)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:203)
at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:186)
at net.java.games.jogl.GLCanvas.display(GLCanvas.java:74)
at net.java.games.jogl.Animator$1.run(Animator.java:104)
at java.lang.Thread.run(Thread.java:595)

note: java is 1.5.0-rc-b63

You are using an old version of jogl.jar, if not also libjogl.so. Find and delete all copies of JOGL installed in JREs and elsewhere in your system, upgrade, and try again.

yes, one old jogl.jar slipped my update :o

with the new update the “make context current” exception is history :slight_smile:

what remains is the memory leak. I tried both using a single thread for the updates and two separate threads for the render update call with no difference in their effect.
If I don’t update the second panel no memory is leaked.

here is the output:

section for panel 1

!!! Created GL context for net.java.games.jogl.impl.x11.X11OnscreenGLContext
!!! Initializing GLU extension address table
!!! Initializing OpenGL extension address table
!!! GLX version: major 1, minor 3
Init GL is net.java.games.jogl.impl.x11.X11GLImpl
OpenGL Renderer = GeForce4 Ti 4600/AGP/SSE/3DNOW!
OpenGL Version = 1.5.2 NVIDIA 66.29
OpenGL Vendor = NVIDIA Corporation
No Fragment Program support, skipping

section for panel 2

!!! Created GL context for net.java.games.jogl.impl.x11.X11OnscreenGLContext
!!! Initializing OpenGL extension address table
!!! GLX version: major 1, minor 3
OpenGL Renderer = GeForce4 Ti 4600/AGP/SSE/3DNOW!
OpenGL Version = 1.5.2 NVIDIA 66.29
OpenGL Vendor = NVIDIA Corporation

this is occuring at each render call per frame

Making context net.java.games.jogl.impl.x11.X11OnscreenGLContext@15b0afd current
Freeing context net.java.games.jogl.impl.x11.X11OnscreenGLContext@15b0afd
Making context net.java.games.jogl.impl.x11.X11OnscreenGLContext@1bfc93a current
Freeing context net.java.games.jogl.impl.x11.X11OnscreenGLContext@1bfc93a

Could you try hacking the Gears.java in the JOGL demos workspace and replace main() with the following:


  public static void main(String[] args) {
    Frame frame = new Frame("Gear Demo");
    frame.setLayout(new BorderLayout());
    GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());

    // Use debug pipeline
    //    canvas.setGL(new DebugGL(canvas.getGL()));
    System.err.println("CANVAS GL IS: " + canvas.getGL().getClass().getName());
    System.err.println("CANVAS GLU IS: " + canvas.getGLU().getClass().getName());

    canvas.addGLEventListener(new GearRenderer());
    frame.add(canvas, BorderLayout.WEST);
    canvas.setSize(300, 300);

    GLCanvas canvas1 = canvas;


    canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());

    // Use debug pipeline
    //    canvas.setGL(new DebugGL(canvas.getGL()));
    System.err.println("CANVAS GL IS: " + canvas.getGL().getClass().getName());
    System.err.println("CANVAS GLU IS: " + canvas.getGLU().getClass().getName());

    canvas.addGLEventListener(new GearRenderer());
    frame.add(canvas, BorderLayout.CENTER);
    canvas.setSize(300, 300);

    GLCanvas canvas2 = canvas;

    frame.setSize(600, 300);
    frame.show();



    while (true) {
      canvas1.display();
      canvas2.display();
    }
  }

Does this also leak memory? It works fine on my system (Windows XP, NVidia Quadro FX Go700). If it doesn’t leak then I doubt that there is an inherent bug in JOGL; try cutting down your test program, which should help you track down the problem. Is your test program standalone, or does it require Xith3D?

It does not leak on my system either.

So it is possibly somewhere in the JOGL handling of Xith3d.

Lets hope I can track it down.

Thanks for your effort,
Ca$cade

after a long debugging night I (hopefully) resolved the issue :slight_smile:

When using a single texture (Xith3D Texture Object) in two Canvas3D displays at the same time the memory is leaked. By the amount of leaking I suspect that for some reason the texture is allocated on the native GL side each time it is accessed for rendering.

But this problem can be avoided using a simple workaround like double loading the textures which are used in both displays at the same time.

Again, thanks for your help :slight_smile:

@Ken Russel:

can you perhaps hack the gears demo to use the same instance of a texture (e.g. on the gears geometry) in both GLCanvas displays and tell whether this works or not. This would help to identify the location of this bug. If JOGL can do this without a problem then perhaps there is something wrong in Xith3D with assigning textures to objects.

I would do it myself if I were in any way familiar with GL/JOGL hacking.

Thanks,
Ca$

The problem is probably that you’re trying to use a texture object defined in one OpenGL context that isn’t defined in another. If you want to use the same texture object in multiple contexts then you have to set up sharing between those contexts, which you can do with the appropriate factory method in the GLDrawableFactory.