Skip to content

Commit 9533d7e

Browse files
committed
CompareScreenshotTest: mitigate a race condition causing tests to fail
1 parent ed89db3 commit 9533d7e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

test/org/lwjgl/opengl/awt/CompareScreenshotTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ public void run() {
283283
BufferedImage background = rbt.createScreenCapture(frameBounds);
284284
// Some Operating Systems have a window open/close animation, so we wait until the screenshot is stable
285285
while (true) {
286+
// Pause at least 500 milliseconds between captures
287+
long pauseStartTime = System.currentTimeMillis();
288+
while (System.currentTimeMillis() - pauseStartTime < 500) {
289+
Thread.yield();
290+
}
291+
286292
BufferedImage s = rbt.createScreenCapture(frameBounds);
287293
if (new ImageComparison(background, s).compareImages().getDifferencePercent() == 0) {
288294
break;

0 commit comments

Comments
 (0)