MacOSX - attaching to external context hangs on loading native awt lib

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

MacOSX - attaching to external context hangs on loading native awt lib

Dominik Pospisil
I am trying to attach to external GL context created by native application. Eerything works as expected on both Windows and Linux but on MacOSX  

GLDrawableFactory.getDesktopFactory().createExternalGLContext()

calls hangs inside GLProfile.initSingleton while loading awt lib. I believe I am seing issue described

https://jogamp.org/bugzilla/show_bug.cgi?id=485
http://stackoverflow.com/questions/8750690/osx-javavm-awt-swing-and-possibly-a-deadlock

It is suggested to:
- spawn JVM from separate thread; this is not an option for me as I do not have control of the native app in which I am embedding JVM and I will still receive callbacks from the main thread where I would not have access to JVM

- launch JVM with -Djava.awt.headless. That results with:

com.jogamp.opengl.GLException: Error: current Context (CGL) null, no Context (NS)
        at jogamp.opengl.macosx.cgl.MacOSXExternalCGLContext.create(MacOSXExternalCGLContext.java:91)
        at jogamp.opengl.macosx.cgl.MacOSXCGLDrawableFactory.createExternalGLContextImpl(MacOSXCGLDrawableFactory.java:446)
        at jogamp.opengl.GLDrawableFactoryImpl.createExternalGLContext(GLDrawableFactoryImpl.java:599)


Is there any known workaround for this issue? I do not need any AWT stuff, all I need is to attach to current OpenGL context and do some drawing.

Many thanks,

- Dominik

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MacOSX - attaching to external context hangs on loading native awt lib

gouessej
Administrator
Hi

Actually, I wonder if it's caused by another bug concerning dylib/jnilib, I have to fix this one soon for JOGL 2.3.3.

In the meantime, please post a SSCCE to reproduce it:
http://sscce.org/
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MacOSX - attaching to external context hangs on loading native awt lib

Dominik Pospisil
I have tried other platforms and they could still return valid GL context even with -Djava.awt.headless set to true. I'll try to do some debugging why I am getting null context on macosx in my scenario. (I am sure that the current thread does have indeed valid GL context). I'll try to come up with some example as well.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MacOSX - attaching to external context hangs on loading native awt lib

Dominik Pospisil
This post was updated on .
Calling CGLGetCurrentContext() from the native code just before invoking JVM returns non-null GL context, however CGL.CGLGetCurrentContext() called from MacOSXExternalCGLContext returns null. Wondering why...

There must be something really weird going on since CGL.CGLGetCurrentContext() does just that - calls CGLGetCurrentContext()
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MacOSX - attaching to external context hangs on loading native awt lib

gouessej
Administrator
Maybe it's called from the wrong thread.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MacOSX - attaching to external context hangs on loading native awt lib

Dominik Pospisil
That's what I was thinking of as well. But I am not doing any threading currently. If that's the case that would mean than JNI call on macosx involves thread switching...
Loading...