Re: JOGL - without GLEventListener (GLCanvas or GLJPanel)
Posted by Andrzej on May 01, 2018; 5:16am
URL: https://forum.jogamp.org/JOGL-without-GLEventListener-GLCanvas-or-GLJPanel-tp4038837p4038846.html
My native renderer is a bit complicated, and it does not have one render() function I can call in a Runnable. It kicks off a rendering thread, onto which rendering operations are queued on based on necessity.
Here is what happens:
1. Initially the opengl context is created on Java side (GLAutoDrawable -> GLWindow/GLCanvas/GLJPanel)
2. The rendering thread decides when it need to render, and then calls back into the Java code to make the context current, and once that's done does does all the gl* rendering it needs.
3. Another call back into Java let's opengl know to render (by calling display() on the GLAutoDrawable)
This all works find when the GLAutoDrawable is the GLWindow, and it's stand alone. As soon as I put that inside a NewtCanvasAWT or use GLCanvas, I see nothing rendered, and get timouts, something like this (this specifically is coming from the GLCanvas usage):
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Waited 5000ms for: <11bf8c0e, 77ede76a>[count 2, qsz 1, owner <Thread-4>] - <AWT-EventQueue-0>
at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
at com.jogamp.nativewindow.awt.JAWTWindow.lockSurface(JAWTWindow.java:603)
at jogamp.opengl.GLDrawableHelper.resizeOffscreenDrawable(GLDrawableHelper.java:344)
at com.jogamp.opengl.awt.GLCanvas.reshapeImpl(GLCanvas.java:844)
at com.jogamp.opengl.awt.GLCanvas.reshape(GLCanvas.java:822)
at java.awt.Component.setBounds(Component.java:2261)
at java.awt.BorderLayout.layoutContainer(BorderLayout.java:838)
at java.awt.Container.layout(Container.java:1510)
at java.awt.Container.doLayout(Container.java:1499)
at java.awt.Container.validateTree(Container.java:1695)
at java.awt.Container.validateTree(Container.java:1704)
at java.awt.Container.validateTree(Container.java:1704)
at java.awt.Container.validateTree(Container.java:1704)
at java.awt.Container.validateTree(Container.java:1704)
at java.awt.Container.validate(Container.java:1630)
at java.awt.Container.validateUnconditionally(Container.java:1667)
at java.awt.Window.show(Window.java:1033)
at java.awt.Component.show(Component.java:1671)
at java.awt.Component.setVisible(Component.java:1623)
at java.awt.Window.setVisible(Window.java:1014)
at com.lhsystems.maps.testbed.presenter.SessionWindowPresenter.present(SessionWindowPresenter.java:65)
at com.lhsystems.maps.testbed.presenter.DataPackageDetailPresenter.lambda$0(DataPackageDetailPresenter.java:69)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Waited 5000ms for: <11bf8c0e, 77ede76a>[count 2, qsz 1, owner <Thread-4>] - <AWT-EventQueue-0>
at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
at com.jogamp.nativewindow.awt.JAWTWindow.lockSurface(JAWTWindow.java:603)
at jogamp.opengl.GLDrawableHelper.resizeOffscreenDrawable(GLDrawableHelper.java:344)
at com.jogamp.opengl.awt.GLCanvas.reshapeImpl(GLCanvas.java:844)
at com.jogamp.opengl.awt.GLCanvas.reshape(GLCanvas.java:822)
at java.awt.Component.setBounds(Component.java:2261)
at java.awt.BorderLayout.layoutContainer(BorderLayout.java:838)
at java.awt.Container.layout(Container.java:1510)
at java.awt.Container.doLayout(Container.java:1499)
at java.awt.Container.validateTree(Container.java:1695)
at java.awt.Container.validateTree(Container.java:1704)
at java.awt.Container.validateTree(Container.java:1704)
at java.awt.Container.validateTree(Container.java:1704)
at java.awt.Container.validateTree(Container.java:1704)
at java.awt.Container.validate(Container.java:1630)
at java.awt.Window.dispatchEventImpl(Window.java:2744)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
It's not easy to provide a distilled one class example showing this, due to this c++ rendering part that seems to be necessary to reproduce this problem :(
I'm not sure whether this is enough information to point me in the right direction... I am not sure why it is all good in a standalone GLWindow, works beautifully, but fails when put in NewtCanvasAWT or when GLCanvas/GLJPanel is used...
Well that's not entirely true, it works fine inside a NewtCanvasAWT as long as I don't put that NewtCanvasAWT inside anthing else (like a JPanel), as long as its stand alone, it's also fine. When I put it inside a NewtCanvasAWT, and then put that in a JPanel, I get further than with GLCanvas/GLJPanel, I can actually see some of my c++ renders, but not all of it. And I still get a timeout, but a little different:
DefaultEDT.run(): Caught exception occured on thread AWT-EventQueue-0-Display-.macosx_nil-1-EDT-2: RunnableTask[executed true, tTotal 49840 ms, tExec 5000 ms, tQueue 44840 ms, attachment null, throwable java.lang.RuntimeException: Waited 5000ms for: <35a85d1, 783f7363>[count 4, qsz 0, owner <Thread-6>] - <AWT-EventQueue-0-Display-.macosx_nil-1-EDT-2>]
java.lang.RuntimeException: Waited 5000ms for: <35a85d1, 783f7363>[count 4, qsz 0, owner <Thread-6>] - <AWT-EventQueue-0-Display-.macosx_nil-1-EDT-2>
at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
at jogamp.newt.WindowImpl$SetSizeAction.run(WindowImpl.java:1045)
at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:435)
at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:2133)
at jogamp.newt.WindowImpl.setSize(WindowImpl.java:1087)
at com.jogamp.newt.opengl.GLWindow.setSize(GLWindow.java:509)
at jogamp.newt.awt.event.AWTParentWindowAdapter$1.run(AWTParentWindowAdapter.java:128)
at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:133)
at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:372)
I suspect this all has to do with Native/AWT threads, and my c++ renderer expecting things to happen on one thread, but the GLCanvas/GLJpanel/NewtCanvasAWT having a different threading model than the stand alone GLWindow... But I am not sure how achieve what I want...
Oh and this is all on macos 10.13.4