Bug 401 - Native window events not delivered when doing GLProfile.initSingleton()
Summary: Native window events not delivered when doing GLProfile.initSingleton()
Status: VERIFIED FIXED
Alias: None
Product: Jogl
Classification: JogAmp
Component: x11 (show other bugs)
Version: 2
Hardware: pc_x86_64 linux
: --- normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2010-07-03 18:05 CEST by Paul Alesius
Modified: 2010-11-11 18:50 CET (History)
2 users (show)

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


Attachments
Debug output of program (68.11 KB, text/plain)
2010-10-27 15:50 CEST, Wade Walker
Details

Note You need to log in before you can comment on or make changes to this bug.
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.