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

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Thu Sep 26 21:28:08 UTC 2019


Hi, Prasanta.
On 9/25/19 11:13 pm, Prasanta Sadhukhan wrote:
>> 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 https://developer.apple.com/documentation/appkit/nsopenglpixelformat/1436219-initwithattributes?language=objc
> 
> |/* 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 |

NSOpenGLPFAScreenMask attribute and its usage it is quite interesting. It is used only once
mostly at startup to initialize the "sharedPixelFormat" and "sharedContext". Later we create
context per GraphicsConfig on top of these "sharedPixelFormat" and "sharedContext".

In the single monitor configuration this logic is clear, we request "sharedPixelFormat"
which supports "NSOpenGLPFAScreenMask" for the main display and it just work.

But how it should work when the new screen will be attached dynamically, and/or old
screen for which we requested NSOpenGLPFAScreenMask will be detached.

For example in the test case for this bug:
  - If the screen via dock is attached before start of the app, we get an exception because
    we cannot initialize the "sharedContext".
  - If the screen via dock is attached after start of the app, it works, right?


It looks like we "ignore" this attribute most of the time in the multi-monitor config,
probably we can drop if completely?


> 
> 
> 
>> -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


-- 
Best regards, Sergey.


More information about the 2d-dev mailing list