JDK-8282270 : java/awt/Robot Screen Capture tests fail after 8280861
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 19
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-02-22
  • Updated: 2022-06-17
  • Resolved: 2022-03-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19
19 b15Fixed
Related Reports
Relates :  
Sub Tasks
JDK-8282276 :  
Description
java/awt/Robot/HiDPIScreenCapture/HiDPIRobotScreenCaptureTest.java often on Windows

Log from a Windows 10 system
Creating screen capture of java.awt.Rectangle[x=83,y=97,width=400,height=300]
Checking rectangle java.awt.Rectangle[x=0,y=0,width=200,height=150] to have color java.awt.Color[r=0,g=255,b=0]
Checking color at java.awt.Point[x=5,y=5] to be equal to java.awt.Color[r=0,g=255,b=0]... OK
Checking color at java.awt.Point[x=195,y=5] to be equal to java.awt.Color[r=0,g=255,b=0]... OK
Checking color at java.awt.Point[x=100,y=75] to be equal to java.awt.Color[r=0,g=255,b=0]... OK
Checking color at java.awt.Point[x=5,y=145] to be equal to java.awt.Color[r=0,g=255,b=0]... OK
Checking color at java.awt.Point[x=195,y=145] to be equal to java.awt.Color[r=0,g=255,b=0]... OK
Checking rectangle java.awt.Rectangle[x=200,y=0,width=200,height=150] to have color java.awt.Color[r=0,g=0,b=255]
Checking color at java.awt.Point[x=205,y=5] to be equal to java.awt.Color[r=0,g=0,b=255]... OK
Checking color at java.awt.Point[x=395,y=5] to be equal to java.awt.Color[r=0,g=0,b=255]... Mismatch: found java.awt.Color[r=0,g=0,b=0] instead. Check image.png.
----------System.err:(12/735)----------
java.lang.RuntimeException: Wrong image color!
	at HiDPIRobotScreenCaptureTest.checkRectColor(HiDPIRobotScreenCaptureTest.java:146)
	at HiDPIRobotScreenCaptureTest.main(HiDPIRobotScreenCaptureTest.java:119)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:828)

JavaTest Message: Test threw exception: java.lang.RuntimeException: Wrong image color!
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.lang.RuntimeException: Wrong image color!
Comments
Changeset: 8a2d5ab0 Author: Maxim Kartashev <maxim.kartashev@jetbrains.com> Committer: Alexey Ivanov <aivanov@openjdk.org> Date: 2022-03-21 07:21:00 +0000 URL: https://git.openjdk.java.net/jdk/commit/8a2d5ab07e6a1668f3e3918bdc8a30bd28a8f93b
21-03-2022

On Windows, all the failures occurred on one host. On Linux, all the failures occurred on one host. The test java/awt/Robot/HiDPIScreenCapture/ScreenCaptureGtkTest.java doesn't save the captured image, there's no way to diagnose what went wrong.
09-03-2022

I attached the image captured on the Windows host where the test failed. The frame didn't fit on the screen. According to the screenshot of the entire screen, the resolution on the host was 1024×768. It can't fit the frame which is larger than screen 1200×600, especially when it is positioned at 83*3=248, 97*2=194. As such, the failure on Windows has nothing to do with JDK-8280861, it's just a coincidence. However, the change in the coordinates of the frame may have contributed to the failure. https://github.com/openjdk/jdk/pull/7613#issuecomment-1062803401
09-03-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/7613 Date: 2022-02-24 14:32:39 +0000
24-02-2022

Whatever the reason, they are now failing too often in CI testing. I am going to problem list them on the specific platforms on which they fail under https://bugs.openjdk.java.net/browse/JDK-8282276 If there's a fix (revertting the test or anything else) then the problem list will need to be updated to de-list them. I also suggest that any fix be put through CI testing at least a couple of times before it is approved and pushed
22-02-2022

java/awt/Robot/HiDPIScreenCapture/HiDPIRobotScreenCaptureTest.java Since the Windows failures cannot possibly have their origin in the fix made, the test is apparently either exposes an existing bug in the Windows Robot or is bumping against a peculiarity of that platform and is best to get reverted back to its original form that didn't fail. java/awt/Robot/HiDPIScreenCapture/ScreenCaptureGtkTest.java The coordinates in the log (83, 78) are higher up than the test suggests (83, 97) and I've seen similar failures on Ubuntu 20.04 when the coordinates were set to (0, 0). The color picked matched perfectly with the bar drawn at the top of the screen. I believe it's best to place the test pixels towards the center of the window to avoid desktop elements interference. The test needs to be corrected in that direction.
22-02-2022

Another failure - from an Ubuntu 18.04 system - seen twice so far. The failing test is java/awt/Robot/HiDPIScreenCapture/ScreenCaptureGtkTest.java ----------System.out:(4/306)---------- command: main -Djdk.gtk.version=2 -Dsun.java2d.uiScale=3 ScreenCaptureGtkTest reason: User specified action: run main/othervm -Djdk.gtk.version=2 -Dsun.java2d.uiScale=3 ScreenCaptureGtkTest Mode: othervm [/othervm specified] Additional options from @modules: --add-modules java.desktop elapsed time (seconds): 0.908 ----------configuration:(3/40)---------- Boot Layer add modules: java.desktop ----------System.out:(1/128)---------- Checking color at 83, 78 to be equal to java.awt.Color[r=0,g=255,b=0]... Mismatch: found java.awt.Color[r=54,g=52,b=58] instead ----------System.err:(13/785)---------- Gtk-Message: 21:54:37.322: Failed to load module "canberra-gtk-module" java.lang.RuntimeException: Wrong screen pixel color at ScreenCaptureGtkTest.checkPixelColors(ScreenCaptureGtkTest.java:104) at ScreenCaptureGtkTest.main(ScreenCaptureGtkTest.java:92) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:577) at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127) at java.base/java.lang.Thread.run(Thread.java:828) JavaTest Message: Test threw exception: java.lang.RuntimeException: Wrong screen pixel color JavaTest Message: shutting down test STATUS:Failed.`main' threw exception: java.lang.RuntimeException: Wrong screen pixel color
22-02-2022