JDK-8156185 : JDK-8024858 (long tooltip delay) is not fixed but is easily fixed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2016-05-03
  • Updated: 2016-07-14
  • Resolved: 2016-06-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
9 b127Fixed
Related Reports
Relates :  
Relates :  

JDK-8024858 was stated as being resolved by upgrading the NVIDIA video drivers. Well I do not have an NVIDIA card, and the drivers I do have are the newest available, and I am still experiencing a ~10-second hang before tooltips are first shown. The problem *does* have a driver dependency -- it happens when Java uses the Win32 rendering path and not when it uses the D3D one -- but the problem is NOT FIXED.

The underlying delay is happening in `sun.awt.Win32GraphicsDevice.getConfigurations()`, which takes a long time to enumerate the available pixel formats of each device. Fortunately it is the wrong method to call. It is called in the Swing tooltip code which determines the correct monitor to use for tooltip display. All the tooltip code wants to know is the current bounds of each `GraphicsDevice` (size and position of each monitor). Currently it enumerates all the configurations returned by each `device.getConfigurations()` and checks the device bounds from each. We only need to call `device.getDefaultConfiguration()` (which does not cause the delay! Hurray!) and get the device bounds from that. The other possible configurations are the same bounds with different color formats, so enumerating them is pointless.

The fix is trivial. In /src/share/classes/javax/swing/ToolTipManager.java:

    private GraphicsConfiguration getDrawingGC(Point toFind) {
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice devices[] = env.getScreenDevices();
        for (GraphicsDevice device : devices) {
-           GraphicsConfiguration configs[] = device.getConfigurations();
-           for (GraphicsConfiguration config : configs) {
-               Rectangle rect = config.getBounds();
-               if (rect.contains(toFind)) {
-                   return config;
-               }
-           }
+           GraphicsConfiguration config = device.getDefaultConfiguration();
+           Rectangle rect = config.getBounds();
+           if (rect.contains(toFind)) {
+               return config;
+           }
        return null;

This bug can be reproduced often.

I cannot reproduce the long delay. But it may depend on the hardware used. The proposed change looks sensible since we don't need the color configuration device.getDefaultConfiguration() is more optimal.