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

MacOS metal pipeline - window isn't painted if created during display sleep

XMLWordPrintable

    • 2d
    • b18

      The test program supplied here can be used to demonstrate that with the
      2D metal pipeline a window is created whilst the application is in display sleep
      then the window is never painted, no matter what you do after returning from sleep.

      It was reported as a JDK 19 issue on macOS 13 (JDK 19 is
      the release in which metal was turned on by default) but I reproduced
      on macOS 12.6 with JDK 18 by specifying -Dsun.java2d.metal=True
      It passes (repaint happens) if you use OpenGL on both of these releases.


      import java.awt.FlowLayout;
      import java.awt.Toolkit;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.SwingUtilities;
      import javax.swing.Timer;

      public class TestRenderStop {
          MyFrame fr;

          public TestRenderStop() {
              JFrame m = new MyFrame("Test Render Stop", "Enter display sleep [control-shift-Eject] now and wait until you hear the beep before typing Enter to resume");
              m.setBounds(400, 400, 800, 400);
              m.setVisible(true);

              Timer t = new Timer(10000, e -> showFrame());
              t.setRepeats(false);
              t.start();
          }

          private void showFrame() {
              fr = new MyFrame("Test Frame", "This is a label");
              fr.setBounds(500, 550, 400, 70);
              fr.setVisible(true);
              Toolkit.getDefaultToolkit().beep();
          }

          class MyFrame extends JFrame {
              MyFrame(String title, String message) {
                  setTitle(title);
                  setLayout(new FlowLayout());
                  add(new JLabel(message));
              }
          }

          public static void main(String[] args) {
              SwingUtilities.invokeLater(TestRenderStop::new);
          }
      }

            aghaisas Ajit Ghaisas
            prr Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: