Bug 401

Summary: Native window events not delivered when doing GLProfile.initSingleton()
Product: [JogAmp] Jogl Reporter: Paul Alesius <Paul>
Component: x11Assignee: Sven Gothel <sgothel>
Status: VERIFIED FIXED    
Severity: normal CC: Paul, wwalker3
Priority: ---    
Version: 2   
Hardware: pc_x86_64   
OS: linux   
Type: --- SCM Refs:
d2ec9f34cf2b3a54c80e2e23671d8fa8a5397d5d
Workaround: ---
Attachments: Debug output of program

Description Paul Alesius 2010-07-03 18:05:55 CEST
I'm using the latest JOGL that I've built from source from the git repository. (JOGL-2.0-pre-0702)
When doing a static initialization of the framework with GLProfile.initSingleton() and creating an AWT frame, then I can't close the AWT frame because the window listener doesn't seem to receive the "window closing" events. I've tried this in Fedora 13 (x86_64) and CentOS 5.5 (x86_64).

--------------------------------------------------------------------------------
Example code:

public class Main {
	static {
	        GLProfile.initSingleton(); // Causes the frame to never get the WindowEvent
	}
	public static void main(String... args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				Frame frame = new Frame();
				frame.setSize(500, 500);
				addWindowListener(frame);
				frame.setVisible(true);
			}
			public void addWindowListener(final Frame frame) {
				frame.addWindowListener(new WindowAdapter() {
					public void windowClosing(WindowEvent ev) { // Never gets this event
						System.out.println("windowClosing()");
						frame.dispose();
					}
				});
			}
		});
	}
}
  


--------------------------------------------------------------------------------

If I put the GLProfile.initSingleton() in a new thread (new Thread(new Runnable(){public void run() {GLProfile.initSingleton;}})), then it works and I can close the AWT window.
Comment 1 Wade Walker 2010-10-27 15:50:31 CEST
Created attachment 155 [details]
Debug output of program
Comment 2 Wade Walker 2010-10-27 15:51:23 CEST
I've seen this too. The general symptom is that if I comment out the first four lines of GL stuff below (plus "frame.add(canvas)"), the app works fine.

When I comment in any of those lines, the app doesn't get its close message. It also doesn't get other native messages -- I tried mouse move too.

Also, the line "frame.add(canvas)" makes the app unterminatable by Eclipse. I have to go the the command line and kill it with "kill -KILL". Commenting out this line makes the app terminateable by Eclipse again.

Here's the bug report info:

Source code: included below
Invocation command-line: invoked from inside Eclipse
OS & version: CentOS 5.4 2.6.18-164.el5
Architecture: x86_64
Java version: 1.6.0_21
JOGL Source/build versions: jogl-b187-2010-09-30_18-13-01
Exceptions, stdout/stderr log file: included below

package name.wadewalker.test;

import java.awt.Frame;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.*;
import javax.media.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.*;

public class SimpleScene implements GLEventListener {

	static { GLProfile.initSingleton(); }

    public static void main(String[] args) {
        GLProfile glp = GLProfile.getDefault();
        GLCapabilities caps = new GLCapabilities(glp);
        GLCanvas canvas = new GLCanvas(caps);

        Frame frame = new Frame("AWT Window Test");
        frame.setSize(300, 300);
        frame.add(canvas);
        frame.setVisible(true);

        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        canvas.addGLEventListener(new SimpleScene());
    }

    @Override
    public void display(GLAutoDrawable drawable) {
        update();
        render(drawable);
    }

    @Override
    public void dispose(GLAutoDrawable drawable) {
    }

    @Override
    public void init(GLAutoDrawable drawable) {
    }

    @Override
    public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
    }

    private void update() {
    }

    private void render(GLAutoDrawable drawable) {
        GL2 gl = drawable.getGL().getGL2();

        gl.glClear(GL.GL_COLOR_BUFFER_BIT);

        // draw a triangle filling the window
        gl.glBegin(GL.GL_TRIANGLES);
        gl.glColor3f(1, 0, 0);
        gl.glVertex2f(-1, -1);
        gl.glColor3f(0, 1, 0);
        gl.glVertex2f(0, 1);
        gl.glColor3f(0, 0, 1);
        gl.glVertex2f(1, -1);
        gl.glEnd();
    }
}
Comment 3 Sven Gothel 2010-11-10 20:49:22 CET
was fixed ..

http://jogamp.org/chuck/job/jogl/label=linux-x86_64/lastCompletedBuild/testReport/com.jogamp.test.junit.jogl.awt/TestAWT02WindowClosing/test01WindowClosing/

sorry don't know when anymore, probably d2ec9f34cf2b3a54c80e2e23671d8fa8a5397d5d,
or another deadlock change.

please verify.
Comment 4 Wade Walker 2010-11-11 18:50:11 CET
Tested and verified that b211 doesn't show this bug anymore. Both reshape and mousemove events show up properly now.