Multiple Newt-Windows crashes since jogl-2.0-b18

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple Newt-Windows crashes since jogl-2.0-b18

Marc@56K
Hi,

the following code worked fine on jogl 2.0 beta 10. Now I updated to jogl-2.0-b18-windows-i586 and it crashed.

public class NewtMultiWindowBug extends Thread implements GLEventListener
{
    public static void main(String[] args)
    {
        try
        {
            for(int i=0; i<10; i++)
            {
                new NewtMultiWindowBug().start();
                //Thread.sleep(1000);                
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
   
    private GLWindow window;
       
    public void run()
    {
        this.window = GLWindow.create(new GLCapabilities(GLProfile.get("GL2GL3")));
        this.window.addGLEventListener(this);    
        this.window.setVisible(true);
       
        while(true)
        {
            window.display();
        }
    }

    @Override
    public void display(GLAutoDrawable drawable)
    {
       
    }

    @Override
    public void dispose(GLAutoDrawable arg0)
    {
    }

    @Override
    public void init(GLAutoDrawable drawable)
    {      

    }

    @Override
    public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4)
    {
    }
}

Each window is running in a separate thread. If I wait one second after the creation of a window it worked. Without the sleep most threads crashed with a NullPointerException:

Exception in thread "Thread-3" java.lang.NullPointerException
        at javax.media.opengl.GLProfile.getProfileMap(GLProfile.java:1493)
        at javax.media.opengl.GLProfile.get(GLProfile.java:548)
        at javax.media.opengl.GLProfile.get(GLProfile.java:555)
        at de.bht.jvr.tests.NewtMultiWindowBug.run(NewtMultiWindowBug.java:35)
...
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Newt-Windows crashes since jogl-2.0-b18

Wade Walker
Administrator
You might try the latest autobuild -- it looks like some fixes went into GLProfile in the area of that NPE on 12/18/2010. Let me know if it still happens there, we might need to report this as a bug.

Reply | Threaded
Open this post in threaded view
|

Re: Multiple Newt-Windows crashes since jogl-2.0-b18

Marc@56K
Hm, i can't find a newer version than jogl-b18-2010-12-14_23-00-56 here: http://jogamp.org/deployment/autobuilds/rc/
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Newt-Windows crashes since jogl-2.0-b18

Wade Walker
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Newt-Windows crashes since jogl-2.0-b18

Marc@56K
Ok, same problem with jogl-2.0-b266-20101223-windows-i586
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Newt-Windows crashes since jogl-2.0-b18

Wade Walker
Administrator
Could you post the stack trace for b266? I'll look at the code and see what's going on.
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Newt-Windows crashes since jogl-2.0-b18

Marc@56K
Exception in thread "Thread-9" java.lang.NullPointerException
        at javax.media.opengl.GLProfile.getProfileMap(GLProfile.java:1501)
        at javax.media.opengl.GLProfile.get(GLProfile.java:549)
        at javax.media.opengl.GLProfile.get(GLProfile.java:556)
        at de.bht.jvr.tests.NewtMultiWindowBug.run(NewtMultiWindowBug.java:35)
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Newt-Windows crashes since jogl-2.0-b18

Marc@56K
In reply to this post by Wade Walker
If i use Thread.sleep(500) I got this exception:

Exception in thread "Thread-4" java.lang.RuntimeException: java.lang.InternalError: Already set: Windows_decon_0
        at com.jogamp.newt.impl.DefaultEDTUtil.invokeImpl(DefaultEDTUtil.java:185)
        at com.jogamp.newt.impl.DefaultEDTUtil.invoke(DefaultEDTUtil.java:113)
        at com.jogamp.newt.impl.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:178)
        at com.jogamp.newt.impl.WindowImpl.runOnEDTIfAvail(WindowImpl.java:1407)
        at com.jogamp.newt.impl.WindowImpl.setVisible(WindowImpl.java:677)
        at com.jogamp.newt.opengl.GLWindow.setVisible(GLWindow.java:277)
        at de.bht.jvr.tests.NewtMultiWindowBug.run(NewtMultiWindowBug.java:37)
Caused by: java.lang.InternalError: Already set: Windows_decon_0
        at javax.media.opengl.GLContext.setAvailableGLVersionsSet(GLContext.java:596)
        at com.jogamp.opengl.impl.GLContextImpl.mapGLVersions(GLContextImpl.java:543)
        at com.jogamp.opengl.impl.GLContextImpl.createContextARB(GLContextImpl.java:508)
        at com.jogamp.opengl.impl.windows.wgl.WindowsWGLContext.createImpl(WindowsWGLContext.java:310)
        at com.jogamp.opengl.impl.GLContextImpl.makeCurrentLocking(GLContextImpl.java:404)
        at com.jogamp.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:350)
        at com.jogamp.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:347)
        at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:539)
        at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:515)
        at com.jogamp.newt.opengl.GLWindow$1.windowResized(GLWindow.java:83)
        at com.jogamp.newt.impl.WindowImpl.consumeWindowEvent(WindowImpl.java:2027)
        at com.jogamp.newt.impl.WindowImpl.sendWindowEvent(WindowImpl.java:1973)
        at com.jogamp.newt.impl.WindowImpl$VisibleAction.run(WindowImpl.java:659)
        at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:93)
        at com.jogamp.newt.impl.DefaultEDTUtil$EventDispatchThread.run(DefaultEDTUtil.java:277)
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Newt-Windows crashes since jogl-2.0-b18

Wade Walker
Administrator
In reply to this post by Marc@56K
It looks like GLProfile has a multithreading bug. To try to work around it, you might try calling GLProfile.initSingleton(true) in a static code block in your main class; this may initialize the member that's coming up null.

To submit a unit test for this bug via GitHub, there are instructions at http://jogamp.org/wiki/index.php/Contributing_a_new_feature_or_fix. Essentially all you have to do is turn your class into a unit test and submit a pull request. If we can get this in as a unit test as well as a bug report, it will greatly increase the chances of it getting fixed

Or for a more lightweight bug report, you can do the normal procedure at http://jogamp.org/wiki/index.php/Jogl_FAQ#Bugreports_.26_Testing. The link at
http://jogamp.org/wiki/index.php/Contributing_a_new_feature_or_fix#Create_an_enhancement_request_or_bug_report tells how to work around a minor Bugzilla login problem.

Thanks for your help, and sorry about this bug -- I guess most users haven't tried one window per thread yet
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Newt-Windows crashes since jogl-2.0-b18

Marc@56K
With GLProfile.initSingleton(true) the problem is gone.
Thanks :-)