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

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

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux_debian_3.0

      Description

      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


        Attachments

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

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated: