JOGL takes too long to start

这一生的挚爱 提交于 2019-12-11 07:10:15

问题


I'm trying to get a little bit into JOGL but it seems like I can't even get the program to start properly.

@SuppressWarnings("serial")
public class Test extends GLJPanel implements GLEventListener {
    public static final void main(final String[] args) {
        final long startTimeMillis = System.currentTimeMillis();

        final GLProfile profile = GLProfile.get(GLProfile.GL4);

        System.out.println("GLProfile#get -> " + (System.currentTimeMillis() - startTimeMillis));
        final GLCapabilities capabilities = new GLCapabilities(profile);

        final JFrame frame = new JFrame(Test.class.getName());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        final Test t = new Test(capabilities);
        frame.add(t);

        frame.setVisible(true);
        frame.pack();
        frame.setLocationRelativeTo(null);
    }

    public Test(final GLCapabilities capabilities) {
        super(capabilities);

        super.setPreferredSize(new Dimension(960, 640));
        super.addGLEventListener(this);
    }

    @Override
    public final void init(final GLAutoDrawable drawable) {}

    @Override
    public final void dispose(final GLAutoDrawable drawable) {}

    @Override
    public final void display(final GLAutoDrawable drawable) {}

    @Override
    public final void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width,
            final int height) {}
}

As you can see there isn't much going on... The code works but it takes about 15 seconds to start. I ran it using -Xprof which resultet in the following output:

Flat profile of 0.01 secs (2 total ticks): TempFileCache-Reaper

  Interpreted + native   Method                        
 50.0%     1  +     0    java.io.File.list
 50.0%     0  +     1    java.io.WinNTFileSystem.delete0
100.0%     1  +     1    Total interpreted

GLProfile#get -> 13296

Flat profile of 13.44 secs (1257 total ticks): main

  Interpreted + native   Method                        
 94.2%     0  +  1162    java.lang.ProcessImpl.create
  2.3%     0  +    28    java.lang.ClassLoader$NativeLibrary.load
  0.5%     6  +     0    java.lang.ClassLoader.defineClass1
  0.2%     0  +     2    java.lang.Class.getDeclaredConstructors0
  0.2%     0  +     2    sun.java2d.d3d.D3DRenderQueue.flushBuffer
  0.2%     0  +     2    java.lang.ProcessImpl.waitForInterruptibly
  0.2%     2  +     0    sun.security.provider.SHA.implCompress
  0.1%     0  +     1    java.io.WinNTFileSystem.getBooleanAttributes
  0.1%     0  +     1    java.io.WinNTFileSystem.canonicalize0
  0.1%     0  +     1    java.net.NetworkInterface.getMacAddr0
  0.1%     0  +     1    sun.reflect.Reflection.getCallerClass
  0.1%     0  +     1    java.io.WinNTFileSystem.list
  0.1%     0  +     1    java.util.zip.ZipFile.open
  0.1%     0  +     1    jogamp.common.os.WindowsDynamicLinkerImpl.LoadLibraryW
  0.1%     0  +     1    java.util.zip.ZipFile.getEntry
  0.1%     0  +     1    java.security.AccessController.doPrivileged
  0.1%     1  +     0    jdk.internal.org.objectweb.asm.ByteVector.<init>
  0.1%     1  +     0    java.awt.Toolkit.initAssistiveTechnologies
  0.1%     1  +     0    sun.java2d.StateTrackableDelegate.getStateTracker
  0.1%     1  +     0    gl4.helloTriangle.Test.main
  0.1%     1  +     0    jdk.internal.org.objectweb.asm.MethodWriter.visitMaxs
  0.1%     1  +     0    java.net.URLStreamHandler.parseURL
  0.1%     1  +     0    com.jogamp.common.os.AndroidVersion.<clinit>
  0.1%     1  +     0    jogamp.nativewindow.jawt.JAWTUtil.getJAWT
  0.1%     0  +     1    java.lang.Class.getEnclosingMethod0
 99.2%    17  +  1206    Total interpreted (including elided)

         Stub + native   Method                        
  0.2%     0  +     2    java.io.WinNTFileSystem.getBooleanAttributes
  0.1%     0  +     1    java.util.zip.ZipFile.getEntrySize
  0.1%     0  +     1    java.lang.ClassLoader.findBootstrapClass
  0.1%     0  +     1    java.lang.Throwable.fillInStackTrace
  0.1%     0  +     1    jogamp.common.os.WindowsDynamicLinkerImpl.LoadLibraryW
  0.5%     0  +     6    Total stub

  Thread-local ticks:
  1.9%    24             Blocked (of total)
  0.3%     4             Class loader


Flat profile of 2.08 secs (197 total ticks): D3D Screen Updater

  Thread-local ticks:
100.0%   197             Blocked (of total)


Flat profile of 2.59 secs (236 total ticks): main-SharedResourceRunner

  Interpreted + native   Method                        
 20.8%     0  +     5    jogamp.nativewindow.windows.GDI.DescribePixelFormat1
 12.5%     0  +     3    jogamp.nativewindow.windows.GDIUtil.CreateDummyDispatchThread0
  4.2%     1  +     0    com.jogamp.gluegen.runtime.ProcAddressTable.isAddressField
  4.2%     1  +     0    jogamp.opengl.windows.wgl.WindowsWGLContext.getExtensionNameMap
  4.2%     0  +     1    jogamp.opengl.windows.wgl.WGL.dispatch_wglMakeCurrent0
  4.2%     1  +     0    sun.misc.URLClassPath$JarLoader$2.<init>
  4.2%     1  +     0    java.lang.Class.searchFields
  4.2%     1  +     0    sun.misc.URLClassPath$JarLoader.checkResource
  4.2%     1  +     0    jogamp.common.os.WindowsDynamicLinkerImpl.lookupSymbolLocalImpl
  4.2%     1  +     0    java.util.zip.ZipEntry.<init>
  4.2%     1  +     0    java.util.HashMap.resize
 70.8%     8  +     9    Total interpreted

     Compiled + native   Method                        
  4.2%     0  +     1    com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver.resolve
  4.2%     0  +     1    java.lang.AbstractStringBuilder.append
  4.2%     0  +     1    java.lang.reflect.Field.copy
  4.2%     0  +     1    jogamp.common.os.WindowsDynamicLinkerImpl.lookupSymbolLocalImpl
  4.2%     0  +     1    com.jogamp.common.os.DynamicLibraryBundle.dynamicLookupFunction
  4.2%     0  +     1    com.jogamp.gluegen.runtime.opengl.GLNameResolver.getFuncNamePermutation
 25.0%     0  +     6    Total compiled

         Stub + native   Method                        
  4.2%     0  +     1    jogamp.common.os.WindowsDynamicLinkerImpl.GetProcAddressA
  4.2%     0  +     1    Total stub

  Thread-local ticks:
 89.8%   212             Blocked (of total)


Flat profile of 0.01 secs (1 total ticks): NativeWindowFactory_ShutdownHook

  Interpreted + native   Method                        
100.0%     1  +     0    jogamp.opengl.egl.EGLDrawableFactory.shutdownImpl
100.0%     1  +     0    Total interpreted


Flat profile of 2.98 secs (267 total ticks): AWT-Windows

  Interpreted + native   Method                        
 99.3%     0  +   265    sun.awt.windows.WToolkit.eventLoop
  0.7%     0  +     2    sun.java2d.d3d.D3DGraphicsDevice.getDeviceCapsNative
100.0%     0  +   267    Total interpreted


Flat profile of 0.10 secs (10 total ticks): Thread-2

  Interpreted + native   Method                        
100.0%     0  +    10    sun.awt.windows.WToolkit.shutdown
100.0%     0  +    10    Total interpreted


Flat profile of 2.18 secs (207 total ticks): DestroyJavaVM

  Thread-local ticks:
100.0%   207             Blocked (of total)


Flat profile of 2.97 secs (267 total ticks): AWT-EventQueue-0

  Interpreted + native   Method                        
  7.1%     0  +     1    sun.awt.windows.WGlobalCursorManager.getCursorPos
  7.1%     0  +     1    sun.awt.windows.WGlobalCursorManager.findHeavyweightUnderCursor
  7.1%     0  +     1    jogamp.opengl.gl4.GL4bcImpl.dispatch_glLinkProgram1
  7.1%     0  +     1    sun.awt.windows.WInputMethod.enableNativeIME
  7.1%     0  +     1    sun.awt.windows.WGlobalCursorManager.setCursor
  7.1%     0  +     1    jogamp.opengl.gl4.GL4bcImpl.dispatch_glFramebufferRenderbuffer1
  7.1%     0  +     1    jogamp.opengl.windows.wgl.WGL.dispatch_wglMakeCurrent0
  7.1%     0  +     1    jogamp.opengl.gl4.GL4bcImpl.dispatch_glReadPixels1
 57.1%     0  +     8    Total interpreted

         Stub + native   Method                        
  7.1%     0  +     1    java.lang.Object.hashCode
  7.1%     0  +     1    java.lang.Thread.currentThread
  7.1%     0  +     1    java.io.WinNTFileSystem.getBooleanAttributes
  7.1%     0  +     1    java.util.zip.ZipFile.getEntry
  7.1%     0  +     1    sun.awt.windows.WGlobalCursorManager.setCursor
  7.1%     0  +     1    java.lang.ClassLoader.defineClass1
 42.9%     0  +     6    Total stub

  Thread-local ticks:
 94.8%   253             Blocked (of total)


Flat profile of 3.07 secs (277 total ticks): AWT-Shutdown

  Thread-local ticks:
100.0%   277             Blocked (of total)


Flat profile of 3.07 secs (277 total ticks): Java2D Disposer

  Thread-local ticks:
100.0%   277             Blocked (of total)


Global summary of 15.62 seconds:
100.0%  1464             Received ticks
  2.3%    33             Compilation
  0.3%     4             Class loader

(Note that GLProfile#get blocks for ~13s!)

I already tested HelloTriangle which leads to the same result (except for that everything is working perfectly fine, constant FPS etc.).

What am I doing wrong? I'm on Windows 10 using Nvidia GTX by the way.

Unlike JOGL Jar runs fine on my development machine, but slowly on others? Even if they have better hardware, I don't have any problems with FPS/textures, only starting the program takes too long.

来源:https://stackoverflow.com/questions/40851464/jogl-takes-too-long-to-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!