FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
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;
}
REPRODUCIBILITY :
This bug can be reproduced often.