Hi All,

Please review a fix for an issue where it is seen that if a MacBookPro is attached to an external monitor via dock and macbook lid is closed,
no Java swing applications will start.

It was found GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration() is returning null in this particular setup.

Since it was difficult to reproduce locally, enabling tracing reveals that CGLGraphicsConfig#getCGLConfigInfo() was failing in NSOpenGLPixelFormat.initWithAttributes()

Appkit documentation https://developer.apple.com/documentation/appkit/nsopenglpixelformat/1436219-initwithattributes?language=objc says that it will return "|nil| if an object with the desired attributes could not be initialized".
Now, when the main display is closed, the
CGDisplayIDToOpenGLDisplayMask(displayID)
is returning 2 as glMask which when passed as an attribute to NSOpenGLPixelFormat, it fails to initialize.
Normally, with main Display being used, glMask is 1.

Proposed fix is to see if first initialization fails, then retry initialization without the offending glMask value for NSOpenGLPFAScreenMask attributes, as documentation https://developer.apple.com/documentation/appkit/1436213-opengl_pixel_format_attributes/nsopenglpfascreenmask?language=objc says "All screens specified in the bit mask are guaranteed to be supported by the pixel format.", so if it is not guranteed to be supported, initAttributes() might fail.

Bug: https://bugs.openjdk.java.net/browse/JDK-8223158

webrev: http://cr.openjdk.java.net/~psadhukhan/8223158/webrev.0/

Regards
Prasanta

Reply via email to