Switching fullscreen/windowed crashes and bugs

Started by Rock_D, June 28, 2009, 23:38:50

Previous topic - Next topic

Rock_D

Switching to fullscreen and then back to windowed gave me an VM access violation for my own program. When looking to replicate the error I found that the FullscreenWindowedTest webstart demo gives an Exception that might be related if you switch to windowed and then back to fullscreen. Sometimes it didn't give the exception, but it just crashed, giving me the same vm access violation that I got with my program (posted at the bottom).
The console log showed this (for the exception):
org.lwjgl.LWJGLException: Could not make context current
   at org.lwjgl.opengl.WindowsContextImplementation.nMakeCurrent(Native Method)
   at org.lwjgl.opengl.WindowsContextImplementation.makeCurrent(WindowsContextImplementation.java:90)
   at org.lwjgl.opengl.Context.makeCurrent(Context.java:182)
   at org.lwjgl.opengl.Display.makeCurrent(Display.java:713)
   at org.lwjgl.opengl.Display.makeCurrentAndSetSwapInterval(Display.java:865)
   at org.lwjgl.opengl.Display.setDisplayModeAndFullscreenInternal(Display.java:536)
   at org.lwjgl.opengl.Display.setDisplayModeAndFullscreen(Display.java:514)
   at org.lwjgl.test.opengl.FullScreenWindowedTest.switchMode(FullScreenWindowedTest.java:80)
   at org.lwjgl.test.opengl.FullScreenWindowedTest.processKeyboard(FullScreenWindowedTest.java:172)
   at org.lwjgl.test.opengl.FullScreenWindowedTest.mainLoop(FullScreenWindowedTest.java:106)
   at org.lwjgl.test.opengl.FullScreenWindowedTest.execute(FullScreenWindowedTest.java:74)
   at org.lwjgl.test.opengl.FullScreenWindowedTest.main(FullScreenWindowedTest.java:276)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at com.sun.javaws.Launcher.executeApplication(Unknown Source)
   at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
   at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
   at com.sun.javaws.Launcher.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
#### Java Web Start Error:
#### null

The actual exception is a java.lang.NullPointerException
   at org.lwjgl.opengl.GL11.glClear(GL11.java:582)
   at org.lwjgl.test.opengl.FullScreenWindowedTest.render(FullScreenWindowedTest.java:147) <- GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

The VM crash log:
#
# An unexpected error has been detected by Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d0b64f8, pid=1384, tid=2120
#
# Java VM: Java HotSpot(TM) Client VM (11.3-b02 mixed mode, sharing windows-x86)
# Problematic frame:
# C  [awt.dll+0xb64f8]
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x02b25c00):  JavaThread "AWT-Windows" daemon [_thread_in_native, id=2120, stack(0x02ef0000,0x02f40000)]

siginfo: ExceptionCode=0xc0000005, writing address 0x034b4680

Registers:
EAX=0x000000c0, EBX=0x0324b6a0, ECX=0x00000030, EDX=0x00004680
ESP=0x02f3f7bc, EBP=0x02f3f918, ESI=0x0324fd30, EDI=0x034b4680
EIP=0x6d0b64f8, EFLAGS=0x00010212

Top of Stack: (sp=0x02f3f7bc)
0x02f3f7bc:   00000000 0324b480 0000016e 6d0b2b81
0x02f3f7cc:   034b4680 6d0adc6b 00000000 03243690
0x02f3f7dc:   6d0b3671 00009824 02b25d14 00000001
0x02f3f7ec:   000001ba 02b26440 00000000 000001be
0x02f3f7fc:   00000000 02f3f824 02b25d14 032435e0
0x02f3f80c:   6d98d975 00000000 22ebbe48 02b25c00
0x02f3f81c:   00000003 02a633ae 02b25c00 6d8c4f45
0x02f3f82c:   02b25c00 00000006 00000008 02b25c00 

Instructions: (pc=0x6d0b64f8)
0x6d0b64e8:   8b 7c 24 10 8b c1 c1 e9 02 c1 e2 05 8d 74 1a 10
0x6d0b64f8:   f3 a5 8b c8 83 e1 03 f3 a4 8b 83 10 a0 00 00 8b 


Stack: [0x02ef0000,0x02f40000],  sp=0x02f3f7bc,  free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [awt.dll+0xb64f8]
C  [awt.dll+0x9c62c]
C  [USER32.dll+0x8734]
C  [USER32.dll+0x8816]
C  [USER32.dll+0x18ea0]
C  [USER32.dll+0x18eec]
C  [ntdll.dll+0xe473]
C  [USER32.dll+0x9402]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  sun.awt.windows.WToolkit.eventLoop()V+0
j  sun.awt.windows.WToolkit.run()V+69
j  java.lang.Thread.run()V+11
v  ~StubRoutines::call_stub

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

Java Threads: ( => current thread )
  0x033af000 JavaThread "javawsApplicationMain" [_thread_blocked, id=2880, stack(0x03df0000,0x03e40000)]
  0x032dcc00 JavaThread "D3D Screen Updater" daemon [_thread_blocked, id=3500, stack(0x03cf0000,0x03d40000)]
  0x032ca000 JavaThread "Keep-Alive-Timer" daemon [_thread_blocked, id=1012, stack(0x03c40000,0x03c90000)]
  0x032c5400 JavaThread "TimerQueue" daemon [_thread_blocked, id=508, stack(0x037f0000,0x03840000)]
  0x03287000 JavaThread "CacheCleanUpThread" daemon [_thread_blocked, id=2708, stack(0x036e0000,0x03730000)]
  0x03282000 JavaThread "CacheMemoryCleanUpThread" daemon [_thread_blocked, id=2108, stack(0x03690000,0x036e0000)]
  0x0327f400 JavaThread "ConsoleWriterThread" daemon [_thread_blocked, id=2572, stack(0x03640000,0x03690000)]
  0x0327d400 JavaThread "AWT-EventQueue-1" [_thread_blocked, id=3780, stack(0x035f0000,0x03640000)]
  0x03256400 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=276, stack(0x03460000,0x034b0000)]
  0x02b3b800 JavaThread "traceMsgQueueThread" daemon [_thread_blocked, id=3996, stack(0x031a0000,0x031f0000)]
  0x003a7000 JavaThread "DestroyJavaVM" [_thread_blocked, id=2004, stack(0x008c0000,0x00910000)]
  0x02b28c00 JavaThread "Javaws Secure Thread" daemon [_thread_blocked, id=3632, stack(0x02f80000,0x02fd0000)]
=>0x02b25c00 JavaThread "AWT-Windows" daemon [_thread_in_native, id=2120, stack(0x02ef0000,0x02f40000)]
  0x02b24800 JavaThread "AWT-Shutdown" [_thread_blocked, id=1992, stack(0x02ea0000,0x02ef0000)]
  0x02b23000 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=2084, stack(0x02e50000,0x02ea0000)]
  0x02a71c00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=1900, stack(0x02d20000,0x02d70000)]
  0x02a6f400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2376, stack(0x02cd0000,0x02d20000)]
  0x02a6a400 JavaThread "Attach Listener" daemon [_thread_blocked, id=1672, stack(0x02c80000,0x02cd0000)]
  0x02a69000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=384, stack(0x02c30000,0x02c80000)]
  0x02a64400 JavaThread "Finalizer" daemon [_thread_blocked, id=1396, stack(0x02be0000,0x02c30000)]
  0x02a5f800 JavaThread "Reference Handler" daemon [_thread_blocked, id=2900, stack(0x02b90000,0x02be0000)]

Other Threads:
  0x02a5e000 VMThread [stack: 0x02b40000,0x02b90000] [id=2088]
  0x02a74000 WatcherThread [stack: 0x02d70000,0x02dc0000] [id=2888]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 960K, used 885K [0x22990000, 0x22a90000, 0x22e70000)
  eden space 896K,  95% used [0x22990000, 0x22a66688, 0x22a70000)
  from space 64K,  43% used [0x22a80000, 0x22a86f00, 0x22a90000)
  to   space 64K,   0% used [0x22a70000, 0x22a70000, 0x22a80000)
 tenured generation   total 4096K, used 3237K [0x22e70000, 0x23270000, 0x26990000)
   the space 4096K,  79% used [0x22e70000, 0x23199528, 0x23199600, 0x23270000)
 compacting perm gen  total 12288K, used 3780K [0x26990000, 0x27590000, 0x2a990000)
   the space 12288K,  30% used [0x26990000, 0x26d411f8, 0x26d41200, 0x27590000)
    ro space 8192K,  63% used [0x2a990000, 0x2aea8810, 0x2aea8a00, 0x2b190000)
    rw space 12288K,  53% used [0x2b190000, 0x2b7fd300, 0x2b7fd400, 0x2bd90000)

Dynamic libraries:
0x00400000 - 0x00424000 	F:\Program Files\Java\jre6\bin\javaw.exe
0x7c900000 - 0x7c9b8000 	C:\WINDOWS\system32\ntdll.dll
0x7c7d0000 - 0x7c8d0000 	C:\WINDOWS\system32\kernel32.dll
0x77f40000 - 0x77feb000 	C:\WINDOWS\system32\ADVAPI32.dll
0x77da0000 - 0x77e32000 	C:\WINDOWS\system32\RPCRT4.dll
0x77f10000 - 0x77f21000 	C:\WINDOWS\system32\Secur32.dll
0x7e390000 - 0x7e421000 	C:\WINDOWS\system32\USER32.dll
0x77e40000 - 0x77e89000 	C:\WINDOWS\system32\GDI32.dll
0x76330000 - 0x7634d000 	C:\WINDOWS\system32\IMM32.DLL
0x7c340000 - 0x7c396000 	F:\Program Files\Java\jre6\bin\msvcr71.dll
0x6d800000 - 0x6da56000 	F:\Program Files\Java\jre6\bin\client\jvm.dll
0x76af0000 - 0x76b1e000 	C:\WINDOWS\system32\WINMM.dll
0x6d290000 - 0x6d298000 	F:\Program Files\Java\jre6\bin\hpi.dll
0x76bb0000 - 0x76bbb000 	C:\WINDOWS\system32\PSAPI.DLL
0x6d7b0000 - 0x6d7bc000 	F:\Program Files\Java\jre6\bin\verify.dll
0x6d330000 - 0x6d34f000 	F:\Program Files\Java\jre6\bin\java.dll
0x6d7f0000 - 0x6d7ff000 	F:\Program Files\Java\jre6\bin\zip.dll
0x6d000000 - 0x6d14a000 	F:\Program Files\Java\jre6\bin\awt.dll
0x72f70000 - 0x72f96000 	C:\WINDOWS\system32\WINSPOOL.DRV
0x77be0000 - 0x77c38000 	C:\WINDOWS\system32\msvcrt.dll
0x774a0000 - 0x775dd000 	C:\WINDOWS\system32\ole32.dll
0x77390000 - 0x77493000 	C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll
0x77e90000 - 0x77f06000 	C:\WINDOWS\system32\SHLWAPI.dll
0x5b190000 - 0x5b1c8000 	C:\WINDOWS\system32\uxtheme.dll
0x746a0000 - 0x746ec000 	C:\WINDOWS\system32\MSCTF.dll
0x75250000 - 0x7527e000 	C:\WINDOWS\system32\msctfime.ime
0x6d1d0000 - 0x6d1e3000 	F:\Program Files\Java\jre6\bin\deploy.dll
0x77a40000 - 0x77ad6000 	C:\WINDOWS\system32\CRYPT32.dll
0x77ae0000 - 0x77af2000 	C:\WINDOWS\system32\MSASN1.dll
0x7c9c0000 - 0x7d1e2000 	C:\WINDOWS\system32\SHELL32.dll
0x770e0000 - 0x7716b000 	C:\WINDOWS\system32\OLEAUT32.dll
0x445d0000 - 0x446a0000 	C:\WINDOWS\system32\WININET.dll
0x03020000 - 0x03029000 	C:\WINDOWS\system32\Normaliz.dll
0x44350000 - 0x44395000 	C:\WINDOWS\system32\iertutil.dll
0x456d0000 - 0x457f7000 	C:\WINDOWS\system32\urlmon.dll
0x6d610000 - 0x6d623000 	F:\Program Files\Java\jre6\bin\net.dll
0x71a30000 - 0x71a47000 	C:\WINDOWS\system32\WS2_32.dll
0x71a20000 - 0x71a28000 	C:\WINDOWS\system32\WS2HELP.dll
0x6d630000 - 0x6d639000 	F:\Program Files\Java\jre6\bin\nio.dll
0x6d6b0000 - 0x6d6f2000 	F:\Program Files\Java\jre6\bin\regutils.dll
0x77bd0000 - 0x77bd8000 	C:\WINDOWS\system32\VERSION.dll
0x7d1f0000 - 0x7d4ac000 	C:\WINDOWS\system32\msi.dll
0x6d230000 - 0x6d284000 	F:\Program Files\Java\jre6\bin\fontmanager.dll
0x4fd10000 - 0x4feb6000 	C:\WINDOWS\system32\d3d9.dll
0x6deb0000 - 0x6deb6000 	C:\WINDOWS\system32\d3d8thk.dll
0x719d0000 - 0x71a10000 	C:\WINDOWS\System32\mswsock.dll
0x76ee0000 - 0x76f07000 	C:\WINDOWS\system32\DNSAPI.dll
0x76f70000 - 0x76f78000 	C:\WINDOWS\System32\winrnr.dll
0x76f20000 - 0x76f4d000 	C:\WINDOWS\system32\WLDAP32.dll
0x16080000 - 0x16099000 	C:\Program Files\Bonjour\mdnsNSP.dll
0x76d20000 - 0x76d39000 	C:\WINDOWS\system32\Iphlpapi.dll
0x76f80000 - 0x76f86000 	C:\WINDOWS\system32\rasadhlp.dll
0x61200000 - 0x61259000 	C:\WINDOWS\system32\hnetcfg.dll
0x71a10000 - 0x71a18000 	C:\WINDOWS\System32\wshtcpip.dll
0x10000000 - 0x10057000 	C:\Documents and Settings\PVR\Application Data\Sun\Java\Deployment\cache\6.0\27\3fe7e05b-10845037-n\lwjgl.dll
0x5f160000 - 0x5f22c000 	C:\WINDOWS\system32\OPENGL32.dll
0x5f400000 - 0x5f421000 	C:\WINDOWS\system32\GLU32.dll
0x736d0000 - 0x7371b000 	C:\WINDOWS\system32\DDRAW.dll
0x73b30000 - 0x73b36000 	C:\WINDOWS\system32\DCIMAN32.dll
0x69500000 - 0x69ea5000 	C:\WINDOWS\system32\nvoglnt.dll

VM Arguments:
jvm_args: -Xbootclasspath/a:F:\Program Files\Java\jre6\lib\javaws.jar;F:\Program Files\Java\jre6\lib\deploy.jar;F:\Program Files\Java\jre6\lib\plugin.jar -Djava.security.policy=file:F:\Program Files\Java\jre6\lib\security\javaws.policy -DtrustProxy=true -Xverify:remote -Djnlpx.home=F:\Program Files\Java\jre6\bin -Djnlpx.remove=true -Djnlpx.splashport=3980 -Djnlpx.jvm=F:\Program Files\Java\jre6\bin\javaw.exe 
java_command: com.sun.javaws.Main C:\DOCUME~1\PVR\LOCALS~1\Temp\javaws2
Launcher Type: SUN_STANDARD

Environment Variables:
CLASSPATH=.;C:\Program Files\Java\jre1.6.0_02\lib\ext\QTJava.zip
PATH=F:\Program Files\Java\jre6\bin;F:\Program Files\Firefox;C:\Program Files\Common Files\ArcSoft\Bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\QuickTime\QTSystem\;F:\Program Files\Java\jdk1.6.0_13\bin;f:\lua;"F:\Program Files\Java\jre6\bin"
USERNAME=PVR
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 15 Model 43 Stepping 1, AuthenticAMD



---------------  S Y S T E M  ---------------

OS: Windows XP Build 2600 Service Pack 3

CPU:total 2 (2 cores per cpu, 1 threads per core) family 15 model 43 stepping 1, cmov, cx8, fxsr, mmx, sse, sse2, sse3, mmxext, 3dnow, 3dnowext

Memory: 4k page, physical 1048040k(292540k free), swap 4091760k(3505516k free)

vm_info: Java HotSpot(TM) Client VM (11.3-b02) for windows-x86 JRE (1.6.0_13-b03), built on Mar  9 2009 01:15:24 by "java_re" with MS VC++ 7.1

time: Mon Jun 29 00:54:46 2009
elapsed time: 8 seconds


OrangyTang on the lwjgl IRC tried the fullscreen webstart demo as well and he also got the exception (not sure about the crash).

My system:
Windows XP SP 3
NVidia 8600 GT
forceware 185.85


broumbroum

Context switch is something very obscure.... Therefore full-screen switch should be requested on the same thread that invokes rendering (update()).
Either use Swing Event Thread or a custom TimerTask, but it has to be the same Thread that invokes Display.update(). it is generally Swing that's best for rendering tasks.


Rock_D

FullscreenWindowedTest is very simple. It's just one thread that creates the display, then updates the screen in a loop, nothing else, so it couldn't have been another thread calling the update.

Ciardhubh

Same exception here (Win XP SP3, Nvidia GT8800).

The crash happens when going from windowed mode to fullscreen mode.

A workaround seems to be to destroy the display before changing the display mode and then creating it again, e.g. :
       if (Display.isCreated()) {
            Display.destroy();
        }

        Display.setDisplayModeAndFullscreen(mode);

        Display.create(); // Remove .create from initialize()
        glInit(); // Can result in square being off-screen


Then again, how much of a workaround is this really? You probably have to reload textures, shaders, GL-states, etc. again.

broumbroum

I'm doing some similar "frame-cycle" using AWTGLCanvas.
WINDOWED_MODE -> First close -> dispose -> create a new Frame -> FULLSCREEN_MODE.
But since it doesn't close the AWTGLCanvas, the context may be kept alive. I simply had to correctly implement addNotify() removeNotify() to start and stop rendering. 8)
I'm publishing today JXA 3.3, where it may be found RenderingScene.