-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
19
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
openjdk version "19.0.1" 2022-10-18
OpenJDK Runtime Environment Temurin-19.0.1+10 (build 19.0.1+10)
OpenJDK 64-Bit Server VM Temurin-19.0.1+10 (build 19.0.1+10, mixed mode, sharing)
Microsoft Windows [Versione 10.0.19045.2311]
A DESCRIPTION OF THE PROBLEM :
When D3D is used, a simple auto-repaint JPanel is capable to overload a 3060 nvidia GPU (up to 47%).
Tooltips trigger some strange behavior and the GPU usage grows again and there's no way to get back.
So I see 2 main issues:
D3D drawing is terribly slow.
Tooltips can trigger more GPU load issues.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just run the attached java test
ACTUAL -
High GPU usage
---------- BEGIN SOURCE ----------
package bug.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* @author MIK
*
*/
public class D3DWoes extends JPanel implements ActionListener
{
/**
*
*/
private static final long serialVersionUID = 5906379118516119809L;
/**
* @param args
*/
public static void main(final String[] args)
{
// set to TRUE in order to use D3D and exploit the bug
// set to FALSE to run with software loops
System.getProperties().put("sun.java2d.d3d","TRUE");
SwingUtilities.invokeLater(() ->
{
final D3DWoes panel = new D3DWoes();
final JFrame f = new JFrame();
f.add(panel);
f.setSize(800, 800);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// auto-repaint timer
Timer t = new Timer(1,panel);
t.setRepeats(true);
t.start();
});
}
/**
* default constructor
*/
public D3DWoes()
{
super();
setToolTipText("");
}
/*
* (non-Javadoc)
*
* @see javax.swing.JComponent#paint(java.awt.Graphics)
*/
@Override
public void paint(final Graphics g)
{
super.paint(g);
g.setColor(Color.GRAY);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.RED);
g.drawString("Click me, wait tooltip and check GPU load " + System.currentTimeMillis(), 300, 400);
}
/*
* @see javax.swing.JComponent#createToolTip()
*/
@Override
public JToolTip createToolTip()
{
setToolTipText(System.currentTimeMillis() + "");
return super.createToolTip();
}
/*
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
@Override
public void actionPerformed(ActionEvent e)
{
repaint();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
- Disable D3D -> System.getProperties().put("sun.java2d.d3d","false");
- Disable Swing double buffering through repaint manager
FREQUENCY : always
openjdk version "19.0.1" 2022-10-18
OpenJDK Runtime Environment Temurin-19.0.1+10 (build 19.0.1+10)
OpenJDK 64-Bit Server VM Temurin-19.0.1+10 (build 19.0.1+10, mixed mode, sharing)
Microsoft Windows [Versione 10.0.19045.2311]
A DESCRIPTION OF THE PROBLEM :
When D3D is used, a simple auto-repaint JPanel is capable to overload a 3060 nvidia GPU (up to 47%).
Tooltips trigger some strange behavior and the GPU usage grows again and there's no way to get back.
So I see 2 main issues:
D3D drawing is terribly slow.
Tooltips can trigger more GPU load issues.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just run the attached java test
ACTUAL -
High GPU usage
---------- BEGIN SOURCE ----------
package bug.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* @author MIK
*
*/
public class D3DWoes extends JPanel implements ActionListener
{
/**
*
*/
private static final long serialVersionUID = 5906379118516119809L;
/**
* @param args
*/
public static void main(final String[] args)
{
// set to TRUE in order to use D3D and exploit the bug
// set to FALSE to run with software loops
System.getProperties().put("sun.java2d.d3d","TRUE");
SwingUtilities.invokeLater(() ->
{
final D3DWoes panel = new D3DWoes();
final JFrame f = new JFrame();
f.add(panel);
f.setSize(800, 800);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// auto-repaint timer
Timer t = new Timer(1,panel);
t.setRepeats(true);
t.start();
});
}
/**
* default constructor
*/
public D3DWoes()
{
super();
setToolTipText("");
}
/*
* (non-Javadoc)
*
* @see javax.swing.JComponent#paint(java.awt.Graphics)
*/
@Override
public void paint(final Graphics g)
{
super.paint(g);
g.setColor(Color.GRAY);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.RED);
g.drawString("Click me, wait tooltip and check GPU load " + System.currentTimeMillis(), 300, 400);
}
/*
* @see javax.swing.JComponent#createToolTip()
*/
@Override
public JToolTip createToolTip()
{
setToolTipText(System.currentTimeMillis() + "");
return super.createToolTip();
}
/*
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
@Override
public void actionPerformed(ActionEvent e)
{
repaint();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
- Disable D3D -> System.getProperties().put("sun.java2d.d3d","false");
- Disable Swing double buffering through repaint manager
FREQUENCY : always
- relates to
-
JDK-8157316 SwingNode does not resize properly when direct 3D is disabled (sun.java2d.d3d=false)
- Closed