Bug 836

Summary: Exiting full screen issues a reshape back to the full screen resolution.
Product: [JogAmp] Jogl Reporter: andrei <arya.darc>
Component: x11Assignee: Sven Gothel <sgothel>
Status: RESOLVED FIXED    
Severity: normal CC: arya.darc, johan
Priority: ---    
Version: 2   
Hardware: pc_x86_64   
OS: linux   
Type: --- SCM Refs:
929cae9a5ba01a382d17387ff289d74ee029f090 c2a4905ec926362a08f486a68d428fb139821df1 88291cd5e20fc8b172f1d78a683be7d2bdec807a 56502090ba5c2e0c266666a4ba3ddd501e9ad95f 8be1fc983e584082b9960b4da19c56af5834d08e
Workaround: ---
Attachments: test.log from running etc/test.sh
test_dbg.log from running etc/test_dbg.sh
Image showing behavior in TestGearsES2NewtCanvasAWT.java

Description andrei 2013-09-13 10:04:35 CEST
Hey,

as in the forum explained, there is a problem when exiting full screen (using NEWT and Swing). After exiting full screen by calling glWindow.setFullscreen(false), two instead of one reshapes are issued. The first one sets the application back to the windowed resolution, the second one however sets back to full screen resolution. The JFrame used stays windowed, but the viewport is set to the full screen resolution and cut off. See the attached image from TestGearsES2NewtCanvasAWT.java.

Here is a JUnit test showing the behavior: https://github.com/arya-s/JOGLStuff/blob/master/src/tests/JOGLFullscreenTest.java
Comment 1 andrei 2013-09-13 10:05:37 CEST
Created attachment 502 [details]
test.log from running etc/test.sh
Comment 2 andrei 2013-09-13 10:06:16 CEST
Created attachment 503 [details]
test_dbg.log from running etc/test_dbg.sh
Comment 3 andrei 2013-09-13 10:07:24 CEST
Created attachment 504 [details]
Image showing behavior in TestGearsES2NewtCanvasAWT.java
Comment 4 andrei 2013-09-18 05:58:28 CEST
I noticed this bug does not exist on my Windows machine.
Comment 5 johan 2013-09-30 20:58:18 CEST
I rewrote the unit test as a plain JUNit and ran it on my OSX 10.8 with JDK 1.7_40 (AMD Radeon HD 6770M 1024 MB), using an external monitor as primary monitor.
The window appear (on the external primary monitor), the test switches to fullscreen OK, then switches back to window mode. The window shortly appears in a new place on the screen but looks to be the same size as originally but then crashes very quickly (looks like less than a second)

Testsuite: fullscreentest.FullScreenTest
Reshape issued by Thread[main-AWTAnimator,5,main]: 640x458
Reshape issued by Thread[main-AWTAnimator,5,main]: 640x458
Reshape issued by Thread[main-AWTAnimator,5,main]: 640x458
Pre-fullscreen dimension: 640x458
Reshape issued by Thread[main-Display-.macosx_nil-1-EDT-1,5,main]: 640x458
Reshape issued by Thread[main-AWTAnimator,5,main]: 640x458
Reshape issued by Thread[main-AWTAnimator,5,main]: 1920x1200
Entered fullscreen.
Reshape issued by Thread[main-AWTAnimator,5,main]: 640x458
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fff8985f250, pid=5519, tid=1799
#
# JRE version: Java(TM) SE Runtime Environment (7.0_40-b43) (build 1.7.0_40-b43)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.0-b56 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libobjc.A.dylib+0x6250]  objc_msgSend+0x10


Stack: [0x00007fff5528e000,0x00007fff55a8e000],  sp=0x00007fff55a88d80,  free space=8171k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libobjc.A.dylib+0x6250]  objc_msgSend+0x10
C  [libnewt.jnilib+0x49c0]  Java_jogamp_newt_driver_macosx_WindowDriver_initWindow0+0x740
j  jogamp.newt.driver.macosx.WindowDriver.initWindow0(JJIIIIZZZJ)V+0
j  jogamp.newt.driver.macosx.WindowDriver.access$1400(Ljogamp/newt/driver/macosx/WindowDriver;JJIIIIZZZJ)V+19
j  jogamp.newt.driver.macosx.WindowDriver$12.run()V+72
j  com.jogamp.common.util.RunnableTask.run()V+24
v  ~StubRoutines::call_stub
V  [libjvm.dylib+0x2d6740]  JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*)+0x22a
V  [libjvm.dylib+0x2d6510]  JavaCalls::call(JavaValue*, methodHandle, JavaCallArguments*, Thread*)+0x28
V  [libjvm.dylib+0x309e1d]  jni_invoke_nonstatic(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*)+0x2ba
V  [libjvm.dylib+0x2fd98e]  jni_CallVoidMethod+0x116
C  [libnativewindow_macosx.jnilib+0x49fd]  Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_UnsetJAWTRootSurfaceLayer0+0x38d
C  [Foundation+0x935ca]  __NSThreadPerformPerform+0xe1
C  [CoreFoundation+0x12b31]  __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+0x11
C  [CoreFoundation+0x1251d]  __CFRunLoopDoSources0+0x1bd
C  [CoreFoundation+0x357f5]  __CFRunLoopRun+0x315
C  [CoreFoundation+0x350e2]  CFRunLoopRunSpecific+0x122
C  [HIToolbox+0x5feb4]  RunCurrentEventLoopInMode+0xd1
C  [HIToolbox+0x5fb94]  ReceiveNextEventCommon+0xa6
C  [HIToolbox+0x5fae3]  BlockUntilNextEventMatchingListInMode+0x3e
C  [AppKit+0x155533]  _DPSNextEvent+0x2ad
C  [AppKit+0x154df2]  -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]+0x80
C  [libosxapp.dylib+0x16f4]  -[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:]+0x7c
C  [AppKit+0x14c1a3]  -[NSApplication run]+0x205
C  [libosxapp.dylib+0x1557]  +[NSApplicationAWT runAWTLoopWithApp:]+0x9c
C  [liblwawt.dylib+0xdb99]  -[AWTStarter starter:]+0x369
C  [Foundation+0x935ca]  __NSThreadPerformPerform+0xe1
C  [CoreFoundation+0x12b31]  __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+0x11
C  [CoreFoundation+0x12455]  __CFRunLoopDoSources0+0xf5
C  [CoreFoundation+0x357f5]  __CFRunLoopRun+0x315
C  [CoreFoundation+0x350e2]  CFRunLoopRunSpecific+0x122
C  [java+0x73b0]  CreateExecutionEnvironment+0x367
C  [java+0x1b5c]  JLI_Launch+0x7a0
C  [java+0x770d]  main+0x65
C  [java+0x13b4]  start+0x34

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  jogamp.newt.driver.macosx.WindowDriver.initWindow0(JJIIIIZZZJ)V+0
j  jogamp.newt.driver.macosx.WindowDriver.access$1400(Ljogamp/newt/driver/macosx/WindowDriver;JJIIIIZZZJ)V+19
j  jogamp.newt.driver.macosx.WindowDriver$12.run()V+72
j  com.jogamp.common.util.RunnableTask.run()V+24
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x00007fa8bac25800 JavaThread "Thread-3" daemon [_thread_in_native, id=46595, stack(0x000000019fab5000,0x000000019fb35000)]
  0x00007fa8bd016800 JavaThread "main-Display-.macosx_nil-1-EDT-2" daemon [_thread_in_native, id=63239, stack(0x00000001a2021000,0x00000001a2121000)]
  0x00007fa8b91d5800 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=52227, stack(0x00000001a1247000,0x00000001a1347000)]
  0x00007fa8ba96e800 JavaThread "Java2D Queue Flusher" daemon [_thread_blocked, id=50455, stack(0x00000001a111c000,0x00000001a121c000)]
  0x00007fa8ba803800 JavaThread "main-AWTAnimator" [_thread_blocked, id=49215, stack(0x00000001a0e07000,0x00000001a0f07000)]
  0x00007fa8bd046000 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=34831, stack(0x000000019fbee000,0x000000019fcee000)]
  0x00007fa8bd03f800 JavaThread "AWT-Shutdown" [_thread_blocked, id=33539, stack(0x000000019c98e000,0x000000019ca8e000)]
=>0x00007fa8bb025000 JavaThread "AWT-AppKit" daemon [_thread_in_native, id=1799, stack(0x00007fff5528e000,0x00007fff55a8e000)]
  0x00007fa8b912d800 JavaThread "process reaper" daemon [_thread_blocked, id=26119, stack(0x000000019b2b7000,0x000000019b2df000)]
  0x00007fa8b9020000 JavaThread "Service Thread" daemon [_thread_blocked, id=25091, stack(0x000000019ae9b000,0x000000019af9b000)]
  0x00007fa8b901f000 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=24579, stack(0x000000019ad98000,0x000000019ae98000)]
  0x00007fa8ba053000 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=24067, stack(0x000000019ac95000,0x000000019ad95000)]
  0x00007fa8ba04a000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=23555, stack(0x000000019ab92000,0x000000019ac92000)]
  0x00007fa8ba045800 JavaThread "Finalizer" daemon [_thread_blocked, id=18947, stack(0x000000019a943000,0x000000019aa43000)]
  0x00007fa8ba042800 JavaThread "Reference Handler" daemon [_thread_blocked, id=18435, stack(0x000000019a840000,0x000000019a940000)]
  0x00007fa8bb000000 JavaThread "main" [_thread_blocked, id=6403, stack(0x000000010acf2000,0x000000010adf2000)]
Comment 6 andrei 2013-10-02 10:08:33 CEST
Forum thread mentioned: http://forum.jogamp.org/Exiting-Fullscreen-in-TestGearsES2NewtCanvasAWT-java-td4030008.html

(In reply to comment #0)
> Hey,
> 
> as in the forum explained, there is a problem when exiting full screen
> (using NEWT and Swing). After exiting full screen by calling
> glWindow.setFullscreen(false), two instead of one reshapes are issued. The
> first one sets the application back to the windowed resolution, the second
> one however sets back to full screen resolution. The JFrame used stays
> windowed, but the viewport is set to the full screen resolution and cut off.
> See the attached image from TestGearsES2NewtCanvasAWT.java.
> 
> Here is a JUnit test showing the behavior:
> https://github.com/arya-s/JOGLStuff/blob/master/src/tests/JOGLFullscreenTest.
> java
Comment 7 Sven Gothel 2013-10-07 03:02:58 CEST
(In reply to comment #6)
> Forum thread mentioned:
> http://forum.jogamp.org/Exiting-Fullscreen-in-TestGearsES2NewtCanvasAWT-java-
> td4030008.html

copy paste your test in your forum post:

+++

01. [set fullscreen  pre]: 0/0 1920x1200, f true, a false, [ l 0, r 0 - t 0, b 0 - 0x0]
02. window resized: 0/0 640x480
03. window resized: 0/0 640x480
04. Back out of fullscreen. Set: 640, 480
05. Thread[main-Animator,5,main] GearsES2.reshape 0/0 640x480, swapInterval 1, drawable 0x3400002, msaa false, tileRendererInUse null
06. >> angle 176.0, [l -1.3333334, r 1.3333334, b -1.0, t 1.0] 2.6666667x2.0 -> [l -1.3333334, r 1.3333334, b -1.0, t 1.0] 2.6666667x2.0
07. [set fullscreen post]: 0/0 640x480, f false, a false, [ l 0, r 0 - t 0, b 0 - 0x0]
08. window resized: 0/0 1920x1200
09.Thread[main-Animator,5,main] GearsES2.reshape 0/0 1920x1200, swapInterval 1, drawable 0x3400002, msaa false, tileRendererInUse null
10. >> angle 184.0, [l -1.6, r 1.6, b -1.0, t 1.0] 3.2x2.0 -> [l -1.6, r 1.6, b -1.0, t 1.0] 3.2x2.0
11. QUIT Window Thread[main-Display-.x11_:0-1-EDT-2,6,main]

As you can see, in the first line, we are in fullscreen, we exit and the window is resized to 640x480 (line 02&03).
I added the 'Back out of fullscreen' message (04), after which I call glWindow.setSize().
We see that the thread issues a reshape to 640x480 (05).
However in line 08 and 09 it is once again reshaped to 1920x1200.

I don't understand where and why 08 and 09 happen. 

+++

I have tested w/ TestGearsES2NewtCanvasAWT
and I cannot reproduce your issue here (Debian X11 NV as well, but KDE).
I actually have a different issue .. 'back to window mode' sometimes doesn't place 
the NEWT window back into AWT.

The resize comes from the WindowManager (WM),
hence we have an issue here .. hmm.
Comment 8 andrei 2013-10-07 05:09:05 CEST
I had a similar issue before when trying out the example that places the rendering window in the middle, surrounded by four buttons in the cardinal directions. I tried to use MigLayout instead of the inbuilt Layoutmanager and it didn't get placed back.

I'm not sure I can find the example anymore.


(In reply to comment #7)
> (In reply to comment #6)
> > Forum thread mentioned:
> > http://forum.jogamp.org/Exiting-Fullscreen-in-TestGearsES2NewtCanvasAWT-java-
> > td4030008.html
> 
> copy paste your test in your forum post:
> 
> +++
> 
> 01. [set fullscreen  pre]: 0/0 1920x1200, f true, a false, [ l 0, r 0 - t 0,
> b 0 - 0x0]
> 02. window resized: 0/0 640x480
> 03. window resized: 0/0 640x480
> 04. Back out of fullscreen. Set: 640, 480
> 05. Thread[main-Animator,5,main] GearsES2.reshape 0/0 640x480, swapInterval
> 1, drawable 0x3400002, msaa false, tileRendererInUse null
> 06. >> angle 176.0, [l -1.3333334, r 1.3333334, b -1.0, t 1.0] 2.6666667x2.0
> -> [l -1.3333334, r 1.3333334, b -1.0, t 1.0] 2.6666667x2.0
> 07. [set fullscreen post]: 0/0 640x480, f false, a false, [ l 0, r 0 - t 0,
> b 0 - 0x0]
> 08. window resized: 0/0 1920x1200
> 09.Thread[main-Animator,5,main] GearsES2.reshape 0/0 1920x1200, swapInterval
> 1, drawable 0x3400002, msaa false, tileRendererInUse null
> 10. >> angle 184.0, [l -1.6, r 1.6, b -1.0, t 1.0] 3.2x2.0 -> [l -1.6, r
> 1.6, b -1.0, t 1.0] 3.2x2.0
> 11. QUIT Window Thread[main-Display-.x11_:0-1-EDT-2,6,main]
> 
> As you can see, in the first line, we are in fullscreen, we exit and the
> window is resized to 640x480 (line 02&03).
> I added the 'Back out of fullscreen' message (04), after which I call
> glWindow.setSize().
> We see that the thread issues a reshape to 640x480 (05).
> However in line 08 and 09 it is once again reshaped to 1920x1200.
> 
> I don't understand where and why 08 and 09 happen. 
> 
> +++
> 
> I have tested w/ TestGearsES2NewtCanvasAWT
> and I cannot reproduce your issue here (Debian X11 NV as well, but KDE).
> I actually have a different issue .. 'back to window mode' sometimes doesn't
> place 
> the NEWT window back into AWT.
> 
> The resize comes from the WindowManager (WM),
> hence we have an issue here .. hmm.
Comment 9 Sven Gothel 2013-10-09 05:36:41 CEST
Stabilized NEWT reparenting/fullscreen on X11 and OSX, 
details see referenced git commits.
Comment 10 andrei 2013-10-09 08:19:39 CEST
No more issues on my system either.

(In reply to comment #9)
> Stabilized NEWT reparenting/fullscreen on X11 and OSX, 
> details see referenced git commits.
Comment 11 johan 2013-10-19 10:09:29 CEST
Fix in 2.1 works for OSX 10.8. This test now succeeds. Thanks!