RFR: 8274939: Incorrect size of the pixel storage is used by the robot on macOS

Phil Race prr at openjdk.java.net
Wed Oct 13 20:22:54 UTC 2021


On Fri, 8 Oct 2021 10:23:13 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> In JDK 9 the native code for the robot class was reworked to get an access to the HiDPI quality screenshots. So we allocate the data storage for the HiDPI quality and then request the best quality from the macOS.
> 
> It works fine if the user request the screenshot of some area, since we properly scale this area. Unfortunately it does not work well if the user request only one pixel, in this case we allocate the array of one element and does not multiply the size by the scale, so if the system scale is 2 then the macOS returns the 2x2 pixels, which does not fit properly to the array of one element. This can be checked by the Xcheck:jni option which produce fatal error in this case.
> 
> Solution is to allocate the storage of the proper size 1 * scale * 1 * scale

Whilst more in keeping with the code that grabs an area It's not easy to know if this really makes things better in any practical way.
It definitely does not fix a single one of the tests described in https://bugs.openjdk.java.net/browse/JDK-8274106
(after of course un-doing the problem listing and work arounds of setting) as tested on both imacs on which they were previously observed to fail. As noted in that bug report, it seems like there may be an Apple bug.
Meanwhile I will run more tests (not just those previously failing ones) to make sure this change doesn't introduce any new issues.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5864



More information about the client-libs-dev mailing list