Closed sorawee closed 1 year ago
Did you try to upgrade your Java? See https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8195830 https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8195830
On 2 Apr 2018, at 10:47, sorawee notifications@github.com wrote:
I have been encountering this problem for more than one year now: whenever I open the visualizer, no matter what spec it is (even sig A {} run {}), top shows that CPU resources are all taken up by the Xorg and java processes. If I leave the visualizer open for a minute, my CPU fan will become really loud. The visualizer is also very sluggish. Note that this only happens whenever the visualizer is open. It does not happen during solving. And when the problem happens, if I close the visualizer, the problem goes away.
This affects both Alloy 5.0 and 4.2. I am using Thinkpad X1 Yoga, Ubuntu 17.10, but it affects 17.04 as well. My Java version is:
java version "1.8.0_161" Java(TM) SE Runtime Environment (build 1.8.0_161-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode) For what it's worth: running the JAR with the option -Dsun.java2d.xrender=false makes the visualizer less sluggish, though it still consumes a lot of CPU resources. It also fixes a possibly related bug: whenever I rotate my screen and open the JAR normally, I get the following error:
Exception: class java.lang.ClassCastException Message: java.lang.ClassCastException: sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData Stacktrace: class java.lang.ClassCastException: sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData sun.java2d.xr.XRPMBlitLoops.cacheToTmpSurface(XRPMBlitLoops.java:148) sun.java2d.xr.XrSwToPMBlit.Blit(XRPMBlitLoops.java:356) sun.java2d.SurfaceDataProxy.updateSurfaceData(SurfaceDataProxy.java:498) sun.java2d.SurfaceDataProxy.replaceData(SurfaceDataProxy.java:455) sun.java2d.SurfaceData.getSourceSurfaceData(SurfaceData.java:233) sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:566) sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:67) sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:1014) sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:186) sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3318) sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3296) com.sun.java.swing.plaf.gtk.GTKEngine.paintCachedImage(GTKEngine.java:555) com.sun.java.swing.plaf.gtk.GTKPainter.paintScrollBarBackground(GTKPainter.java:1055) javax.swing.plaf.synth.SynthPainter.paintScrollBarBackground(SynthPainter.java:1021) javax.swing.plaf.synth.SynthScrollBarUI.update(SynthScrollBarUI.java:241) javax.swing.JComponent.paintComponent(JComponent.java:780) javax.swing.JComponent.paint(JComponent.java:1056) javax.swing.JComponent.paintChildren(JComponent.java:889) javax.swing.JComponent.paint(JComponent.java:1065) javax.swing.JComponent.paintChildren(JComponent.java:889) javax.swing.JSplitPane.paintChildren(JSplitPane.java:1047) javax.swing.JComponent.paint(JComponent.java:1065) javax.swing.JComponent.paintChildren(JComponent.java:889) javax.swing.JComponent.paint(JComponent.java:1065) javax.swing.JComponent.paintChildren(JComponent.java:889) javax.swing.JComponent.paint(JComponent.java:1065) javax.swing.JLayeredPane.paint(JLayeredPane.java:586) javax.swing.JComponent.paintChildren(JComponent.java:889) javax.swing.JComponent.paint(JComponent.java:1065) javax.swing.JComponent.paintToOffscreen(JComponent.java:5210) javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:290) javax.swing.RepaintManager.paint(RepaintManager.java:1272) javax.swing.JComponent._paintImmediately(JComponent.java:5158) javax.swing.JComponent.paintImmediately(JComponent.java:4969) javax.swing.RepaintManager$4.run(RepaintManager.java:854) javax.swing.RepaintManager$4.run(RepaintManager.java:814) java.security.AccessController.doPrivileged(Native Method) java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814) javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789) javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738) javax.swing.RepaintManager.access$1200(RepaintManager.java:64) javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732) java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756) java.awt.EventQueue.access$500(EventQueue.java:97) java.awt.EventQueue$3.run(EventQueue.java:709) java.awt.EventQueue$3.run(EventQueue.java:703) java.security.AccessController.doPrivileged(Native Method) java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) java.awt.EventQueue.dispatchEvent(EventQueue.java:726) java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) java.awt.EventDispatchThread.run(EventDispatchThread.java:82) Running the JAR with -Dsun.java2d.xrender=false fixes the problem.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AlloyTools/org.alloytools.alloy/issues/40, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMPLtD7Nw3BMmatmMPETDpZfw1Yehbbks5tkeWWgaJpZM4TDTpj.
-Dsun.java2d.xrender=false fixes the CPU problem for me but the interface becomes unusable.
I will try updating my JDK and see if it improves.
Also, why not electron here for the UI?
@pkriens @sorawee I am getting the following stack trace with openjdk 9 as I launch alloy 5.
Stack: [0x00007ff475b5e000,0x00007ff475c5f000], sp=0x00007ff475c59f00, free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libjava.so+0x1d009] JNU_GetEnv+0x19
C [libfontmanager.so+0x33f8e]
C [libfreetype.so.6+0x14d2b] FT_Stream_Seek+0x1b
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j sun.font.FreetypeFontScaler.initNativeScaler(Lsun/font/Font2D;IIZI)J+0 java.desktop@9-internal
j sun.font.FreetypeFontScaler.<init>(Lsun/font/Font2D;IZI)V+26 java.desktop@9-internal
v ~StubRoutines::call_stub
j sun.reflect.NativeConstructorAccessorImpl.newInstance0(Ljava/lang/reflect/Constructor;[Ljava/lang/Object;)Ljava/lang/Object;+0 java.base@9-internal
j sun.reflect.NativeConstructorAccessorImpl.newInstance([Ljava/lang/Object;)Ljava/lang/Object;+85 java.base@9-internal
J 950 C1 java.base@9-internal9-internal (9 bytes) @ 0x00007ff50a385324 [0x00007ff50a385220+0x0000000000000104]
J 945 C1 java.base@9-internal9-internal (73 bytes) @ 0x00007ff50a382c64 [0x00007ff50a382900+0x0000000000000364]
j sun.font.FontScaler.getScaler(Lsun/font/Font2D;IZI)Lsun/font/FontScaler;+39 java.desktop@9-internal
j sun.font.TrueTypeFont.getScaler()Lsun/font/FontScaler;+21 java.desktop@9-internal
j sun.font.FileFontStrike.<init>(Lsun/font/FileFont;Lsun/font/FontStrikeDesc;)V+204 java.desktop@9-internal
j sun.font.FileFont.createStrike(Lsun/font/FontStrikeDesc;)Lsun/font/FontStrike;+18 java.desktop@9-internal
j sun.font.Font2D.getStrike(Lsun/font/FontStrikeDesc;Z)Lsun/font/FontStrike;+92 java.desktop@9-internal
j sun.font.Font2D.getStrike(Lsun/font/FontStrikeDesc;)Lsun/font/FontStrike;+3 java.desktop@9-internal
j sun.font.CompositeStrike.getStrikeForSlot(I)Lsun/font/PhysicalStrike;+23 java.desktop@9-internal
j sun.font.CompositeStrike.getFontMetrics()Lsun/font/StrikeMetrics;+31 java.desktop@9-internal
j sun.font.FontDesignMetrics.initMatrixAndMetrics()V+28 java.desktop@9-internal
j sun.font.FontDesignMetrics.<init>(Ljava/awt/Font;Ljava/awt/font/FontRenderContext;)V+62 java.desktop@9-internal
j sun.font.FontDesignMetrics.getMetrics(Ljava/awt/Font;Ljava/awt/font/FontRenderContext;)Lsun/font/FontDesignMetrics;+128 java.desktop@9-internal
j sun.swing.SwingUtilities2.getFontMetrics(Ljavax/swing/JComponent;Ljava/awt/Font;)Ljava/awt/FontMetrics;+15 java.desktop@9-internal
j javax.swing.JComponent.getFontMetrics(Ljava/awt/Font;)Ljava/awt/FontMetrics;+2 java.desktop@9-internal
j sun.swing.MenuItemLayoutHelper.reset(Ljavax/swing/JMenuItem;Ljavax/swing/Icon;Ljavax/swing/Icon;Ljava/awt/Rectangle;ILjava/lang/String;ZLjava/awt/Font;Ljava/awt/Font;ZLjava/lang/String;)V+77 java.desktop@9-internal
j javax.swing.plaf.synth.SynthMenuItemLayoutHelper.<init>(Ljavax/swing/plaf/synth/SynthContext;Ljavax/swing/plaf/synth/SynthContext;Ljavax/swing/JMenuItem;Ljavax/swing/Icon;Ljavax/swing/Icon;Ljava/awt/Rectangle;ILjava/lang/String;ZZLjava/lang/String;)V+98 java.desktop@9-internal
j javax.swing.plaf.synth.SynthGraphicsUtils.getPreferredMenuItemSize(Ljavax/swing/plaf/synth/SynthContext;Ljavax/swing/plaf/synth/SynthContext;Ljavax/swing/JComponent;Ljavax/swing/Icon;Ljavax/swing/Icon;ILjava/lang/String;ZLjava/lang/String;)Ljava/awt/Dimension;+33 java.desktop@9-internal
j javax.swing.plaf.synth.SynthMenuUI.getPreferredMenuItemSize(Ljavax/swing/JComponent;Ljavax/swing/Icon;Ljavax/swing/Icon;I)Ljava/awt/Dimension;+41 java.desktop@9-internal
j javax.swing.plaf.basic.BasicMenuItemUI.getPreferredSize(Ljavax/swing/JComponent;)Ljava/awt/Dimension;+14 java.desktop@9-internal
j javax.swing.JComponent.getPreferredSize()Ljava/awt/Dimension;+26 java.desktop@9-internal
j javax.swing.BoxLayout.checkRequests()V+111 java.desktop@9-internal
j javax.swing.BoxLayout.preferredLayoutSize(Ljava/awt/Container;)Ljava/awt/Dimension;+10 java.desktop@9-internal
j javax.swing.plaf.basic.DefaultMenuLayout.preferredLayoutSize(Ljava/awt/Container;)Ljava/awt/Dimension;+40 java.desktop@9-internal
j javax.swing.plaf.synth.SynthMenuLayout.preferredLayoutSize(Ljava/awt/Container;)Ljava/awt/Dimension;+22 java.desktop@9-internal
j java.awt.Container.preferredSize()Ljava/awt/Dimension;+43 java.desktop@9-internal
j java.awt.Container.getPreferredSize()Ljava/awt/Dimension;+1 java.desktop@9-internal
j javax.swing.JComponent.getPreferredSize()Ljava/awt/Dimension;+39 java.desktop@9-internal
j javax.swing.JRootPane$RootLayout.preferredLayoutSize(Ljava/awt/Container;)Ljava/awt/Dimension;+68 java.desktop@9-internal
j java.awt.Container.preferredSize()Ljava/awt/Dimension;+43 java.desktop@9-internal
j java.awt.Container.getPreferredSize()Ljava/awt/Dimension;+1 java.desktop@9-internal
j javax.swing.JComponent.getPreferredSize()Ljava/awt/Dimension;+39 java.desktop@9-internal
j java.awt.BorderLayout.preferredLayoutSize(Ljava/awt/Container;)Ljava/awt/Dimension;+157 java.desktop@9-internal
j java.awt.Container.preferredSize()Ljava/awt/Dimension;+43 java.desktop@9-internal
j java.awt.Container.getPreferredSize()Ljava/awt/Dimension;+1 java.desktop@9-internal
j java.awt.Window.pack()V+32 java.desktop@9-internal
j edu.mit.csail.sdg.alloy4viz.VizGUI.<init>(ZLjava/lang/String;Ljavax/swing/JMenu;Ledu/mit/csail/sdg/alloy4/Computer;Ledu/mit/csail/sdg/alloy4/Computer;Z)V+1357
j edu.mit.csail.sdg.alloy4viz.VizGUI.<init>(ZLjava/lang/String;Ljavax/swing/JMenu;Ledu/mit/csail/sdg/alloy4/Computer;Ledu/mit/csail/sdg/alloy4/Computer;)V+9
j edu.mit.csail.sdg.alloy4whole.SimpleGUI.finishInit([Ljava/lang/String;I)V+401
j edu.mit.csail.sdg.alloy4whole.SimpleGUI.<init>([Ljava/lang/String;)V+661
j edu.mit.csail.sdg.alloy4whole.SimpleGUI.<init>([Ljava/lang/String;Ledu/mit/csail/sdg/alloy4whole/SimpleGUI;)V+2
j edu.mit.csail.sdg.alloy4whole.SimpleGUI$7.run()V+8
j java.awt.event.InvocationEvent.dispatch()V+47 java.desktop@9-internal
j java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V+21 java.desktop@9-internal
j java.awt.EventQueue.access$500(Ljava/awt/EventQueue;Ljava/awt/AWTEvent;Ljava/lang/Object;)V+3 java.desktop@9-internal
j java.awt.EventQueue$3.run()Ljava/lang/Void;+32 java.desktop@9-internal
j java.awt.EventQueue$3.run()Ljava/lang/Object;+1 java.desktop@9-internal
v ~StubRoutines::call_stub
j java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;+0 java.base@9-internal
j java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object;+18 java.base@9-internal
j java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V+46 java.desktop@9-internal
j java.awt.EventDispatchThread.pumpOneEventForFilters(I)V+183 java.desktop@9-internal
j java.awt.EventDispatchThread.pumpEventsForFilter(ILjava/awt/Conditional;Ljava/awt/EventFilter;)V+35 java.desktop@9-internal
j java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+11 java.desktop@9-internal
j java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4 java.desktop@9-internal
j java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3 java.desktop@9-internal
j java.awt.EventDispatchThread.run()V+9 java.desktop@9-internal
v ~StubRoutines::call_stub
Could you try Alloy 6.x on a later Java? Please reopen this bug if you still see this problem
I have had the problems of CPU resource consumption a few years now already. Initially I only realized that my notebook became warm / hot when using Alloy. Later I realized that the fan started running when I used the visualizer and only recently I actually checked it using top and identified the 100% CPU consumption on XOrg.
Issues appeared under Ubuntu 20.04 and 22.04 with Alloy 5.x and Alloy 6.x and also with the most recent version built on my laptop.
I think I have found the reason for it (awt graphics feedback loop) and have prepared a patch in a branch. Will create a pull request.
what Java version/distribution are you using and did you try other versions distributions?
Over the last couple of years I have used different versions of Java, all providing the same problem (and providing no traps, only a high cpu resource consumption). I have not tried to use a different version just recently. If you want me to, I can try other versions.
Currently, I use
Ubuntu 22.04 openjdk version "11.0.20.1" 2023-08-24
Please note that I have been able to remove the high cpu load with the patch that I have provided as a pull request. Without knowing awfully much about awt, swing and Java generally, I thought that changing a property of a graphics component within a draw method is probably not a good idea. Having initially changed this to only become set when really necessary had the same effect compared to what I have suggested in the pull request:
@Override
public void paint(Graphics g) {
super.paint(g);
if (split.getDividerLocation() != split.getSize().height - split.getInsets().bottom - split.getDividerSize() - split.getRightComponent().getPreferredSize().height){
split.setDividerLocation(split.getSize().height - split.getInsets().bottom - split.getDividerSize() - split.getRightComponent().getPreferredSize().height);
}
}
But maybe I am already talking too much about a solution when you want to hear about the problem.
I do agree that code should not be in the heavily used pain method. I will accept yoiur PR and test it.
I have now tested the most recent build (without my fix) Alloy Analyzer . . 6.1.0 built 2021-11-03T15:25:43.736Z with openjdk 11.0.20.1 2023-08-24 openjdk 17.0.8.1 2023-08-24 openjdk 18.0.2-ea 2022-07-19 openjdk 19.0.2 2023-01-17 and for all of these the xorg 100% load occurs in the moment I open the visualizer.
But you're PR fixes this?
Yes, it does. I have also double-checked this now for all the openjdk versions listed above with a fresh checkout from the repo that includes the PR.
Thanks for the work. It looks pretty bizar. the person that did this code in the pain method seemed to have had no good understanding how often it was called.
I have been encountering this problem for more than one year now: whenever I open the visualizer, no matter what spec it is (even
sig A {} run {}
),top
shows that CPU resources are all taken up by theXorg
andjava
processes. If I leave the visualizer open for a minute, my CPU fan will become really loud. The visualizer is also very sluggish. Note that this only happens whenever the visualizer is open. It does not happen during solving. And when the problem happens, if I close the visualizer, the problem goes away.This affects both Alloy 5.0 and 4.2. I am using Thinkpad X1 Yoga, Ubuntu 17.10, but it affects 17.04 as well. My Java version is:
For what it's worth: running the JAR with the option
-Dsun.java2d.xrender=false
makes the visualizer less sluggish, though it still consumes a lot of CPU resources. It also fixes a possibly related bug: whenever I rotate my screen and open the JAR normally, I get the following error:Running the JAR with
-Dsun.java2d.xrender=false
fixes the problem.