[OpenJDK 2D-Dev] <Swing Dev> [14] RFR: JDK-8223158: Docked MacBook cannot start any Java Swing applications

Prasanta Sadhukhan prasanta.sadhukhan at oracle.com
Thu Sep 26 06:13:06 UTC 2019

Hi Phil,

On 25-Sep-19 9:58 PM, Philip Race wrote:
> Why is this sent to swing-dev ? That's completely the wrong list.
> You want 2d-dev. I'll am replying on 2d-dev not swing-dev.
> I wonder why I don't see this when I have my Mac closed and connect to 
> an external monitor ?
> What is special here ?
I am not sure, probably connecting via dock might be playing a role here 
as there is a DisplayLink dock driver handling the display.
> > Now, when the main display is closed, the 
> CGDisplayIDToOpenGLDisplayMask(displayID) is returning 2 as glMask
> The phrasing here is misleading suggesting that "glMask" is an API name.
> The method is returning the value 2, which we then store in a variable 
> we call glMask ..
> and then hand off as the value for NSOpenGLPFAScreenMask
> Why would the call error out on this ? It seems like the right thing 
> to do
> What is the implication of not having glMask ? If we don't need it, 
> why specify it at all ?
I guess we need it for displaying on main display.
> What will happen if the second call fails too ? Won't we be back to 
> the crash ?
The proposed fix is in failure path to retry the init. I don't think we 
can escape the crash if 2nd attempt fails too.
> Nits:
> 1) Can we split that very long debugging trace statement ?
> 2) I guess we don't need to free "attrs" or "attrs1" since it is stack 
> allocated ..
> Unfortunate that we have to repeat the entire initialisation minus glMask.
> Can you think of a better way to do this ?
As per 

|/* Check if initWithAttributes succeeded. */ if(pixFmt == nil) { /* 
initWithAttributes failed. Try to alloc/init with a different list of 
attributes. */ } it is appropriate to try with another list, which is 
what I tried here. Regards Prasanta |

> -phil.
> On 9/25/19, 3:49 AM, Prasanta Sadhukhan wrote:
>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/2d-dev/attachments/20190926/4d3c2ca4/attachment.html>

More information about the 2d-dev mailing list