Hi Sergey,

Here is my understanding of waitForIdle() - it ensures that all the events on 
the EDT are pushed, and it has a huge wait time of 10seconds, which should 
mostly guarantee that there are no pending events on the EDT till the function 
is executed. And it mostly works on all platforms. The test case failed on OEL, 
whereas it passed on Windows and Linux. I haven't checked for Mac, but most 
likely it would work there too. 
The testcase in question tries to paint the window, and then picks the color 
from a particular location on screen. The function bug8024864::showTestUI has 
frame.setVisible(true) as its last statement, which should ultimately generate 
a native paint event. Now waitForIdle will ensure that, that event has been 
posted, but paint/repaint will involve some work down the OS level. Now, it 
could be possible that, the scheduler might choose to suspend the EDT thread 
and run the main thread, which checks for the pixel color on the screen and it 
might fail.
So, although waitForIdle guarantees dispatch of all the events from the EDT, it 
doesnot guarantee that they have been processed. 
Hence the changes I have made to make sure that the window has been drawn on to 
the screen.

As a sidenote, I was looking into the code, and found this kind of code in 
SunToolkit.realSync:
            int iters = 0;
            while (iters < MIN_ITERS) {
                syncNativeQueue(timeout);
                iters++;
            }

The MIN_ITERS is set as 0, so this code never executes. Either the loop should 
be changed to do-while, or should be removed. There is another loop which does 
the actual work:
            while (syncNativeQueue(timeout) && iters < MAX_ITERS) {
                iters++;
            }

Let me know your thoughts on this.

Thanks,
Krishna

-----Original Message-----
From: Sergey Bylokhov 
Sent: Friday, January 19, 2018 4:26 AM
To: Krishna Addepalli <krishna.addepa...@oracle.com>; swing-dev@openjdk.java.net
Subject: Re: <Swing Dev> [11][JDK-8176512][TEST_BUG] add a minimal delay to 
java/awt/Paint/bug8024864.java

Hi, Krishna.
Can you please check why "robot.waitForIdle()" does not work?

On 18/01/2018 10:02, Krishna Addepalli wrote:
> Hi All,
> 
> Please review a fix for
> 
> Bug: JDK-8176512: https://bugs.openjdk.java.net/browse/JDK-8176512
> 
> Webrev: http://cr.openjdk.java.net/~kaddepalli/8176512/webrev00/
> 
> The problem is the testcase randomly fails on OEL. So the solution is 
> to use CyclicBarrier to ensure that the window is shown on the screen 
> before attempting to get the colors in particular location.
> 
> Thanks,
> 
> Krishna
> 


--
Best regards, Sergey.

Reply via email to