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

[wayland] java.awt.Robot.createScreenCapture(r) produces black image

XMLWordPrintable

    • x86_64
    • linux_debian_3.0

      ADDITIONAL SYSTEM INFORMATION :
      Tried on Debian11 (bullseye) and Debian10 (buster) with default Gnome3 desktop
      On Debian11 tried with these openjdk java versions:
      - "17-ea" 2021-09-14
      - "14.0.2" 2020-07-14
      - "13.0.5.1" 2020-11-06
      - "11.0.11" 2021-04-20


      A DESCRIPTION OF THE PROBLEM :
      When I try to take a screenshot using java.awt.Robot, then in any case this produces just a black image.
      Same bad result using javafx.scene.robot.Robot.
      Also getPixelColor​(x,y) always returns black.
      But getPixelColor​(x,y) returns any wrong color, when this argument is set: -Dawt.robot.gtk=false

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just try to take a screenshot on any Debian OS with Gnome3, it is always black.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      This function should return an Image containing the recorded screenshot.
      ACTUAL -
      Black image.

      ---------- BEGIN SOURCE ----------
      public class Test
      {
        public static void main (String args[]) throws Exception
        {
          java.awt.Robot robot = new java.awt.Robot();
          java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
          java.awt.Rectangle rect = new java.awt.Rectangle(tk.getScreenSize());
          java.awt.image.BufferedImage im = robot.createScreenCapture(rect);
          javax.imageio.ImageIO.write(im, "png", new java.io.File("/tmp/screen.png"));
        }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        1. screen.png
          screen.png
          65 kB
        2. screen-1.png
          screen-1.png
          148 kB
        3. Test.java
          0.4 kB

            azvegint Alexander Zvegintsev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: