Surface already locked exception

hello, in very rare cases i get the following exception

javax.media.opengl.GLException: Surface already locked
at com.sun.opengl.impl.windows.WindowsOnscreenGLDrawable.lockSurface(WindowsOnscreenGLDrawable.java:156)
at com.sun.opengl.impl.windows.WindowsOnscreenGLContext.makeCurrentImpl(WindowsOnscreenGLContext.java:57)
at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:127)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
at javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:298)
at sun.java2d.opengl.OGLRenderQueue$QueueFlusher.run(Unknown Source)

i was yet not able to reproduce this error, since it happens only about once in fifty times.
what may be special about my code is that i remove the GLcanvas from my frame and later on add it again. could this be the problem?

this is on (java6, jogl1.0.0, winXP)

thanks.

If you’re using Java 6 and the heavyweight GLCanvas then I don’t recommend you specify -Dsun.java2d.opengl=true. Instead specify -Dsun.java2d.noddraw=true. Only use -Dsun.java2d.opengl=true if you’re using the GLJPanel and need the performance increase offered by the Java 2D/JOGL bridge.

If you can provide a full thread dump (of all threads in the process, using the jstack tool or Ctrl-Break) at or very near the time the exception occurs we can try to look into it further.

thanks Ken,
this exception also occurs when using the -Dsun.java2d.noddraw=true or no flag at all.

here is the stack dump:


2007-02-28 10:56:33
Full thread dump Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode):

"AWT-EventQueue-0" prio=6 tid=0x032ef400 nid=0x874 in Object.wait() [0x248df000..0x248dfc14]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:485)
	at java.awt.EventQueue.getNextEvent(Unknown Source)
	- locked <0x11468160> (a java.awt.EventQueue)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

   Locked ownable synchronizers:
	- None

"DestroyJavaVM" prio=6 tid=0x003e8000 nid=0xf14 waiting on condition [0x00000000..0x0090fd4c]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"ResourceManagerThread" prio=6 tid=0x02bd0800 nid=0xc4 in Object.wait() [0x0ff8f000..0x0ff8fc94]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at com.company.theproduct.common.resourcemanagement.RessourceManager.waitForResources(RessourceManager.java:216)
	- locked <0x1224f638> (a com.company.theproduct.common.resourcemanagement.RessourceManager)
	at com.company.theproduct.common.resourcemanagement.RessourceManager.run(RessourceManager.java:151)
	at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
	- None

"AWT-EventQueue-0" prio=6 tid=0x02bd3800 nid=0xfe0 runnable [0x0ff1f000..0x0ff1fd14]
   java.lang.Thread.State: RUNNABLE
	at java.awt.EventDispatchThread.run(Unknown Source)

   Locked ownable synchronizers:
	- None

"Thread-3" daemon prio=6 tid=0x035ed800 nid=0x8e8 in Object.wait() [0x0eecf000..0x0eecfd14]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x11916c08> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(Unknown Source)
	- locked <0x11916c08> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(Unknown Source)
	at org.apache.batik.util.CleanerThread.run(Unknown Source)

   Locked ownable synchronizers:
	- None

"AWT-EventQueue-0" prio=6 tid=0x03574400 nid=0xfac runnable [0x0415f000..0x0415fa14]
   java.lang.Thread.State: RUNNABLE
	at java.awt.EventDispatchThread.run(Unknown Source)

   Locked ownable synchronizers:
	- None

"Thread-2" prio=6 tid=0x038d7400 nid=0xce4 runnable [0x0410f000..0x0410fa94]
   java.lang.Thread.State: RUNNABLE
	at com.sun.opengl.util.Animator$MainLoop.run(Animator.java:188)
	at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
	- None

"AWT-Windows" daemon prio=6 tid=0x0350f000 nid=0xb14 runnable [0x0372f000..0x0372fb14]
   java.lang.Thread.State: RUNNABLE
	at sun.awt.windows.WToolkit.eventLoop(Native Method)
	at sun.awt.windows.WToolkit.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
	- None

"AWT-Shutdown" prio=6 tid=0x0350c400 nid=0xd2c in Object.wait() [0x036df000..0x036dfb94]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:485)
	at sun.awt.AWTAutoShutdown.run(Unknown Source)
	- locked <0x11471b18> (a java.lang.Object)
	at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
	- None

"Java2D Disposer" daemon prio=10 tid=0x0350a400 nid=0xc44 in Object.wait() [0x0368f000..0x0368fc14]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.ref.ReferenceQueue.remove(Unknown Source)
	- locked <0x11471b40> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(Unknown Source)
	at sun.java2d.Disposer.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
	- None

"Low Memory Detector" daemon prio=6 tid=0x02bc3800 nid=0x158 runnable [0x00000000..0x00000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"CompilerThread0" daemon prio=10 tid=0x02bc2400 nid=0xa4 waiting on condition [0x00000000..0x02f8f99c]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"JDWP Command Reader" daemon prio=6 tid=0x02bb6400 nid=0xe20 runnable [0x00000000..0x00000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"JDWP Event Helper Thread" daemon prio=6 tid=0x02bb4c00 nid=0xbcc runnable [0x00000000..0x00000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"JDWP Transport Listener: dt_socket" daemon prio=6 tid=0x02bb2c00 nid=0x7c0 runnable [0x00000000..0x02e9f860]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"Attach Listener" daemon prio=10 tid=0x02ba7400 nid=0xbb4 waiting on condition [0x00000000..0x00000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"Signal Dispatcher" daemon prio=10 tid=0x02ba6400 nid=0xac0 runnable [0x00000000..0x00000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"Finalizer" daemon prio=8 tid=0x02b95400 nid=0xa90 in Object.wait() [0x02d0f000..0x02d0fc94]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.ref.ReferenceQueue.remove(Unknown Source)
	- locked <0x1141b8f8> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(Unknown Source)
	at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

   Locked ownable synchronizers:
	- None

"Reference Handler" daemon prio=10 tid=0x02b94400 nid=0xe60 in Object.wait() [0x02cbf000..0x02cbfd14]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:485)
	at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
	- locked <0x1141b918> (a java.lang.ref.Reference$Lock)

   Locked ownable synchronizers:
	- None

"VM Thread" prio=10 tid=0x02b91000 nid=0xcf8 runnable 

"VM Periodic Task Thread" prio=10 tid=0x02bde400 nid=0x9a8 waiting on condition 

JNI global references: 3909

We fixed a bug in a fairly recent JOGL build associated with failures to make the OpenGL context current. Previously if a GLContext.makeCurrent() call failed it could leave the AWT surface locked so that subsequent attempts to call makeCurrent() would throw the exception you’re getting. My guess is that higher up in your exception log there is a GLException indicating that there was an error making the context current. If you try the last nightly build linked from the JOGL home page I think that your application will at least be able to recover from whatever transient error is causing the exception to be thrown in the first place.

Another question is what graphics card you have and whether you’re running the latest drivers from your vendor.

thanks Ken,

ok, i will switch to RC3 again, and see if there is another exception thrown earlier.

the graphics card is an
ATI RADEON X600 x86/SSE2 (OpenGL 2.0.6)
with catalyst version 7.1

(i see that they recently released 7.2, so i will also update the drivers ;-))