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

Heavy CPU usage when mixing JavaFX and Swing multiple times

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • tbd
    • 8u60
    • javafx
    • x86
    • windows_8

      FULL PRODUCT VERSION :
      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.3.9600]

      A DESCRIPTION OF THE PROBLEM :
      If I embed Swing into JavaFX which is embedded into Swing, and I set focus with the mouse, I do have issues with the CPU usage.

      this bug is related to bug JDK-8088540.

      Lets start with this example:

      public class EmbeddedTestWithFX extends JFrame {

          public EmbeddedTestWithFX() {
              setSize(new Dimension(300, 300));

              JTextArea textArea = new JTextArea();
              textArea.setSize(new Dimension(150, 150));

              JPanel container = new JPanel();
              container.setLayout(null);
              container.add(textArea);

              JFXPanel jfxPanel = new JFXPanel();

              Platform.runLater(() -> {
                  SwingNode swing = new SwingNode();
                  StackPane stack = new StackPane(swing);
                  Scene scene = new Scene(stack);
                  swing.setContent(container);
                  SwingUtilities.invokeLater(() -> jfxPanel.setScene(scene));
              });

              setContentPane(jfxPanel);
          }

          public static void main(String[] args) {
              new EmbeddedTestWithFX().setVisible(true);
          }
      }

      If I then try to click on the JTextArea, I can see in the taskmanager, that it uses alot of CPU, around 25 procent of my CPU (Core I7-4810MQ 2.8GHz)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Click on the textarea, and the problem should be obvious

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expecting that the CPU usage doesn't go up
      ACTUAL -
      It uses alot of CPU, around 25 procent of my CPU (Core I7-4810MQ 2.8GHz)

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

              Created:
              Updated:
              Resolved: