<AWT Dev> RFR: 8040630 Popup menus and tooltips flicker with previous popup contents when first shown

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Mon Feb 3 02:07:44 UTC 2020

Please review the fix for jdk/client.

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

This change is intended to fix the flickering of popup menus on
macOS. The root cause of the problem is that the native windows
for popup menus are cached internally. So when we show such a
cached window to the user he will see old content till the moment
we draw the new one.
As a fix we could
  - Drop the internal state(surface) of the window which contains the
    old content, as suggested in the current fix we set its size to 1x1 pixels.
  - Clean the old content by something like graphics.clearRect(), but
    since the draw operation is asynchronous it is possible it will
    not be completed when the user will see the popup.
  - Drop the caching completely, I am not sure that we really needed it,
    I have checked the performance PopupFactory.getPopup() when the
    cache is enabled/disabled and did not found a big difference. But
    since I plan to backport this to jdk11, I would like to minimize the
    fix, and drop the cache sometime later.

  - The easiest way to reproduce the bug is to run SwingSet2, and
    quickly open/reopen the "File" and "Look and feel" menu.
  - The bug is not really macOS specific, but java2D OGL pipeline"
    specific where the actual draw operations are asynchronous.

Best regards, Sergey.

More information about the awt-dev mailing list