From 4eeddd0d446f8491dde2e5b0e3e11e0d5b0be9b7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 28 Jul 2015 00:37:53 +0200 Subject: Bug 1161 - Fix Canvas resize stops the rendering in Mac OS X (mostly from WebStart) Root cause: JAWTWindow's JAWTComponentListener 'isShowing' state is initialized while attaching it on-thread and updated via hierarchy-changed event. JAWTComponentListener attachment to the component is issued at JAWTWindow's creation but on the AWT-EDT, hence it may happen at a later time. In this bug scenario, it happens very late, so that the hierarchy-changed event is missed and 'isShowing' is never set to 'true'. Solution is to update 'isShowing' state on the actual AWT-EDT when attaching to the component. Also make 'isShowing' volatile. --- src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nativewindow/classes') diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 3eece0759..294e57bd3 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -137,7 +137,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, private String jawtStr() { return "JAWTWindow["+id(JAWTWindow.this)+"]"; } private class JAWTComponentListener implements ComponentListener, HierarchyListener { - private boolean isShowing; + private volatile boolean isShowing; private String str(final Object obj) { if( null == obj ) { @@ -178,6 +178,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, AWTEDTExecutor.singleton.invoke(false, new Runnable() { // Bug 952: Avoid deadlock via AWTTreeLock acquisition .. @Override public void run() { + isShowing = component.isShowing(); // Bug 1161: Runnable might be deferred, hence need to update if(DEBUG) { System.err.println(jawtStr()+".attach @ Thread "+getThreadName()+": "+JAWTComponentListener.this.toString()); } @@ -247,7 +248,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, final java.awt.Component changed = e.getChanged(); final boolean displayable = changed.isDisplayable(); final boolean showing = changed.isShowing(); - System.err.println(jawtStr()+".hierarchyChanged: action "+action+", displayable "+displayable+", showing [changed "+showing+", comp "+isShowing+"], "+s(e)); + System.err.println(jawtStr()+".hierarchyChanged: action "+action+", displayable "+displayable+", showing [changed "+showing+", comp "+wasShowing+" -> "+isShowing+"], "+s(e)); } } } -- cgit v1.2.3