Bug 924 - NewtCanvasAWT XEventsQueued crash during reparent of undecorated fullscreen window
Summary: NewtCanvasAWT XEventsQueued crash during reparent of undecorated fullscreen w...
Status: RESOLVED FIXED
Alias: None
Product: Newt
Classification: JogAmp
Component: x11 (show other bugs)
Version: 1
Hardware: All all
: --- enhancement
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2013-12-13 14:57 CET by Xerxes Rånby
Modified: 2013-12-20 17:08 CET (History)
0 users

See Also:
Type: ---
SCM Refs:
008366fd591c9fce31e7185528b606a8205a38f8 c9fcc8cd510abc0cbebb872dc3e457327655e778 b4e03a5168f62223369a483924eb2491250c6f95 0e1b4bf1b17b10933c3ccdfea5cef7eca6aad2fb 9b2bbaf82ed410096ac279542357daefc0d6dc7f e217858a83f947ffdd7e4ce3395073584e57108a 0f1ddc82329835b903e31e301fcf134d1d7337be c8726ef04b94ad8e66e1191a06ff793b908d130c ded0a8fb68067e3dbb42ff4f6fce315a237afa8f
Workaround: TRUE


Attachments
NewtCanvasAWT-XEventsQueued-debug-crash-log.txt (584.81 KB, text/plain)
2013-12-13 14:57 CET, Xerxes Rånby
Details
hs_err_pid13015.log (82.93 KB, text/plain)
2013-12-13 14:59 CET, Xerxes Rånby
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xerxes Rånby 2013-12-13 14:57:48 CET
Created attachment 568 [details]
NewtCanvasAWT-XEventsQueued-debug-crash-log.txt

Steps to reproduce:
#2.1.3 rc
_JAVA_OPTIONS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" firefox http://jogamp.org/deployment/archive/master/gluegen_753-joal_504-jogl_1170-jocl_887-signed/jogl-applet-runner-newt-gears-normal-napplet.html

#2.1.2 alternative using jogl-demos:
_JAVA_OPTIONS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" firefox http://jogamp.org/deployment/jogamp-current/jogl-demos/jogl-newt-applet-runner-angelesgl2es1.html

press the keys in the following order:
f d r r
-> crash
 
Ubuntu 12.04 i386
 
GL_VENDOR NVIDIA Corporation
GL_RENDERER GeForce GT 610/PCIe/SSE2
GL_VERSION 4.3.0 NVIDIA 319.32
 
IcedTea-Web Plugin (using IcedTea-Web 1.5pre+rd93aaf41548e)
 
Fil: IcedTeaPlugin.so
Sökväg: /usr/local/lib/IcedTeaPlugin.so
Version:
Status: Aktiverad
The IcedTea-Web Plugin executes Java applets.
vm_info: OpenJDK Server VM (23.7-b01) for linux-x86 JRE (1.7.0_25-b30), built on Jul 15 2013 20:45:25 by "buildd" with gcc 4.6.3

Crash log attached.
Comment 1 Xerxes Rånby 2013-12-13 14:59:18 CET
Created attachment 569 [details]
hs_err_pid13015.log
Comment 2 Xerxes Rånby 2013-12-13 15:01:37 CET
Some runs triggers an Nativewindow X11 IOError exception "Resource temporary unavailable" instead of crashing.

...
LAutoDrawableBase.sizeChanged: (NetxPanelThread@http://jogamp.org/deployment/archive/master/gluegen_753-joal_504-jogl_1170-jocl_887-signed/jogl-applet-runner-newt-gears-normal-napplet.html-Display-.x11_:0-1-EDT-3): 1920x1080 - surfaceHandle 0x5c00002
Window.focusAction() START - NetxPanelThread@http://jogamp.org/deployment/archive/master/gluegen_753-joal_504-jogl_1170-jocl_887-signed/jogl-applet-runner-newt-gears-normal-napplet.html-Display-.x11_:0-1-EDT-3, focusAction: com.jogamp.newt.awt.NewtCanvasAWT$FocusAction@13ac7b2 - windowHandle 0x5c00002
NewtCanvasAWT.FocusAction: NetxPanelThread@http://jogamp.org/deployment/archive/master/gluegen_753-joal_504-jogl_1170-jocl_887-signed/jogl-applet-runner-newt-gears-normal-napplet.html-Display-.x11_:0-1-EDT-3, isOnscreen true, hasFocus false, isParent true, isFS false
Window.focusAction() END - NetxPanelThread@http://jogamp.org/deployment/archive/master/gluegen_753-joal_504-jogl_1170-jocl_887-signed/jogl-applet-runner-newt-gears-normal-napplet.html-Display-.x11_:0-1-EDT-3, focusAction: com.jogamp.newt.awt.NewtCanvasAWT$FocusAction@13ac7b2 - windowHandle 0x5c00002, res: false
Window.RequestFocusInt: forcing - (NetxPanelThread@http://jogamp.org/deployment/archive/master/gluegen_753-joal_504-jogl_1170-jocl_887-signed/jogl-applet-runner-newt-gears-normal-napplet.html-Display-.x11_:0-1-EDT-3): skipFocusAction false, focus true -> true - windowHandle 0x5c00002 parentWindowHandle 0x4e00022
Window.reparent: END-X (NetxPanelThread@http://jogamp.org/deployment/archive/master/gluegen_753-joal_504-jogl_1170-jocl_887-signed/jogl-applet-runner-newt-gears-normal-napplet.html-Display-.x11_:0-1-EDT-2) windowHandle 0x5c00002, visible: true, parentWindowHandle 0x4e00022, parentWindow 27807950 32/32 1920x1080
consumeKeyEvent(usr): KeyEvent[EVENT_KEY_PRESSED, code 0x52, sym 0x52, char 'r' (0x72), printable true, modifier false, action false, InputEvent[modifiers: [], NEWTEvent[source:jogamp.newt.driver.x11.WindowDriver, consumed false, when:1386942403611 d 1448ms]]], consumed: false
Nativewindow X11 IOError: Display 0x9cd07c8 (:0): Resursen tillfälligt otillgänglig
Nativewindow X11 IOError: Display 0x9cd07c8 (:0): Resursen tillfälligt otillgänglig
FATAL ERROR in native method: Nativewindow X11 IOError: Display 0x9cd07c8 (:0): Resursen tillfälligt otillgänglig
	at jogamp.newt.driver.x11.DisplayDriver.DispatchMessages0(Native Method)
	at jogamp.newt.driver.x11.DisplayDriver.dispatchMessagesNative(DisplayDriver.java:107)
	at jogamp.newt.DisplayImpl.dispatchMessages(DisplayImpl.java:540)
	at jogamp.newt.DisplayImpl$5.run(DisplayImpl.java:463)
	at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:326)
Comment 3 Xerxes Rånby 2013-12-17 12:40:07 CET
#This bug is still reproducible using 2.1.3
_JAVA_OPTIONS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" firefox http://jogamp.org/deployment/jogamp-current/jogl-applet-runner-newt-gears-normal-napplet.html

press the keys in the following order:
f d r r
-> crash

Reading symbols from /tmp/jogamp_0000/file_cache/jln2887950668522298898
/jln9052652992330954465/libnewt.so...(no debugging symbols found)...done.

Need to recompile the jogamp natives with debug symbols enabled in order to produce a gdb backtrace.
Comment 4 Sven Gothel 2013-12-18 22:25:47 CET
Cannot reproduce on Debian Jessie, 64bit, X11+NV and 
icedtea-web 1.3.2-1; 
1.7.0_21 (1.7.0u21), VM: OpenJDK 64-Bit; 
OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-5)
Comment 5 Sven Gothel 2013-12-18 22:45:13 CET
Ubuntu 13.10 64bit:

(10:41:22 PM) sgothel: same version here .. Mesa/Intel
(10:41:31 PM) sgothel: fast 'fdrr' no crash
(10:42:30 PM) sgothel: java version "1.7.0_25"
(10:42:30 PM) sgothel: OpenJDK Runtime Environment (IcedTea 2.3.12) (7u25-2.3.12-4ubuntu3)
(10:42:30 PM) sgothel: OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
(10:42:46 PM) sgothel: Picked up _JAVA_OPTIONS: -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all
(10:42:54 PM) sgothel: jogl-applet-runner-newt-gears-normal-napplet.html
(10:43:13 PM) sgothel: 32Bit false

firefox version 26.0

WM: Kwin (KDE)
Comment 6 Sven Gothel 2013-12-18 22:54:09 CET
(In reply to comment #5)
> Ubuntu 13.10 64bit:
> 
> (10:41:22 PM) sgothel: same version here .. Mesa/Intel
> (10:41:31 PM) sgothel: fast 'fdrr' no crash
> (10:42:30 PM) sgothel: java version "1.7.0_25"
> (10:42:30 PM) sgothel: OpenJDK Runtime Environment (IcedTea 2.3.12)
> (7u25-2.3.12-4ubuntu3)
> (10:42:30 PM) sgothel: OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
> (10:42:46 PM) sgothel: Picked up _JAVA_OPTIONS: -Dnativewindow.debug=all
> -Djogl.debug=all -Dnewt.debug=all
> (10:42:54 PM) sgothel: jogl-applet-runner-newt-gears-normal-napplet.html
> (10:43:13 PM) sgothel: 32Bit false
> 
> firefox version 26.0
> 
> WM: Kwin (KDE)

WM: 'Unity' produces the issue!
Comment 7 Sven Gothel 2013-12-18 23:18:52 CET
(11:09:57 PM) sgothel: TestGearsES2NewtCanvasAWT + [KWin, Unity] + Mesa-Soft: OK
(11:10:33 PM) sgothel: TestGearsES2NewtCanvasAWT + [KWin, Unity] + Mesa-Intel: BadDrawable (GLX.dispatch_glXSwapBuffers0)
(11:12:13 PM) sgothel: Plugin + Unity + Mesa-Soft: Crash (dispatch)
(11:12:19 PM) sgothel: Plugin + KWin + Mesa-Soft: OK!
(11:12:48 PM) sgothel: So the only surprising thing for me here is: 
    TestGearsES2NewtCanvasAWT + KWin + Mesa-Intel: BadDrawable (GLX.dispatch_glXSwapBuffers0)

Mesa-Soft via:
  export LIBGL_ALWAYS_SOFTWARE=true
Comment 8 Sven Gothel 2013-12-18 23:54:07 CET
Ubuntu 13.10 - 'dist-upgrade' to latest at time of writing ..

> Mesa-Soft via:
>   export LIBGL_ALWAYS_SOFTWARE=true

TestGearsES2NewtCanvasAWT + KWin-[GL/No] + Mesa-Soft: OK
=================================

TestGearsES2NewtCanvasAWT + KWin-[GL/No] + Mesa-Intel: Buggy
====================================
Info: Nativewindow X11 Error: 9 - BadDrawable (invalid Pixmap or Window parameter), dpy 0x7fa1f400e950, id 4800002, # 14595: 152:8 Unknown
java.lang.Exception: Stack trace
        at java.lang.Thread.dumpStack(Unknown Source)
        at jogamp.nativewindow.x11.X11Util.dumpStack(X11Util.java:618)
        at jogamp.opengl.x11.glx.GLX.dispatch_glXSwapBuffers0(Native Method)
        at jogamp.opengl.x11.glx.GLX.glXSwapBuffers(GLX.java:943)

Plugin + KWin-GL + Mesa-Soft: OK!
=======================

Plugin + KWin-GL + Mesa-Intel: OK!
=======================
(after upgrade)
Comment 9 Sven Gothel 2013-12-18 23:57:24 CET
Unity + Plugin + Mesa/Intel:
  FS toggle: OK
  Reparent toggle: Crash

java.lang.Exception: Stack trace
# An error report file with more information is saved as:
# /home/jogamp/bin/hs_err_pid4903.log
        at java.lang.Thread.dumpStack(Thread.java:1344)
        at jogamp.nativewindow.x11.X11Util.dumpStack(X11Util.java:618)
        at jogamp.opengl.x11.glx.GLX.dispatch_glXSwapBuffers0(Native Method)
        at jogamp.opengl.x11.glx.GLX.glXSwapBuffers(GLX.java:943)
        at jogamp.opengl.x11.glx.X11GLXDrawable.swapBuffersImpl(X11GLXDrawable.java:74)

^^ Above works fine w/ KWin !
Comment 10 Sven Gothel 2013-12-18 23:58:32 CET
Simple partial remedy (as far as we can go):

Disable 'reparent action' while in fullscreen mode!

Other than that: Bug on behalf of 'Unity WM' and Mesa/Intel.
Comment 11 Sven Gothel 2013-12-19 00:00:59 CET
(In reply to comment #9)
> Unity + Plugin + Mesa/Intel:
>   FS toggle: OK
>   Reparent toggle: Crash

To be correct:

Crash after: ffr

i.e. reparent action fails after fullscreen action in+out _and_ subsequent reparent.

> 
> java.lang.Exception: Stack trace
> # An error report file with more information is saved as:
> # /home/jogamp/bin/hs_err_pid4903.log
>         at java.lang.Thread.dumpStack(Thread.java:1344)
>         at jogamp.nativewindow.x11.X11Util.dumpStack(X11Util.java:618)
>         at jogamp.opengl.x11.glx.GLX.dispatch_glXSwapBuffers0(Native Method)
>         at jogamp.opengl.x11.glx.GLX.glXSwapBuffers(GLX.java:943)
>         at
> jogamp.opengl.x11.glx.X11GLXDrawable.swapBuffersImpl(X11GLXDrawable.java:74)
> 
> ^^ Above works fine w/ KWin !
Comment 12 Sven Gothel 2013-12-19 08:38:10 CET
Window.reparent: START (main-Display-.x11_:0.0-1-EDT-1) valid true, windowHandle 0x4c00002 parentWindowHandle 0x4400011, visible true, becomesVisible true, forceDestroyCreate false, DEBUG_TEST_REPARENT_INCOMPATIBLE false, HINT_FORCE_RECREATION false, HINT_BECOMES_VISIBLE false, old parentWindow: 1224577418, new parentWindow: 0
Window.reparent: ACTION (main-Display-.x11_:0.0-1-EDT-1) windowHandle 0x4c00002 new parentWindowHandle 0x0, reparentAction ACTION_NATIVE_REPARENTING, pos/size 708/52 640x480, visible true
X11Window reconfig: 708/52 640x480, [*PARENT false, FS false[span false], *UNDECOR false, ALWAYSONTOP false, VISIBLE true]
X11: reconfigureWindow0 dpy 0x7f8e9c008670, scrn 0, parent (nil)/0x8f, win 0x4c00002, 708/52 640x480, parentChange 1, hasParent 0, decorationChange 1, undecorated 0, fullscreenChange 0, fullscreen 0 (span 0), alwaysOnTopChange 0, alwaysOnTop 0, visibleChange 0, visible 1, tempInvisible 1, fsEWMHFlags 0
X11: reconfigureWindow0 TEMP VISIBLE OFF
X11: reconfigureWindow0 PARENTING in->out
X11.WaitForReparentNotify: Event 0xA: Result 0, exp 0x4c00002, has (nil)
Unity WM Reparent after 'Fullscreen On + Off':

1 - fullscreen on
  - Size: 640x480 -> 1920x1080 OK

2 - fullscreen off
  - Size: 1920x1080 -> 640x480 OK

3 - attempt to perform native reparent
  - 3.1 Size-1: 640x480 -> 640x480 OK
  - 3.2 Size-2: 640x480 -> 1920x1080 ERROR!
  - 3.3 fails due to WM claims size is fullscreen -> reparent via recreate -> XID BadDrawable

3) Log
X11.WaitForReparentNotify: Event ReparentNotify: Result 1, exp 0x4c00002, has 0x4c00002
Window.windowRepaint AWT-EventQueue-0 (defer: false) 0/0 640x480
X11: reconfigureWindow0 DECORATIONS 1
X11: reconfigureWindow0 setPosSize 708/52 640x480
X11: reconfigureWindow0 TEMP VISIBLE ON
X11: reconfigureWindow0 X (full)
definePosition: 0/0 -> 708/52
X11: event . FocusOut call 0x4c00002
Window.focusChanged: (main-Display-.x11_:0.0-1-EDT-1): (defer: false) true -> false - windowHandle 0x4c00002 parentWindowHandle 0x0
consumeWindowEvent: WindowEvent[EVENT_WINDOW_LOST_FOCUS, NEWTEvent[source:jogamp.newt.driver.x11.WindowDriver, consumed false, when:1387437953156 d 0ms]], visible true 708/52 640x480
X11: event . ReparentNotify: call 0/0 OldParent 0x4c00002 (root 0x8f, top 0x1c08040), NewParent 0x1c08040 (root 0x8f, top 0x1c0803f), Window 0x4c00002 (root 0x8f, top 0x1c08040)
Window.reparentNotify (main-Display-.x11_:0.0-1-EDT-1): 0x0 -> 0x1c08040

3.1) Log OK

X11: event . ConfigureNotify call 0x4c00002 (parent 0x4c00002, above (nil)) 708/52 640x480 0, child-event: 0
NewtWindows_updateInsets: insets by _NET_FRAME_EXTENTS [ l 0, r 0, t 0, b 0 ]

3.2) Log ERROR

X11: event . ConfigureNotify call 0x4c00002 (parent 0x4c00002, above (nil)) 0/0 1920x1200 0, child-event: 0
NewtWindows_updateInsets: insets by _NET_FRAME_EXTENTS [ l 0, r 0, t 0, b 0 ]
Window.sizeChanged: (main-Display-.x11_:0.0-1-EDT-1): (defer: false) force false, 640x480 -> 1920x1200 - windowHandle 0x4c00002 parentWindowHandle 0x0
defineSize: 640x480 -> 1920x1200

??
Comment 13 Sven Gothel 2013-12-19 12:35:29 CET
xwininfo reveils that the window reparented to TOP after fullscreen on and off ops (ffr) state is:
      Window state:
          Fullscreen
          Above
          Focused

where it shall only be:
      Window state:
          Focused

hence the 'fullscreen off' operation, while window is invisible,
didn't took the states away. 
This is performed via _NET_WM_STATE -> 'root window'
with data: _NET_WM_STATE_REMOVE, _NET_WM_STATE_FULLSCREEN, _NET_WM_STATE_ABOVE,
which works well w/ all other WMs as tested so far (KWin, *box, ..).

Remedy:
  - Reparent Child -> TOP: Reset _NET_WM_STATE (! _NET_WM_STATE_FULLSCREEN, ..)
  - Don't derive reparent success from successful position, 
    WM's only regard custom position as a hint (X11).
Comment 14 Sven Gothel 2013-12-19 13:04:41 CET
c9fcc8cd510abc0cbebb872dc3e457327655e778
   Fix 'Unity WM' issue w/ sticky _NET_WM_STATE after Fullscreen On/Off Cycle

b4e03a5168f62223369a483924eb2491250c6f95
   Ignore reparent when in fullscreen - otherwise may confuse WM

0e1b4bf1b17b10933c3ccdfea5cef7eca6aad2fb
   X11 WindowDriver: Only perform 'tempFSAlwaysOnTop' toggle @ focusChanged(..) if isFullscreen()

9b2bbaf82ed410096ac279542357daefc0d6dc7f
   Remove position criteria from reparent/fullscreen success, WM's only regard custom position as a hint (X11).

0f1ddc82329835b903e31e301fcf134d1d7337be
   More robost Fullscreen Exit
    
    - 'tempInvisible' shall be also performed for top windows, solves Unity-WM background refresh issue
    
    - Rename local field 'fullscreen' -> '_fullscreen' to avoid confusion
    
    - Proper insets handling: Set 'WindowImpl.this.fullscreen = _fullscreen' only before reconfiguring,
      otherwise wrong position maybe used due to wrong insets value.
    
    Tested w/ WMs: KWin + Unity
Comment 15 Sven Gothel 2013-12-19 18:56:19 CET
Reopened:
  - X11 Fullscreen ALT-TAB regression (no task-switcher visible)
  - ALWAYS_ON_TOP not persistent when child -> top
Comment 16 Sven Gothel 2013-12-19 19:19:19 CET
c8726ef04b94ad8e66e1191a06ff793b908d130c

    - X11 Fullscreen ALT-TAB regression (no task-switcher visible)
      We still need the fast reconfigure path for ALWAYSONTOP only toggle.
      It was removed w/ commit c9fcc8cd510abc0cbebb872dc3e457327655e778,
      which disabled toggling FULLSCREEN and ALWAYSONTOP.
    
      Note: Another bug in Unity WM's Compiz:
        'Unredirect Fullscreen Windows := True' disables
        the ALT-TAB taskbar/launcher HUD rendering and subsequent task-switch.
        Hence it shall be disabled .. nothing we can do here.
    
    - ALWAYS_ON_TOP not persistent when child -> top
      WM removes ALWAYS_ON_TOP state when reparenting,
      hence reinforce it when Child -> Top.
Comment 17 Sven Gothel 2013-12-20 17:08:45 CET
ded0a8fb68067e3dbb42ff4f6fce315a237afa8f
  Fullscreen toggle in X11 requires a 'sleep' on sluggish WMs (Unity) ; 
  Block insets change while toggling fullscreen mode.