<AWT Dev> RFR: 8242174 [macos] The NestedModelessDialogTest test make the macOS unstable

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Mon Apr 13 15:09:11 UTC 2020


Hello.
Please review the fix for jdk/client.

Bug: https://bugs.openjdk.java.net/browse/JDK-8242174
Fix: http://cr.openjdk.java.net/~serb/8242174/webrev.00

This is part of the effort to stabilize the execution of our nightly tests. We already fix most of the
issues in the tests which made the OS and other tests unstable for some reasons.

And this is attempt to fix the "product" bug. I have found that some of our tests, like
"java/awt/Dialog/NestedDialogs/Modeless/NestedModelessDialogTest.java" have the code like this:
   robot.keyPress(KeyEvent.VK_SHIFT);
   robot.keyPress(KeyEvent.VK_H);
   robot.waitForIdle();
   robot.keyRelease(KeyEvent.VK_H);
   robot.keyRelease(KeyEvent.VK_SHIFT);


This should work fine, but unfortunately on macOS, such code produces "random" strange
results, sometimes some keys are pressed but never released, sometimes the shift
modifier is disappeared and so on. The situation is quite bad because the test itself is
passed but leaves the modifier key pressed, this occurred in different tests and caused
to fail some other tests around.

Note that our code is implemented according to the official Apple's documentation, so I had
filed a bug to Apple:
https://bugs.openjdk.java.net/browse/JDK-8242174?focusedCommentId=14328518&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14328518

So in this fix, I tried to follow the recommendation above. For all events(except mouse move)
an additional delay(50 ms) is added. If the test already uses some delay then the biggest
one will be used(the new delay will not be added to the old one)

This new delay will solve the problem of events lost, but it does not fix the problem of disappeared
modifiers(SHIFT/CTRL, etc). I tried different solutions and finally was able to find one suggestion
which works fine, is to use CGEventSourceCreate(kCGEventSourceStateHIDSystemState); instead of NULL in our events:
https://developer.apple.com/documentation/coregraphics/cgeventsourcestateid/kcgeventsourcestatehidsystemstate?language=objc


-- 
Best regards, Sergey.


More information about the awt-dev mailing list