aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-02-17 03:25:34 +0100
committerSven Gothel <[email protected]>2013-02-17 03:25:34 +0100
commit8edaa9780455b60f6034a78970cab4f516d4b061 (patch)
tree9f088885da8c3690be871a720dfcd254f569d2ef /src
parent674004cd67105b27b63c7ac2f05738f21864bdc0 (diff)
NEWT/OSX: Fix Memory Leak ; Fix Occasional Crash Duer to Lifecycle Ops not on Main-Thread.
- Fix Memory Leak - NewtWindow::dealloc -> [NewtView release]: Fixes NewtView leak - NewtView::dealloc -> removeTrackingRect: Removes occasional crash (double free of TrackingRect) - Fix Occasional Crash Duer to Lifecycle Ops not on Main-Thread. Perform OSX WindowDriver ops on Main-Thread: - close0 - changeContentView0 - createWindow0 - Cleaned up AddRemove unit tests, added TestAddRemove03GLWindowNEWT
Diffstat (limited to 'src')
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java43
-rw-r--r--src/newt/native/MacWindow.m31
-rw-r--r--src/newt/native/NewtMacWindow.m32
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java35
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java37
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove03GLWindowNEWT.java130
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java4
7 files changed, 243 insertions, 69 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
index 5755bdf11..89d53fbeb 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
@@ -50,6 +50,7 @@ import jogamp.newt.WindowImpl;
import jogamp.newt.driver.DriverClearFocus;
import jogamp.newt.driver.DriverUpdatePosition;
+import com.jogamp.common.util.Function;
import com.jogamp.newt.event.InputEvent;
import com.jogamp.newt.event.KeyEvent;
@@ -86,7 +87,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
sscSurfaceHandle = 0;
isOffscreenInstance = false;
if (0 != handle) {
- close0(handle);
+ OSXUtil.RunOnMainThread(true, new Runnable() {
+ public void run() {
+ close0( handle );
+ } } );
}
} catch (Throwable t) {
if(DEBUG_IMPLEMENTATION) {
@@ -378,24 +382,36 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
try {
if(0!=getWindowHandle()) {
// save the view .. close the window
- surfaceHandle = changeContentView0(getParentWindowHandle(), getWindowHandle(), 0);
+ surfaceHandle = OSXUtil.RunOnMainThread(true, new Function<Long, Object>() {
+ public Long eval(Object... args) {
+ return Long.valueOf(
+ changeContentView0(getParentWindowHandle(), getWindowHandle(), 0) );
+ } } ).longValue();
if(recreate && 0==surfaceHandle) {
throw new NativeWindowException("Internal Error - recreate, window but no view");
}
- close0(getWindowHandle());
+ OSXUtil.RunOnMainThread(true, new Runnable() {
+ public void run() {
+ close0( getWindowHandle() );
+ } } );
setWindowHandle(0);
} else {
surfaceHandle = 0;
}
- setWindowHandle(createWindow0(getParentWindowHandle(),
- pS.getX(), pS.getY(), width, height,
- (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance),
- fullscreen,
- ((isUndecorated() || offscreenInstance) ?
- NSBorderlessWindowMask :
- NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask),
- NSBackingStoreBuffered,
- getScreen().getIndex(), surfaceHandle));
+
+ setWindowHandle( OSXUtil.RunOnMainThread(true, new Function<Long, Object>() {
+ public Long eval(Object... args) {
+ return Long.valueOf(
+ createWindow0( getParentWindowHandle(),
+ pS.getX(), pS.getY(), width, height,
+ (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance),
+ fullscreen,
+ ( (isUndecorated() || offscreenInstance) ? NSBorderlessWindowMask :
+ NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask ),
+ NSBackingStoreBuffered,
+ getScreen().getIndex(), surfaceHandle) );
+ } } ).longValue() );
+
if (getWindowHandle() == 0) {
throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this);
}
@@ -411,6 +427,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
}
protected static native boolean initIDs0();
+ /** Must be called on Main-Thread */
private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h,
boolean opaque, boolean fullscreen, int windowStyle,
int backingStoreType,
@@ -422,9 +439,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
/** in case of a child window, it actually only issues orderBack(..) */
private native void orderOut0(long window);
private native void orderFront0(long window);
+ /** Must be called on Main-Thread */
private native void close0(long window);
private native void setTitle0(long window, String title);
private native long contentView0(long window);
+ /** Must be called on Main-Thread */
private native long changeContentView0(long parentWindowOrViewHandle, long window, long view);
private native void setContentSize0(long window, int w, int h);
private native void setFrameTopLeftPoint0(long parentWindowHandle, long window, int x, int y);
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m
index b9c339285..94363624f 100644
--- a/src/newt/native/MacWindow.m
+++ b/src/newt/native/MacWindow.m
@@ -553,7 +553,9 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0
return (jboolean) res;
}
-/*
+/**
+ * Method is called on Main-Thread, hence no special invocation required inside method.
+ *
* Class: jogamp_newt_driver_macosx_WindowDriver
* Method: createWindow0
* Signature: (JIIIIZIIIJ)J
@@ -706,19 +708,10 @@ NS_ENDHANDLER
return (jlong) ((intptr_t) myWindow);
}
-// Footnote: Our view handling produces random 'Assertion failure' even w/o parenting:
-//
-// [NSThemeFrame lockFocus], /SourceCache/AppKit/AppKit-1138.23/AppKit.subproj/NSView.m:6053
-// [NSThemeFrame(0x7fe94bc72c80) lockFocus] failed with window=0x7fe94bc445a0, windowNumber=9425, [self isHiddenOrHasHiddenAncestor]=0
-// ..
-// AppKit 0x00007fff89621001 -[NSView lockFocus] + 250
-// AppKit 0x00007fff8961eafa -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 3780
-// AppKit 0x00007fff8961793e -[NSView displayIfNeeded] + 1676
-// AppKit 0x00007fff8961707d _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 648
-//
-
-/*
+/**
+ * Method is called on Main-Thread, hence no special invocation required inside method.
+ *
* Class: jogamp_newt_driver_macosx_WindowDriver
* Method: close0
* Signature: (J)V
@@ -761,8 +754,6 @@ NS_DURING
[mView exitFullScreenModeWithOptions: NULL];
}
// Note: mWin's release will also release it's mView!
- // [mWin setContentView: nil];
- // [mView release];
}
NS_HANDLER
NS_ENDHANDLER
@@ -770,7 +761,8 @@ NS_ENDHANDLER
if(NULL!=pWin) {
[mWin detachFromParent: pWin];
}
- [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:NO];
+ // [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:NO];
+ [mWin orderOut: mWin];
DBG_PRINT( "windowClose.1 - %p,%d view %p,%d, parent %p\n",
mWin, getRetainCount(mWin), mView, getRetainCount(mView), pWin);
@@ -778,7 +770,8 @@ NS_ENDHANDLER
// Only release window, if release is not yet in process.
// E.g. destroyNotifySent:=true set by NewtMacWindow::windowWillClose(), i.e. window-close was clicked.
if(!destroyNotifySent) {
- [mWin performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
+ // [mWin performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
+ [mWin release];
}
DBG_PRINT( "windowClose.X - %p,%d, released %d, view %p,%d, parent %p\n",
@@ -960,7 +953,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_contentView0
return res;
}
-/*
+/**
+ * Method is called on Main-Thread, hence no special invocation required inside method.
+ *
* Class: jogamp_newt_driver_macosx_WindowDriver
* Method: changeContentView
* Signature: (J)J
diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m
index 5b826566b..e69f74dfb 100644
--- a/src/newt/native/NewtMacWindow.m
+++ b/src/newt/native/NewtMacWindow.m
@@ -107,6 +107,7 @@ static jmethodID windowRepaintID = NULL;
- (id)initWithFrame:(NSRect)frameRect
{
+ id res = [super initWithFrame:frameRect];
javaWindowObject = NULL;
jvmHandle = NULL;
@@ -129,28 +130,35 @@ static jmethodID windowRepaintID = NULL;
*/
myCursor = NULL;
- return [super initWithFrame:frameRect];
+ DBG_PRINT("NewtView::create: %p (refcnt %d)\n", res, (int)[res retainCount]);
+ return res;
}
- (void) release
{
+ DBG_PRINT("NewtView::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]);
#ifdef VERBOSE_ON
- NSLog(@"NewtView::release\n");
- NSLog(@"%@",[NSThread callStackSymbols]);
+ // NSLog(@"%@",[NSThread callStackSymbols]);
#endif
[super release];
}
- (void) dealloc
{
+ DBG_PRINT("NewtView::dealloc.0: %p (refcnt %d), ptrTrackingTag %d\n", self, (int)[self retainCount], (int)ptrTrackingTag);
if(softLocked) {
NSLog(@"NewtView::dealloc: softLock still hold @ dealloc!\n");
}
+ if(0 != ptrTrackingTag) {
+ // [self removeCursorRect: ptrRect cursor: myCursor];
+ [self removeTrackingRect: ptrTrackingTag];
+ ptrTrackingTag = 0;
+ }
pthread_mutex_destroy(&softLockSync);
#ifdef VERBOSE_ON
- NSLog(@"NewtView::dealloc\n");
- NSLog(@"%@",[NSThread callStackSymbols]);
+ //NSLog(@"%@",[NSThread callStackSymbols]);
#endif
+ DBG_PRINT("NewtView::dealloc.X: %p\n", self);
[super dealloc];
}
@@ -390,25 +398,31 @@ static jmethodID windowRepaintID = NULL;
mouseInside = NO;
cursorIsHidden = NO;
realized = YES;
+ DBG_PRINT("NewtWindow::create: %p (refcnt %d)\n", res, (int)[res retainCount]);
return res;
}
- (void) release
{
+ DBG_PRINT("NewtWindow::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]);
#ifdef VERBOSE_ON
- NSLog(@"NewtWindow::release\n");
- NSLog(@"%@",[NSThread callStackSymbols]);
+ // NSLog(@"%@",[NSThread callStackSymbols]);
#endif
[super release];
}
- (void) dealloc
{
+ DBG_PRINT("NewtWindow::dealloc.0: %p (refcnt %d)\n", self, (int)[self retainCount]);
#ifdef VERBOSE_ON
- NSLog(@"NewtWindow::dealloc\n");
- NSLog(@"%@",[NSThread callStackSymbols]);
+ // NSLog(@"%@",[NSThread callStackSymbols]);
#endif
+ NewtView* mView = (NewtView *)[self contentView];
+ if( NULL != mView ) {
+ [mView release];
+ }
[super dealloc];
+ DBG_PRINT("NewtWindow::dealloc.X: %p\n", self);
}
- (void) setUnrealized
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java
index a14364e05..ce8f9adc8 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java
@@ -50,13 +50,14 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
-import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.UITestCase;
public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
static long durationPerTest = 50;
static int addRemoveCount = 15;
- static boolean shallUseOffscreenFBOLayer = false;
+ static boolean noOnscreenTest = false;
+ static boolean noOffscreenTest = false;
static boolean shallUseOffscreenPBufferLayer = false;
static GLProfile glp;
static int width, height;
@@ -64,8 +65,8 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
@BeforeClass
public static void initClass() {
- if(GLProfile.isAvailable(GLProfile.GL2)) {
- glp = GLProfile.get(GLProfile.GL2);
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
Assert.assertNotNull(glp);
width = 640;
height = 480;
@@ -139,6 +140,7 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
{
for(int i=0; i<addRemoveOpCount; i++) {
+ System.err.println("Loop # "+i+" / "+addRemoveCount);
final GLCanvas glc = new GLCanvas(caps);
Assert.assertNotNull(glc);
if( !onscreen ) {
@@ -148,7 +150,9 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
glc.setMinimumSize(glc_sz);
glc.setPreferredSize(glc_sz);
glc.setSize(glc_sz);
- glc.addGLEventListener(new Gears());
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ glc.addGLEventListener(gears);
final JFrame[] top = new JFrame[] { null };
final Container glcCont = create(top, width, height, i);
@@ -172,11 +176,11 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
public void test01Onscreen()
throws AWTException, InterruptedException, InvocationTargetException
{
- if( shallUseOffscreenFBOLayer || shallUseOffscreenPBufferLayer || JAWTUtil.isOffscreenLayerRequired() ) {
- System.err.println("Offscreen test requested or platform requires it.");
+ if( noOnscreenTest || JAWTUtil.isOffscreenLayerRequired() ) {
+ System.err.println("No onscreen test requested or platform doesn't support onscreen rendering.");
return;
}
- GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ GLCapabilities caps = new GLCapabilities(glp);
if(shallUseOffscreenPBufferLayer) {
caps.setPBuffer(true);
caps.setOnscreen(true); // simulate normal behavior ..
@@ -188,11 +192,11 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
public void test02Offscreen()
throws AWTException, InterruptedException, InvocationTargetException
{
- if( !JAWTUtil.isOffscreenLayerSupported() ) {
- System.err.println("Platform doesn't support offscreen test.");
+ if( noOffscreenTest || !JAWTUtil.isOffscreenLayerSupported() ) {
+ System.err.println("No offscreen test requested or platform doesn't support offscreen rendering.");
return;
}
- GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ GLCapabilities caps = new GLCapabilities(glp);
if(shallUseOffscreenPBufferLayer) {
caps.setPBuffer(true);
caps.setOnscreen(true); // simulate normal behavior ..
@@ -212,8 +216,10 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
try {
addRemoveCount = Integer.parseInt(args[i]);
} catch (Exception ex) { ex.printStackTrace(); }
- } else if(args[i].equals("-layeredFBO")) {
- shallUseOffscreenFBOLayer = true;
+ } else if(args[i].equals("-noOnscreen")) {
+ noOnscreenTest = true;
+ } else if(args[i].equals("-noOffscreen")) {
+ noOffscreenTest = true;
} else if(args[i].equals("-layeredPBuffer")) {
shallUseOffscreenPBufferLayer = true;
} else if(args[i].equals("-wait")) {
@@ -224,7 +230,8 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
System.err.println("addRemoveCount "+addRemoveCount);
- System.err.println("shallUseOffscreenFBOLayer "+shallUseOffscreenFBOLayer);
+ System.err.println("noOnscreenTest "+noOnscreenTest);
+ System.err.println("noOffscreenTest "+noOffscreenTest);
System.err.println("shallUseOffscreenPBufferLayer "+shallUseOffscreenPBufferLayer);
if(waitForKey) {
UITestCase.waitForKey("Start");
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java
index d67662116..3d78943f9 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java
@@ -52,13 +52,14 @@ import org.junit.Test;
import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.UITestCase;
public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
static long durationPerTest = 50;
static int addRemoveCount = 15;
- static boolean shallUseOffscreenFBOLayer = false;
+ static boolean noOnscreenTest = false;
+ static boolean noOffscreenTest = false;
static boolean shallUseOffscreenPBufferLayer = false;
static GLProfile glp;
static int width, height;
@@ -66,8 +67,8 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
@BeforeClass
public static void initClass() {
- if(GLProfile.isAvailable(GLProfile.GL2)) {
- glp = GLProfile.get(GLProfile.GL2);
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
Assert.assertNotNull(glp);
width = 640;
height = 480;
@@ -141,8 +142,9 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
{
for(int i=0; i<addRemoveOpCount; i++) {
+ System.err.println("Loop # "+i+" / "+addRemoveCount);
final GLWindow glw = GLWindow.create(caps);
-
+ Assert.assertNotNull(glw);
final NewtCanvasAWT glc = new NewtCanvasAWT(glw);
Assert.assertNotNull(glc);
if( !onscreen ) {
@@ -152,7 +154,9 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
glc.setMinimumSize(glc_sz);
glc.setPreferredSize(glc_sz);
glc.setSize(glc_sz);
- glw.addGLEventListener(new Gears());
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ glw.addGLEventListener(gears);
final JFrame[] top = new JFrame[] { null };
final Container glcCont = create(top, width, height, i);
@@ -177,11 +181,11 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
public void test01Onscreen()
throws AWTException, InterruptedException, InvocationTargetException
{
- if( shallUseOffscreenFBOLayer || shallUseOffscreenPBufferLayer || JAWTUtil.isOffscreenLayerRequired() ) {
- System.err.println("Offscreen test requested or platform requires it.");
+ if( noOnscreenTest || JAWTUtil.isOffscreenLayerRequired() ) {
+ System.err.println("No onscreen test requested or platform doesn't support onscreen rendering.");
return;
}
- GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ GLCapabilities caps = new GLCapabilities(glp);
if(shallUseOffscreenPBufferLayer) {
caps.setPBuffer(true);
caps.setOnscreen(true); // simulate normal behavior ..
@@ -193,11 +197,11 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
public void test02Offscreen()
throws AWTException, InterruptedException, InvocationTargetException
{
- if( !JAWTUtil.isOffscreenLayerSupported() ) {
- System.err.println("Platform doesn't support offscreen test.");
+ if( noOffscreenTest || !JAWTUtil.isOffscreenLayerSupported() ) {
+ System.err.println("No offscreen test requested or platform doesn't support offscreen rendering.");
return;
}
- GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ GLCapabilities caps = new GLCapabilities(glp);
if(shallUseOffscreenPBufferLayer) {
caps.setPBuffer(true);
caps.setOnscreen(true); // simulate normal behavior ..
@@ -217,8 +221,10 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
try {
addRemoveCount = Integer.parseInt(args[i]);
} catch (Exception ex) { ex.printStackTrace(); }
- } else if(args[i].equals("-layeredFBO")) {
- shallUseOffscreenFBOLayer = true;
+ } else if(args[i].equals("-noOnscreen")) {
+ noOnscreenTest = true;
+ } else if(args[i].equals("-noOffscreen")) {
+ noOffscreenTest = true;
} else if(args[i].equals("-layeredPBuffer")) {
shallUseOffscreenPBufferLayer = true;
} else if(args[i].equals("-wait")) {
@@ -229,7 +235,8 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
System.err.println("addRemoveCount "+addRemoveCount);
- System.err.println("shallUseOffscreenFBOLayer "+shallUseOffscreenFBOLayer);
+ System.err.println("noOnscreenTest "+noOnscreenTest);
+ System.err.println("noOffscreenTest "+noOffscreenTest);
System.err.println("shallUseOffscreenPBufferLayer "+shallUseOffscreenPBufferLayer);
if(waitForKey) {
UITestCase.waitForKey("Start");
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove03GLWindowNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove03GLWindowNEWT.java
new file mode 100644
index 000000000..9d7a4026b
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove03GLWindowNEWT.java
@@ -0,0 +1,130 @@
+/**
+ * Copyright 2013 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+public class TestAddRemove03GLWindowNEWT extends UITestCase {
+ static long durationPerTest = 50;
+ static int addRemoveCount = 15;
+ static GLProfile glp;
+ static int width, height;
+ static boolean waitForKey = false;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
+ Assert.assertNotNull(glp);
+ width = 640;
+ height = 480;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ }
+
+ protected void runTestGL(GLCapabilities caps, int addRemoveOpCount)
+ throws InterruptedException, InvocationTargetException
+ {
+
+ for(int i=0; i<addRemoveOpCount; i++) {
+ System.err.println("Loop # "+i+" / "+addRemoveCount);
+ final GLWindow glw = GLWindow.create(caps);
+ Assert.assertNotNull(glw);
+ glw.setTitle("GLWindow #"+i);
+ glw.setSize(width, height);
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ glw.addGLEventListener(gears);
+
+ glw.setVisible(true);
+
+ final long t0 = System.currentTimeMillis();
+ do {
+ glw.display();
+ Thread.sleep(10);
+ } while ( ( System.currentTimeMillis() - t0 ) < durationPerTest ) ;
+
+ System.err.println("GLWindow: "+glw.getChosenGLCapabilities());
+
+ glw.destroy();
+ }
+ }
+
+ @Test
+ public void test01Onscreen()
+ throws InterruptedException, InvocationTargetException
+ {
+ GLCapabilities caps = new GLCapabilities(glp);
+ runTestGL(caps, addRemoveCount);
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ durationPerTest = Long.parseLong(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-loops")) {
+ i++;
+ try {
+ addRemoveCount = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-wait")) {
+ waitForKey = true;
+ }
+ }
+ System.err.println("waitForKey "+waitForKey);
+
+ System.err.println("addRemoveCount "+addRemoveCount);
+
+ if(waitForKey) {
+ UITestCase.waitForKey("Start");
+ }
+ org.junit.runner.JUnitCore.main(TestAddRemove03GLWindowNEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java
index f2fae293b..52fa83b65 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java
@@ -172,7 +172,9 @@ public class TestBug664GLCanvasSetVisibleSwingAWT extends UITestCase {
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
});
- glc.addGLEventListener(new GearsES2());
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ glc.addGLEventListener(gears);
final JFrame[] top = new JFrame[] { null };
final Container glcCont = create(top, width, height, i);