Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8191018

Swing consuming max CPU when running in a minimized RDP session to a VM

XMLWordPrintable

    • x86
    • other

      FULL PRODUCT VERSION :
      java version "1.8.0_111"
      Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 10 Version 1607 OS Build 14393.1593

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      VM on VMware ESXi, 6.5.0, 5969303, 2 virtual processors, 6 cores.

      A DESCRIPTION OF THE PROBLEM :
      We use VMs accessed through RDP (built-in Win10) for our out-of-office machines. One of the applications used is a Java Swing app. When working with it, and the RDP session window is minimized, the application starts maxing out it's CPU usage. When the window is restored again, the CPU usage goes back to normal.

      Original investigation with source, CPU utilization graph, JVisualVm profiler and sampler output is on StackOverflow: https://stackoverflow.com/questions/46006654

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start a headless VM on Win10
      RDP into it
      Start the application and a CPU monitor (task manager or other or external to the VM)
      Minimize the RDP session window
      Wait some time
      Restore the window
      Observe the CPU usage graph


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected no change in CPU usage during minimized phase
      ACTUAL -
      CPU usage peaks at 80% on my particular configuration, different depending on virtual processor count.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JComboBox;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.SwingUtilities;
      import javax.swing.Timer;

      public class Test {
      public static void main(String[] args) {
      SwingUtilities.invokeLater(() -> {
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      JPanel panel = new JPanel();
      for (int i = 0; i < 3; i++) {
      JPanel subpanel = new JPanel();
      JComboBox<?> box = new JComboBox<>();
      subpanel.add(box);
      panel.add(subpanel);
      }
      frame.add(panel);
      frame.pack();
      frame.setVisible(true);

      Timer timer = new Timer(1000, e -> {
      frame.repaint();
      });
      timer.setRepeats(true);
      timer.start();
      });
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Disabling D3D: -Dsun.java2d.d3d=false

        1. java-cpu-after.png
          java-cpu-after.png
          99 kB
        2. java-cpu-before.png
          java-cpu-before.png
          91 kB
        3. Test.java
          0.8 kB

            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: