Hi,
There is a freeze when running Java3d 1.6.1 (JRE 8) application w/ jogl 2.4 on macosx Sonoma. My code is asking for .getBestConfiguration(template) from the GraphicsDevice; The log file is below: ---------------------- "J3D-Renderer-1" #766 prio=5 os_prio=31 tid=0x00007f7a51c01000 nid=0x24f03 in Object.wait() [0x000070001c1de000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:502) at jogamp.nativewindow.macosx.OSXUtil.RunOnMainThread(OSXUtil.java:318) - locked <0x00000007468e4770> (a java.lang.Object) at jogamp.nativewindow.macosx.OSXUtil.CreateNSWindow(OSXUtil.java:161) at jogamp.nativewindow.jawt.macosx.MacOSXJAWTWindow.lockSurfaceImpl(MacOSXJAWTWindow.java:332) at com.jogamp.nativewindow.awt.JAWTWindow.lockSurface(JAWTWindow.java:690) at javax.media.j3d.JoglPipeline$QueryCanvas.addNotify(JoglPipeline.java:8605) at java.awt.Container.addNotify(Container.java:2775) - locked <0x00000006422a7340> (a java.awt.Component$AWTTreeLock) at java.awt.Window.addNotify(Window.java:770) - locked <0x00000006422a7340> (a java.awt.Component$AWTTreeLock) at java.awt.Frame.addNotify(Frame.java:487) - locked <0x00000006422a7340> (a java.awt.Component$AWTTreeLock) at java.awt.Window.show(Window.java:1031) 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 javax.media.j3d.JoglPipeline.getBestConfiguration(JoglPipeline.java:8379) at javax.media.j3d.Renderer.doWork(Renderer.java:496) at javax.media.j3d.J3dThread.run(J3dThread.java:271) ---------------------------------------- Thanks for any advise! |
Administrator
|
Hello Julien,
Thank you for your responce. The fragment of code is listed below. Actually, the issue cannot be reproduced repeatedly. This code (.getBestConfiguration(template)) freezes on the particular mac only. On my mac I wasn't able to reproduce that issue at all. Probably, the problem is with mac configuration or execution environment. It would be nice if you can give me some tips what should be tested on the problematic mac to find out the source of the problem. ------------------------------------------------------------ final GraphicsEnvironment l_env = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice l_default = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); final GraphicsDevice[] l_devices = l_env.getScreenDevices(); final GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D(); template.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED); try { defaultGraphicsConfiguration = l_default.getBestConfiguration(template); for (GraphicsDevice gd : l_devices) { if (!gd.equals(l_default)) { graphicsConfigurations.add(gd.getBestConfiguration(template)); } } } catch (Exception ex) { ex.printStackTrace(); } -------------------------------------------------------------- private static GraphicsConfiguration defaultGraphicsConfiguration; private static ArrayList<GraphicsConfiguration> graphicsConfigurations; -------------------------------------------------------------- Thank you! |
Administrator
|
Sorry but I need an SSCCE, not only a fragment of code.
Please indicate what differs between the environment in which it just works and the environment in which it doesn't work, the operating system, the hardware, the version of Java. We don't have enough information to help you.
Julien Gouesse | Personal blog | Website
|
I cannot provide reasonable SSCCE that covers all the aspects of the big application. And I don't want to put someone digging large amount of code to find answear for me. So let's close this topic cause I can't supply the required information.
Anyway, Thank you for trying to help! |
Administrator
|
As you wish, but Apple JRE is not supported, Java 8 is obsolete and you can contact Sven to get some commercial support if needed.
Julien Gouesse | Personal blog | Website
|
Thank you for your advise. It works for me.
Bye! |
Administrator
|
Oracle JRE 8 is certified to work with Mac OS X Ventura since its update 351 but there is no certified system configuration for Sonoma yet as far as I know. By using a very old version of Java, you risk to be alone with your bugs. If you switch to a more recent version, you'll have to use some "--add-opens" and "--add-exports" clauses to make it work.
Julien Gouesse | Personal blog | Website
|
Alright, thank you!
|
This post was updated on .
In reply to this post by vs3d
I'm having the exact same issue.
I really tried to create a working (or well, broken) SSCCE, but couldn't reproduce the bug in the SSCCE; I can only produce it in my program. Anyway, the following file depicts how my program works: Test3D.java. ------------ Stack (not of the SSCCE, but of my actual program when it freezes) ------------ wait:-1, Object (java.lang) wait:338, Object (java.lang) RunOnMainThread:318, OSXUtil (jogamp.nativewindow.macosx) CreateNSWindow:161, OSXUtil (jogamp.nativewindow.macosx) lockSurfaceImpl:311, MacOSXJAWTWindow (jogamp.nativewindow.jawt.macosx) lockSurface:708, JAWTWindow (com.jogamp.nativewindow.awt) createJAWTDrawableAndContext:724, GLCanvas (com.jogamp.opengl.awt) addNotify:619, GLCanvas (com.jogamp.opengl.awt) addNotify:2804, Container (java.awt) addNotify:4839, JComponent (javax.swing) addNotify:2804, Container (java.awt) addNotify:4839, JComponent (javax.swing) addNotify:2804, Container (java.awt) addNotify:4839, JComponent (javax.swing) addNotify:729, JRootPane (javax.swing) addNotify:2804, Container (java.awt) addNotify:791, Window (java.awt) addNotify:495, Frame (java.awt) show:1053, Window (java.awt) show:1728, Component (java.awt) setVisible:1675, Component (java.awt) setVisible:1036, Window (java.awt) actionPerformed:693, BasicFrame$19 (net.sf.openrocket.gui.main) <----- This action sets the PhotoFrame visible fireActionPerformed:1972, AbstractButton (javax.swing) actionPerformed:2313, AbstractButton$Handler (javax.swing) fireActionPerformed:405, DefaultButtonModel (javax.swing) setPressed:262, DefaultButtonModel (javax.swing) doClick:374, AbstractButton (javax.swing) actionPerformed:129, ScreenMenuItem (com.apple.laf) processActionEvent:692, MenuItem (java.awt) processEvent:651, MenuItem (java.awt) dispatchEventImpl:379, MenuComponent (java.awt) dispatchEvent:367, MenuComponent (java.awt) dispatchEventImpl:776, EventQueue (java.awt) run:722, EventQueue$4 (java.awt) run:716, EventQueue$4 (java.awt) executePrivileged:776, AccessController (java.security) doPrivileged:399, AccessController (java.security) doIntersectionPrivilege:86, ProtectionDomain$JavaSecurityAccessImpl (java.security) doIntersectionPrivilege:97, ProtectionDomain$JavaSecurityAccessImpl (java.security) run:746, EventQueue$5 (java.awt) run:744, EventQueue$5 (java.awt) executePrivileged:776, AccessController (java.security) doPrivileged:399, AccessController (java.security) doIntersectionPrivilege:86, ProtectionDomain$JavaSecurityAccessImpl (java.security) dispatchEvent:743, EventQueue (java.awt) pumpOneEventForFilters:203, EventDispatchThread (java.awt) pumpEventsForFilter:124, EventDispatchThread (java.awt) pumpEventsForHierarchy:113, EventDispatchThread (java.awt) pumpEvents:109, EventDispatchThread (java.awt) pumpEvents:101, EventDispatchThread (java.awt) run:90, EventDispatchThread (java.awt) ------------ Thread dump (not of the SSCCE, but of my application when the freeze happens) ------------ Full thread dump "AWT-EventQueue-0@1810" prio=6 tid=0x16 nid=NA waiting java.lang.Thread.State: WAITING at java.lang.Object.wait(Object.java:-1) at java.lang.Object.wait(Object.java:338) at jogamp.nativewindow.macosx.OSXUtil.RunOnMainThread(OSXUtil.java:318) at jogamp.nativewindow.macosx.OSXUtil.CreateNSWindow(OSXUtil.java:161) at jogamp.nativewindow.jawt.macosx.MacOSXJAWTWindow.lockSurfaceImpl(MacOSXJAWTWindow.java:311) at com.jogamp.nativewindow.awt.JAWTWindow.lockSurface(JAWTWindow.java:708) at com.jogamp.opengl.awt.GLCanvas.createJAWTDrawableAndContext(GLCanvas.java:724) at com.jogamp.opengl.awt.GLCanvas.addNotify(GLCanvas.java:619) at java.awt.Container.addNotify(Container.java:2804) - locked <0x205b> (a java.awt.Component$AWTTreeLock) at javax.swing.JComponent.addNotify(JComponent.java:4839) at java.awt.Container.addNotify(Container.java:2804) at javax.swing.JComponent.addNotify(JComponent.java:4839) at java.awt.Container.addNotify(Container.java:2804) at javax.swing.JComponent.addNotify(JComponent.java:4839) at javax.swing.JRootPane.addNotify(JRootPane.java:729) at java.awt.Container.addNotify(Container.java:2804) at java.awt.Window.addNotify(Window.java:791) at java.awt.Frame.addNotify(Frame.java:495) at java.awt.Window.show(Window.java:1053) at java.awt.Component.show(Component.java:1728) at java.awt.Component.setVisible(Component.java:1675) at java.awt.Window.setVisible(Window.java:1036) at net.sf.openrocket.gui.main.BasicFrame$19.actionPerformed(BasicFrame.java:693) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262) at javax.swing.AbstractButton.doClick(AbstractButton.java:374) at com.apple.laf.ScreenMenuItem.actionPerformed(ScreenMenuItem.java:129) at java.awt.MenuItem.processActionEvent(MenuItem.java:692) at java.awt.MenuItem.processEvent(MenuItem.java:651) at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:379) at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:367) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776) at java.awt.EventQueue$4.run(EventQueue.java:722) at java.awt.EventQueue$4.run(EventQueue.java:716) at java.security.AccessController.executePrivileged(AccessController.java:776) at java.security.AccessController.doPrivileged(AccessController.java:399) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97) at java.awt.EventQueue$5.run(EventQueue.java:746) at java.awt.EventQueue$5.run(EventQueue.java:744) at java.security.AccessController.executePrivileged(AccessController.java:776) at java.security.AccessController.doPrivileged(AccessController.java:399) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.awt.EventQueue.dispatchEvent(EventQueue.java:743) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) "TimerQueue@6960" daemon prio=5 tid=0x20 nid=NA waiting java.lang.Thread.State: WAITING at jdk.internal.misc.Unsafe.park(Unsafe.java:-1) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:341) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(AbstractQueuedSynchronizer.java:506) at java.util.concurrent.ForkJoinPool.unmanagedBlock(ForkJoinPool.java:3463) at java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3434) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1623) at java.util.concurrent.DelayQueue.take(DelayQueue.java:217) at javax.swing.TimerQueue.run(TimerQueue.java:172) at java.lang.Thread.run(Thread.java:833) "AppKit Thread@1357" daemon prio=5 tid=0x11 nid=NA runnable java.lang.Thread.State: RUNNABLE at sun.lwawt.macosx.LWCToolkit.doAWTRunLoopImpl(LWCToolkit.java:-1) at sun.lwawt.macosx.LWCToolkit.doAWTRunLoop(LWCToolkit.java:931) at sun.lwawt.macosx.LWCToolkit.invokeAndWait(LWCToolkit.java:733) at sun.lwawt.macosx.LWCToolkit.invokeAndWait(LWCToolkit.java:678) at sun.lwawt.macosx.CAccessibility.invokeAndWait(CAccessibility.java:121) at sun.lwawt.macosx.CAccessibility.getFocusOwner(CAccessibility.java:619) "Common-Cleaner@8245" daemon prio=8 tid=0xc nid=NA waiting java.lang.Thread.State: WAITING at java.lang.Object.wait(Object.java:-1) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:155) at jdk.internal.ref.CleanerImpl.run(CleanerImpl.java:140) at java.lang.Thread.run(Thread.java:833) at jdk.internal.misc.InnocuousThread.run(InnocuousThread.java:162) "Java2D Queue Flusher@1565" daemon prio=10 tid=0x14 nid=NA waiting java.lang.Thread.State: WAITING at java.lang.Object.wait(Object.java:-1) at sun.java2d.opengl.OGLRenderQueue$QueueFlusher.run(OGLRenderQueue.java:206) at java.lang.Thread.run(Thread.java:833) "Reference Handler@8242" daemon prio=10 tid=0x2 nid=NA runnable java.lang.Thread.State: RUNNABLE at java.lang.ref.Reference.waitForReferencePendingList(Reference.java:-1) at java.lang.ref.Reference.processPendingReferences(Reference.java:253) at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:215) "Finalizer@8243" daemon prio=8 tid=0x3 nid=NA waiting java.lang.Thread.State: WAITING at java.lang.Object.wait(Object.java:-1) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:155) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:176) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:172) "AWT-Shutdown@1360" prio=5 tid=0x12 nid=NA waiting java.lang.Thread.State: WAITING at java.lang.Object.wait(Object.java:-1) at java.lang.Object.wait(Object.java:338) at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:291) at java.lang.Thread.run(Thread.java:833) "Java2D Disposer@1727" daemon prio=10 tid=0x15 nid=NA waiting java.lang.Thread.State: WAITING at java.lang.Object.wait(Object.java:-1) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:155) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:176) at sun.java2d.Disposer.run(Disposer.java:145) at java.lang.Thread.run(Thread.java:833) "Timer-0@2420" daemon prio=6 tid=0x18 nid=NA waiting java.lang.Thread.State: WAITING at java.lang.Object.wait(Object.java:-1) at java.util.TimerThread.mainLoop(Timer.java:563) at java.util.TimerThread.run(Timer.java:516) "doubleClickTimer@7834" prio=6 tid=0x24 nid=NA waiting java.lang.Thread.State: WAITING at java.lang.Object.wait(Object.java:-1) at java.lang.Object.wait(Object.java:338) at java.util.TimerThread.mainLoop(Timer.java:537) at java.util.TimerThread.run(Timer.java:516) "doubleClickTimer@7925" prio=6 tid=0x25 nid=NA waiting java.lang.Thread.State: WAITING at java.lang.Object.wait(Object.java:-1) at java.lang.Object.wait(Object.java:338) at java.util.TimerThread.mainLoop(Timer.java:537) at java.util.TimerThread.run(Timer.java:516) "Signal Dispatcher@8244" daemon prio=9 tid=0x4 nid=NA runnable java.lang.Thread.State: RUNNABLE "Notification Thread@662" daemon prio=9 tid=0x10 nid=NA runnable java.lang.Thread.State: RUNNABLE "DestroyJavaVM@8076" prio=5 tid=0x26 nid=NA runnable java.lang.Thread.State: RUNNABLE ------------ JoglVersion.getInstance().toString(gl) (ran in the SSCCE) ------------ Package: com.jogamp.opengl Extension Name: com.jogamp.opengl Specification Title: Java Bindings for OpenGL API Specification Specification Vendor: JogAmp Community Specification Version: 2.5 Implementation Title: Java Bindings for OpenGL Runtime Environment Implementation Vendor: JogAmp Community Implementation Vendor ID: com.jogamp Implementation URL: http://jogamp.org/ Implementation Version: 2.5.0 Implementation Build: 2.5-b1533-20230818 Implementation Branch: origin/master Implementation Commit: 70f62ca5d121e5e71548246d468b5e7baa5faf25 Implementation SHA Sources: null Implementation SHA Classes: null Implementation SHA Classes-this: null Implementation SHA Natives: null Implementation SHA Natives-this: null ----------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------- MacOSXGraphicsDevice[type .macosx, connection decon, unitID 0, handle 0x0, owner false, NullToolkitLock[obj 0x55979826]]: Natives GL4bc false GL4 true [4.1 (Core profile, arb, compat[ES2, ES3], FBO, hardware)] GLES3 false GL3bc false GL3 true [4.1 (Core profile, arb, compat[ES2, ES3], FBO, hardware)] GL2 true [2.1 (Compat profile, arb, compat[], FBO, hardware)] GLES2 false GLES1 false Count 3 / 8 Common GL4ES3 true GL2GL3 true GL2ES2 true GL2ES1 true Mappings GL2ES1 GLProfile[GL2ES1/GL2.hw] GL4ES3 GLProfile[GL4ES3/GL4.hw] GL2ES2 GLProfile[GL2ES2/GL4.hw] GL2 GLProfile[GL2/GL2.hw] GL4 GLProfile[GL4/GL4.hw] GL3 GLProfile[GL3/GL4.hw] GL2GL3 GLProfile[GL2GL3/GL4.hw] default GLProfile[GL2/GL2.hw] Count 7 / 12 Swap Interval 0 GL Profile GLProfile[GL2/GL2.hw] GL Version 2.1 (Compat profile, arb, compat[], FBO, hardware) - 2.1 Metal - 86 [GL 2.1.0, vendor 0.0.0 (n/a)] Quirks [NoOffscreenBitmap, GL4NeedsGL3Request, NeedSharedObjectSync] Impl. class jogamp.opengl.gl4.GL4bcImpl GL_VENDOR Apple GL_RENDERER Apple M1 Pro GL_VERSION 2.1 Metal - 86 GLSL true, has-compiler-func: true, version: 1.20 / 1.20.0 GL FBO: basic true, full true GL_EXTENSIONS 133 GLX_EXTENSIONS 0<quote author="vs3d"> |
Administrator
|
Please use at least a more recent version of Java with Java3D >= 1.7 (different package namespace than Java3D 1.6). You can't expect things to work well by using the very latest version of OS X with an obsolete JRE. As you can't provide a SSCCE, you can't completely exclude the possibility that the problems lies in your application. I advise you to contact Sven for commercial support.
Julien Gouesse | Personal blog | Website
|
I run my application with JRE 17. Same issue happened when running with JRE 11. Sorry, the last part of my original post accidentally included the original post of this thread. These is my setup:
JOGL version: 2.5.0 Current default locale: en_BE System properties: apple.laf.useScreenMenuBar=true com.apple.mrj.application.apple.menu.about.name=OpenRocket exe4j.moduleName=/Applications/OpenRocket.app file.encoding=UTF-8 file.separator=/ i4j.jreBundle=/Applications/OpenRocket.app/Contents/Resources/jre.bundle i4j.ownBundlePath=/Applications/OpenRocket.app java.class.path=/Applications/OpenRocket.app/Contents/Resources/app/.install4j/i4jruntime.jar:/Applications/OpenRocket.app/Contents/Resources/app/OpenRocket.jar java.class.version=61.0 java.home=/Applications/OpenRocket.app/Contents/Resources/jre.bundle/Contents/Home java.io.tmpdir=/var/folders/cn/j3pmm_jd2mgfnhmfp9sqnn440000gn/T/ java.library.path=/Users/SiboVanGool/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:. java.runtime.name=OpenJDK Runtime Environment java.runtime.version=17.0.7+7-LTS java.specification.name=Java Platform API Specification java.specification.vendor=Oracle Corporation java.specification.version=17 java.util.Arrays.useLegacyMergeSort=true java.vendor=BellSoft java.vendor.url=https://bell-sw.com/ java.vendor.url.bug=https://bell-sw.com/support java.version=17.0.7 java.version.date=2023-04-18 java.vm.compressedOopsMode=Zero based java.vm.info=mixed mode java.vm.name=OpenJDK 64-Bit Server VM java.vm.specification.name=Java Virtual Machine Specification java.vm.specification.vendor=Oracle Corporation java.vm.specification.version=17 java.vm.vendor=BellSoft java.vm.version=17.0.7+7-LTS jdk.debug=release jnlp.jogamp.tmp.cache.root=jln4138930902534900094 line.separator=\u000a native.encoding=US-ASCII os.arch=aarch64 os.name=Mac OS X os.version=14.0 path.separator=: sun.arch.data.model=64 sun.awt.enableExtraMouseButtons=true sun.awt.exception.handler=net.sf.openrocket.gui.main.SwingExceptionHandler$AwtHandler sun.boot.library.path=/Applications/OpenRocket.app/Contents/Resources/jre.bundle/Contents/Home/lib sun.cpu.endian=little sun.font.fontmanager=sun.font.CFontManager sun.io.unicode.encoding=UnicodeBig sun.java.command=com.install4j.runtime.launcher.MacLauncher sun.java.launcher=SUN_STANDARD sun.jnu.encoding=UTF-8 sun.management.compiler=HotSpot 64-Bit Tiered Compilers user.country=BE user.dir=/Applications/OpenRocket.app/Contents/Resources/app user.language=en user.timezone=Europe/Brussels Thanks for your reply. |
Hi,
Mostly, I think that the 99.9999% of JRE problems lie within the user code. So, I don't think that this issue is a Java problem. Try to add 1-2 seconds delay before running problematic code, or execute it a bit later with SwingUtilities.invokeLater() method. I think that the particular Jogl routine is not re-entrant safe. P.S. If you're running with JavaFX, try to disable 3D in it by adding the following parameters: -Dprism.order\=sw -Dprism.verbose\=true |
Administrator
|
Ok you use Java 17, fine. Do you use the necessary clauses I mentioned? Which JOGL routine are you talking about?
Why do you mention JavaFX? Java3D and JavaFX are two unrelated APIs. I don't understand why you don't provide a SSCCE whereas you seem to have a precise idea of what's wrong.
Julien Gouesse | Personal blog | Website
|
You just mixed two different replies.
P.S. Despite their different API JavaFX uses 3D as well and it does interfere with Java3D in some cases. |
Administrator
|
I can't fix a bug I can't reproduce and I'm not the only one in this category. You risk some trouble by accessing the OpenGL driver and the Direct3D driver at the same time in the same process yes, I assume you used the software renderer to avoid that.
Julien Gouesse | Personal blog | Website
|
Thank you for your patience @gouessej. I was finally able to create an SSCCE of the problem. When I run this Java Swing code, my program freezes:
``` import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.awt.GLCanvas; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Rectangle; public class Test3D { public static void main(String[] args) { JFrame frame = new JFrame(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { frame.setVisible(true); } }); PhotoFrame pa = new PhotoFrame(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { pa.setVisible(true); } }); } private static class PhotoFrame extends JFrame { public PhotoFrame() { PhotoPanel photoPanel = new PhotoPanel(); setContentPane(photoPanel); } } private static class PhotoPanel extends JPanel implements GLEventListener { PhotoPanel() { this.setLayout(new BorderLayout()); initGLCanvas(); } private void initGLCanvas() { Component canvas; try { final GLProfile glp = GLProfile.get(GLProfile.GL2); final GLCapabilities caps = new GLCapabilities(glp); canvas = new GLCanvas(caps); // NOTE: using GLJPanel did not work either this.add(canvas, BorderLayout.CENTER); } catch (Throwable t) { this.add(new JLabel("Unable to load 3d Libraries: " + t.getMessage())); } } @Override public void paintImmediately(Rectangle r) { } @Override public void paintImmediately(int x, int y, int w, int h) { } @Override public void display(final GLAutoDrawable drawable) { } @Override public void init(final GLAutoDrawable drawable) { } @Override public void dispose(GLAutoDrawable glAutoDrawable) { } @Override public void reshape(GLAutoDrawable glAutoDrawable, int i, int i1, int i2, int i3) { } } } ``` However, when I change the order of execution in the main method by first setting PhotoFrame visible and then the normal frame (instead of vice versa), the application does not freeze : ``` public static void main(String[] args) { PhotoFrame pa = new PhotoFrame(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { pa.setVisible(true); } }); JFrame frame = new JFrame(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { frame.setVisible(true); } }); } ``` Another example of a freeze scenario (same code, just different order): ``` public static void main(String[] args) { JFrame frame = new JFrame(); PhotoFrame pa = new PhotoFrame(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { frame.setVisible(true); } }); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { pa.setVisible(true); } }); } ``` In the above code, when switching the order of the two runnables, the application does not freezes. Also when I comment out either one of the runnables, the application does not freezes. Placing the two `setVisible` calls in the same invokeLater call has the same effect: the application only freezes when `frame.setVisible(true);` is called before `pa.setVisible(true);`. |
Okay, I was able to solve the freezing by starting `initGLCanvas()` in a new thread:
``` new Thread(() -> { initGLCanvas(); }).start(); ``` |
I do want to make a final comment that this issue does not occur when running the application on Windows or Linux. It also only started when I first updated macOS to Ventura, then after some days the issue magically disappeared and now when I updated to macOS Sonoma, the issue returned. No code changes were performed; the program stayed exactly the same.
|
Administrator
|
In reply to this post by SiboVG
Thank you for your great contribution. Now we have enough information to fill a bug report but do you reproduce this problem when using an animator, which is the advised way to do things correctly?
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |