RFR: 8280982: [Wayland] [XWayland] java.awt.Robot taking screenshots [v7]
Alexander Zvegintsev
azvegint at openjdk.org
Fri May 26 15:54:56 UTC 2023
On Fri, 26 May 2023 15:32:41 GMT, Maxim Kartashev <mkartashev at openjdk.org> wrote:
> Tried running this version on my machine (Ubuntu 22.04, two displays with 100% and 200% scaling). A few observations:
>
> 1. I couldn't get any of the screenshot tests working through `jtreg` (screenshots are all black, no permission is ever asked). Does anybody know how to do that properly? Can this be made to work out of the box?
jtreg strips env variables down to a very few.
so providing following options should solve the issue:
`jtreg -ea -e:DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS -e:WAYLAND_DISPLAY=$WAYLAND_DISPLAY ...`
This is already addressed in jtreg 7.3 by [openjdk/jtreg/pull/152](https://github.com/openjdk/jtreg/pull/152)
> 2. Running manually is OK for the most part except for some tests in certain configurations:
>
>
> * Test `test/jdk/java/awt/Robot/HiDPIScreenCapture/ScreenCaptureGtkTest.java` consistently fails with `sun.java2d.uiScale` other than `1`. For example,
>
>
> ```
> $ java -Dsun.java2d.uiScale=3 ScreenCaptureGtkTest.java
> Creating screen capture of java.awt.Rectangle[x=89,y=99,width=100,height=100]
> Exception in thread "main" java.lang.SecurityException: Screen Capture in the selected area was not allowed
> at java.desktop/sun.awt.screencast.ScreencastHelper.getRGBPixels(ScreencastHelper.java:161)
> at java.desktop/sun.awt.X11.XRobotPeer.getRGBPixels(XRobotPeer.java:139)
> at java.desktop/java.awt.Robot.createCompatibleImage(Robot.java:606)
> at java.desktop/java.awt.Robot.createScreenCapture(Robot.java:477)
> at ScreenCaptureGtkTest.captureImageOf(ScreenCaptureGtkTest.java:130)
> at ScreenCaptureGtkTest.main(ScreenCaptureGtkTest.java:96)
> ```
>
> and this is when I allow both screens to be captured in the system dialog that appears after the start of the test. The same failure can be observed with `java -Dsun.java2d.uiScale=2 HiDPIRobotScreenCaptureTest.java`. Both tests hang after throwing those exceptions, by the way.
>
I'll take a look.
> * The same test fails in a different fashion with `-Djdk.gtk.version=2`. For example:
This is intended, GTK2 is not supported and deprecated for removal.
[JDK-8280031](https://bugs.openjdk.org/browse/JDK-8280031)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13803#issuecomment-1564594406
More information about the build-dev
mailing list