JetBrains / jdk8u

GNU General Public License v2.0
122 stars 35 forks source link

JavaFX application crashed (MacOS) after being left inactive for a while #8

Open chrisr3 opened 7 years ago

chrisr3 commented 7 years ago

The final entry in the application's log file was:

2017-07-14T12:44:16,277 [ERROR] ErrorHandler - Uncaught error
java.lang.NullPointerException: null
    at sun.swing.JLightweightFrame.updateClientCursor(JLightweightFrame.java:473) ~[?:1.8.0_152-release]
    at sun.swing.JLightweightFrame.access$000(JLightweightFrame.java:79) ~[?:1.8.0_152-release]
    at sun.swing.JLightweightFrame$1.updateCursor(JLightweightFrame.java:112) ~[?:1.8.0_152-release]
    at sun.lwawt.LWLightweightFramePeer.updateCursorImmediately(LWLightweightFramePeer.java:117) ~[?:1.8.0_152-release]
    at java.awt.Component.updateCursorImmediately(Component.java:3156) ~[?:1.8.0_152-release]
    at java.awt.Container.validate(Container.java:1643) ~[?:1.8.0_152-release]
    at java.awt.Window.dispatchEventImpl(Window.java:2744) ~[?:1.8.0_152-release]
    at java.awt.Component.dispatchEvent(Component.java:4719) ~[?:1.8.0_152-release]
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764) ~[?:1.8.0_152-release]
    at java.awt.EventQueue.access$500(EventQueue.java:98) ~[?:1.8.0_152-release]
    at java.awt.EventQueue$3.run(EventQueue.java:715) ~[?:1.8.0_152-release]
    at java.awt.EventQueue$3.run(EventQueue.java:709) ~[?:1.8.0_152-release]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_152-release]
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) ~[?:1.8.0_152-release]
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90) ~[?:1.8.0_152-release]
    at java.awt.EventQueue$4.run(EventQueue.java:737) ~[?:1.8.0_152-release]
    at java.awt.EventQueue$4.run(EventQueue.java:735) ~[?:1.8.0_152-release]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_152-release]
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) ~[?:1.8.0_152-release]
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:734) ~[?:1.8.0_152-release]
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) [?:1.8.0_152-release]
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) [?:1.8.0_152-release]
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) [?:1.8.0_152-release]
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:1.8.0_152-release]
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) [?:1.8.0_152-release]
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) [?:1.8.0_152-release]

So it looks like the JavaFX application thread has crashed while trying to update the cursor.

chrisr3 commented 7 years ago

The code in question is

MouseInfo.getPointerInfo().getLocation();

where the relevant part of getPointerInfo() is:

    ...
    Point point = new Point(0, 0);
    int deviceNum = Toolkit.getDefaultToolkit().getMouseInfoPeer().fillPointWithCoords(point);
    GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment().
                               getScreenDevices();

    PointerInfo retval = null;
    if (areScreenDevicesIndependent(gds)) {
        retval = new PointerInfo(gds[deviceNum], point);
    } else {
        for (int i = 0; i < gds.length; i++) {
            GraphicsConfiguration gc = gds[i].getDefaultConfiguration();
            Rectangle bounds = gc.getBounds();
            if (bounds.contains(point)) {
                retval = new PointerInfo(gds[i], point);
            }
        }
    }

    return retval;
}

This function can legitimately return null in some circumstances, and JavaFX is throwing NPE when it then tries to invoke getLocation().