Login  Register

Re: Jogl/Jogamp on Java 8 building from source

Posted by Predrag Bokšić on Dec 28, 2017; 4:03am
URL: https://forum.jogamp.org/Jogl-Jogamp-on-Java-9-tp4038012p4038454.html

The exact line of code where the JVM 9 crashes (on the latest Apple computers) can be found in the file j3d/j3d-core/src/javax/media/j3d/GraphicsConfigTemplate3D.java, in the method GraphicsConfiguration getBestConfiguration(GraphicsConfiguration[] gc). Please read the method contents to find the line inside.



@Override
public GraphicsConfiguration getBestConfiguration(GraphicsConfiguration[] gc) {
if ((gc == null) || (gc.length == 0) || (gc[0] == null)) {
    return null;
}

synchronized (globalLock) {
    testCfg = gc;

    // It is possible that the followign postRequest will
    // cause request renderer run immediately before
    // runMonitor(WAIT). So we need to set
    // threadWaiting to true.

    threadWaiting = true;

    // Prevent deadlock if invoke from Behavior callback since
    // this thread has to wait Renderer thread to finish but
    // MC can only handle postRequest and put it in Renderer
    // queue when free.

    if (Thread.currentThread() instanceof BehaviorScheduler) {
         VirtualUniverse.mc.sendRenderMessage(gc[0], this,
         // this is not executed
         MasterControl.GETBESTCONFIG);
    } else {
         // this is executed
         VirtualUniverse.mc.postRequest(MasterControl.GETBESTCONFIG, this);
    }

    // this is okay
    runMonitor(J3dThread.WAIT);

    // !!!     this crashes the JVM 9    !!!
    GraphicsConfiguration graphicsConfiguration = (GraphicsConfiguration) testCfg;

    // this is okay
    return graphicsConfiguration;

    }
}




More precisely, the spot where the JVM 9 crashes is in

                canvas.doQuery();

in

    @Override
    GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate3D gct,
            GraphicsConfiguration[] gc)

in the file j3d-core/src/javax/media/j3d/JoglPipeline.java.




And even more precisely, the spot where the JVM 9 crashes is in

            context.destroy();

in the following method:


        // It seems that at least on Mac OS X we need to do the OpenGL
        // context-related work outside of the addNotify call because the
        // Canvas hasn't been resized to a non-zero size by that point
        private void doQuery() {
            if (alreadyRan)
                return;
            GLContext context = glDrawable.createContext(null);
            int res = context.makeCurrent();
            if (res != GLContext.CONTEXT_NOT_CURRENT) {
                try {
                    chooser.init(context);
                } finally {
                    context.release();
                }
            }


            // !!!     this crashes the JVM 9    !!!
            context.destroy();

            alreadyRan = true;

            glDrawable.setRealized(false);
            nativeWindow.destroy();
        }
    }


in the file JoglPipeline.java.

I don't know why this is happening, but I was interested in learning how to examine the program execution.