Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 8 Swing rendering problem with Intel HD 3700 linux

I developed an application in java 8 update 181 in Kubuntu 18.04. In my development PC, I have Intel i3-6100 with Intel® HD Graphics 530. All the graphics are done using swing and with this hardware configuration, everything works as it should.

On the production PC, I have Intel(R) Celeron(R) CPU J1900 with Intel® HD Graphics for Intel Atom® Processor Z3700 Series. Running the same with same OS and java version I noticed problems with my graphics done in swing.

  1. Swing components like jLabels, jButton etc. not updating. For example frame A has label B with text "Old text", I update the text on the label B with the text "New text", then I call setVisible(true) to frame A, the frame becomes visible with the text "Old text". This is not happening every time, sometimes it does the update, sometimes I don't. This is still happening in an event that I added SwingUtilities as apart from my solution, mentioned below.
  2. In labels where I have .gif animation not running smoothly, or they freeze.
  3. Swapping active frames (changing visibly on the second to true, and on the first to false) has some delays.
  4. After a period of time, the GUI application freezes and continues to work after some time, sometimes after a few minutes, sometimes after a few seconds.

So after searching on many forums, I did the following changes on my application

  1. Started using SwingUtilities.invokeLater() or SwingUtilities.invokeAndWait() (where I want to change something before showing it, for example, if a price for a service is 80.00 update and then show it) everywhere I update my GUI components.
  2. After every update on component i call component.revalidate() and component.repaint() or repaint(50).
  3. Every time I call frame.setVisible(status) I wait for the signal from the windowListener that the frame is activated and opened, or deactivated and closed depending on calling with true or false as status.
  4. After still having problems with swing components not updating I tried setting the frame visible and than updating all its components. This works fine for some time at the start, but after some time I noticed that sometimes again the components are not updating. This is an ugly workaround that sometimes works because you can see that content is changing on the frame when the frame is visible.
  5. I read that there is problem with graphic hardware acceleration on Intel HD 3000 Series, so on some forums, I read that I should call my application with VM Options -Dsun.java2d.d3d=false and -Dsun.java2d.opengl=True. This way the graphic is a bit smoother but after (not perfect) a period of time between 12 and 24 hours, the graphic freezes for about 5 min, not updating anything.
  6. On some forums I saw that user removed this problem with downgrading from java 8 to java 7 (this requires modification of my code and other codes from my colleagues, I estimate at least 2 months) and on some forums, I saw downgrading to java 8 update 25 helps to resolve this problem. I tried with downgrading to java 8 update 25 and the graphics and animations started going smoother, but again after a period of time (24 hours the last time), the application started freezing.
  7. I checked my OS has the latest version of Intel HD graphics and has OpenGL version 3.0 Mesa 18.0.5.

Also, I saw on a lot of problem with the game Minecraft running with java 8 on Intel HD.

I don't have much experience with java GUI, but I don't understand how it works with one Intel HD graphic fine, with other doesn't. Write once run anywhere concept of java failed me this time.

//EDIT 2018-11-02 Finally my mini pci-e to pci-e card arrived that i ordered on aliexpress, but the graphics still glitches. No idea what to try next. I guess that all the graphics rendering are done by the processor, not my nvidia card or the intel hd graphics.

like image 800
AdrianES Avatar asked Oct 18 '18 12:10

AdrianES


1 Answers

There is a known bug: https://bugs.openjdk.java.net/browse/JDK-8067328. Oracle recommends to disable D3D (they have disabled it by default in 8_40).

This article describes the same problem and way to fix it at the end: https://yakovfain.com/2014/06/27/swing-rendering-seems-to-be-broken-in-java-8/

like image 116
Zefick Avatar answered Oct 25 '22 22:10

Zefick