[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 Oct 10 19:14:57 UTC 2019


On 10/9/19 11:05 pm, Prasanta Sadhukhan wrote:
>> In that case, OK. this simplifies things, but I still don't understand why
>> when what we are doing looks to be correct that the call fails.
>>
> I do not have any definite answer to this but it seems getting display mask from DisplayLink driver for a docked display might be wrong so |NSOpenGLPixelFormat#init fails as that mask is probably not supported.|

I just got the similar bug:
https://bugs.openjdk.java.net/browse/JDK-8232086

I cannot reproduce that, but I guess the reason is the same, so I looked to the list
of requirements and I think that some of them are unused as well.
NSOpenGLPFAWindow - is not needed because we never render to the window directly.
NSOpenGLPFAPixelBuffer - is not needed because we never render to the pixel buffer.
NSOpenGLPFADoubleBuffer - we use our own texture as a backbuffer

I guess at a minimum we can align this list to the list used by the JavaFX.


> 
> |Regards|
> |Prasanta
> |
>> -phil.
>>
>> On 10/9/19 1:06 AM, Prasanta Sadhukhan wrote:
>>> Hi Sergey,
>>>
>>> On 27-Sep-19 2:58 AM, Sergey Bylokhov wrote:
>>>> 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?
>>>>
>>> Yes, since we do not have the required docked hardware, had to ask customer to test this and they confirm app does work if screen via dock is attached after they start the app.
>>>>
>>>> It looks like we "ignore" this attribute most of the time in the multi-monitor config,
>>>> probably we can drop if completely?
>>>>
>>> Modified webrev ignoring this NSOpenGLPFAScreenMask attribute. Normal working on primary display is not affected and I have given a fix to the customer to test in their environment and they confirmed it is working for them with external monitor.
>>>
>>> http://cr.openjdk.java.net/~psadhukhan/8223158/webrev.2/
>>>
>>> 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
>>>>
>>>>
>>


-- 
Best regards, Sergey.


More information about the 2d-dev mailing list