diff options
3 files changed, 200 insertions, 1 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c0db411dc..7239e81d5 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -188,6 +188,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* @@ -214,7 +215,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT @@ -235,6 +236,7 @@ testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAWTCloseX11DisplayBug565.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAWTCloseX11DisplayBug565.java new file mode 100644 index 000000000..8df54988f --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAWTCloseX11DisplayBug565.java @@ -0,0 +1,89 @@ +package com.jogamp.opengl.test.junit.jogl.acore; + +import jogamp.nativewindow.x11.X11Util; +import org.junit.Assert; +import org.junit.Test; + +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import java.awt.Frame; + +/** + * Tests the closing the device of GLCanvas in JOGL + */ +public class TestAWTCloseX11DisplayBug565 { + + @Test + public void testX11WindowMemoryLeak() throws Exception { + GLProfile.initSingleton(); // ensure shared resource runner is done + try { + for ( int j = 0; j < 10; j++ ) { + final int open0; + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + open0 = X11Util.getOpenDisplayConnectionNumber(); + } else { + open0 = 0; + } + + GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault( ) ); + Frame frame = new Frame( "AWT Resource X11 Leak - #" + j ); + + GLCanvas glCanvas = new GLCanvas( caps ); + frame.add( glCanvas ); + frame.setSize( 128, 128 ); + + final Frame _frame = frame; + final GLCanvas _glCanvas = glCanvas; + + try { + javax.swing.SwingUtilities.invokeAndWait( new Runnable() { + public void run() { + _frame.setVisible( true ); + } + } ); + } + catch ( Throwable t ) { + t.printStackTrace(); + Assert.fail(t.getMessage()); + } + glCanvas.display(); + try { + javax.swing.SwingUtilities.invokeAndWait( new Runnable() { + public void run() { + _frame.setVisible( false ); + _frame.remove( _glCanvas ); + _frame.dispose(); + } + } ); + } + catch ( Throwable t ) { + t.printStackTrace(); + Assert.fail(t.getMessage()); + } + + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + final int openD = X11Util.getOpenDisplayConnectionNumber() - open0; + if(openD>1) { + X11Util.dumpOpenDisplayConnections(); + X11Util.dumpPendingDisplayConnections(); + Assert.assertTrue("More than 1 new open display connections", false); + } + } + } + } + catch ( Exception e ) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + } + + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestAWTCloseX11DisplayBug565.class.getName()); + } + +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java new file mode 100644 index 000000000..e14d5b800 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java @@ -0,0 +1,108 @@ +package com.jogamp.opengl.test.junit.jogl.acore; + +import jogamp.nativewindow.x11.X11Util; +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; + +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.opengl.DefaultGLCapabilitiesChooser; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLPbuffer; +import javax.media.opengl.GLProfile; + +/** + * Tests the closing the device of GLWindow and GLPBuffer in JOGL + */ +public class TestNEWTCloseX11DisplayBug565 { + + @Test + public void testX11WindowMemoryLeak() throws Exception { + GLProfile.initSingleton(); // ensure shared resource runner is done + try { + for ( int j = 0; j < 10; j++ ) { + final int open0; + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + open0 = X11Util.getOpenDisplayConnectionNumber(); + } else { + open0 = 0; + } + + GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault( ) ); + + GLWindow window = GLWindow.create(caps); + window.setTitle("NEWT Resource X11 Leak - #" + j ); + window.setSize( 128, 128 ); + window.setVisible(true); + window.display(); + window.setVisible(false); + window.destroy(); + + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + final int openD = X11Util.getOpenDisplayConnectionNumber() - open0; + if(openD>1) { + X11Util.dumpOpenDisplayConnections(); + X11Util.dumpPendingDisplayConnections(); + Assert.assertTrue("More than 1 new open display connections", false); + } + } + } + } + catch ( Exception e ) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + } + + + @Test + public void testX11WindowMemoryLeakOffscreenWindow() throws Exception { + GLProfile.initSingleton(); // ensure shared resource runner is done + try { + for ( int j = 0; j < 10; j++ ) { + final int open0; + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + open0 = X11Util.getOpenDisplayConnectionNumber(); + } else { + open0 = 0; + } + final GLProfile glp = GLProfile.getDefault( ); + GLCapabilitiesImmutable caps = new GLCapabilities( glp ); + + + GLPbuffer buffer = GLDrawableFactory.getFactory( glp ).createGLPbuffer( + null, + caps, + new DefaultGLCapabilitiesChooser(), + 256, + 256, + null + ); + buffer.display(); + buffer.destroy(); + + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + final int openD = X11Util.getOpenDisplayConnectionNumber() - open0; + if(openD>1) { + X11Util.dumpOpenDisplayConnections(); + X11Util.dumpPendingDisplayConnections(); + Assert.assertTrue("More than 1 new open display connections", false); + } + } + } + } + catch ( Exception e ) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestNEWTCloseX11DisplayBug565.class.getName()); + } + +} + |