RFR: 8378153: Robot.getPixelColor() may return stale pixels due to missing Toolkit.sync()

Phil Race prr at openjdk.org
Thu Feb 19 02:57:42 UTC 2026


On Wed, 18 Feb 2026 08:24:22 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> Robot.getPixelColor() does not call Toolkit.getDefaultToolkit().sync() before reading the pixel, unlike Robot.createScreenCapture() which has had this call since [JDK-6725214](https://bugs.openjdk.org/browse/JDK-6725214).
> 
> When a hardware-accelerated pipeline (OGL, D3D, Metal) is active, rendering may be buffered and not yet flushed to the screen when getPixelColor() reads the pixel. This causes it to return stale values typically the window background color instead of the rendered content.

I don't know how often this is a problem but it seems like a safe and good change.

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

Marked as reviewed by prr (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29780#pullrequestreview-3823242186


More information about the client-libs-dev mailing list