Bug 523 - Hang and timeout exception on exit when sharing GLContext
Summary: Hang and timeout exception on exit when sharing GLContext
Status: RESOLVED WORKSFORME
Alias: None
Product: Newt
Classification: JogAmp
Component: windows (show other bugs)
Version: 1
Hardware: pc_x86_32 windows
: --- normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2011-11-05 01:19 CET by Michael Weber
Modified: 2011-11-21 09:32 CET (History)
0 users

See Also:
Type: ---
SCM Refs:
12342c9e6122051fbdc91493c4d63515ad4613d1 e7388512b69979d00e5a213a1b166a1b1726ae0c
Workaround: ---


Attachments
test.log configuration report using Sept 16 2011 signed release (88.35 KB, application/octet-stream)
2011-11-05 01:19 CET, Michael Weber
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Weber 2011-11-05 01:19:37 CET
Created attachment 289 [details]
test.log configuration report using Sept 16 2011 signed release

While learning to use Newt I also experimented with using a shared GLContext in order to understand how to share display lists and buffer objects across GLWindow instances. When using the Sept 16 2011 signed release, I found that upon exit, my test application hung and also reported a timeout related exception (and still did not exit after the RuntimeException). The stack trace is copied below for reference. This problem does not happen if I do not use a shared GLContext.

I wrote a unit test to demonstrate the problem, and when I test it against a more recent build of JOGL (source as of Oct 14 2011 from git://jogamp.org/), I find that the problem is fixed. I will submit the test case for consideration via github as per the "how to submit" guidelines, and hence I am logging this bug for the ID.

A test.log file with configuration script output is also attached.

Detected screen size 1680x1050
Detected screen size 1680x1050
INIT GL IS: jogamp.opengl.gl4.GL4bcImpl
INIT GL IS: jogamp.opengl.gl4.GL4bcImpl
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.RuntimeException: Waited 5000ms for: Thread[main-AWTAnimator-1,5,] - Thread[main-Display-Windows_nil-1-EDT-1-Display-Windows_nil-2-EDT-1,5,main], with recursionCount 0, lock: com.jogamp.common.util.locks.RecursiveLock@17050f5, qsz 0
	at jogamp.newt.DefaultEDTUtil.invokeImpl(DefaultEDTUtil.java:185)
	at jogamp.newt.DefaultEDTUtil.invoke(DefaultEDTUtil.java:113)
	at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:202)
	at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:1454)
	at jogamp.newt.WindowImpl.setVisible(WindowImpl.java:741)
	at com.jogamp.newt.opengl.GLWindow.setVisible(GLWindow.java:299)
	at com.jogamp.newt.awt.NewtCanvasAWT.reparentWindow(NewtCanvasAWT.java:237)
	at com.jogamp.newt.awt.NewtCanvasAWT.removeNotify(NewtCanvasAWT.java:208)
	at java.awt.Container.removeNotify(Container.java:2609)
	at javax.swing.JComponent.removeNotify(JComponent.java:4701)
	at java.awt.Container.removeNotify(Container.java:2609)
	at javax.swing.JComponent.removeNotify(JComponent.java:4701)
	at java.awt.Container.removeNotify(Container.java:2609)
	at javax.swing.JComponent.removeNotify(JComponent.java:4701)
	at java.awt.Container.removeNotify(Container.java:2609)
	at javax.swing.JComponent.removeNotify(JComponent.java:4701)
	at java.awt.Container.removeNotify(Container.java:2609)
	at javax.swing.JComponent.removeNotify(JComponent.java:4701)
	at javax.swing.JRootPane.removeNotify(JRootPane.java:754)
	at java.awt.Container.removeNotify(Container.java:2609)
	at java.awt.Window.removeNotify(Window.java:686)
	at java.awt.Frame.removeNotify(Frame.java:886)
	at java.awt.Window$1DisposeAction.run(Window.java:1014)
	at java.awt.Window.doDispose(Window.java:1026)
	at java.awt.Window.dispose(Window.java:973)
	at demos.NewtSharedContext$6.run(NewtSharedContext.java:304)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.RuntimeException: Waited 5000ms for: Thread[main-AWTAnimator-1,5,] - Thread[main-Display-Windows_nil-1-EDT-1-Display-Windows_nil-2-EDT-1,5,main], with recursionCount 0, lock: com.jogamp.common.util.locks.RecursiveLock@17050f5, qsz 0
	at com.jogamp.common.util.locks.RecursiveLock.lock(RecursiveLock.java:125)
	at jogamp.newt.WindowImpl.setVisibleActionImpl(WindowImpl.java:664)
	at jogamp.newt.WindowImpl$VisibleAction.run(WindowImpl.java:726)
	at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:93)
	at jogamp.newt.DefaultEDTUtil$EventDispatchThread.run(DefaultEDTUtil.java:282)
Comment 1 Sven Gothel 2011-11-21 09:32:49 CET
Beside the fact that the test case runs through .. here is a review and related fixes 
to the public API:

Fix GLDrawableFactory: Move 'GLContext getOrCreateSharedContext(..)' to non public class GLDrawableFactoryImpl.
    
   Michael Weber's test case (commit e7388512b69979d00e5a213a1b166a1b1726ae0c)
    pointed me to the flaw in GLDrawableFactory which exposed a non-public method,
    ie. 'getOrCreateSharedContext()'.
    
    This lead to the assumption, that the 'shared' drawable/context of the factory is multi purpose
    and may be used for application context sharing - which is not the case.
    
    Changed Michael's test case to use a local shared pbuffer based drawable/context
    and made the method non-public, where it belongs.