[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 Oct 10 06:05:33 UTC 2019
On 09-Oct-19 9:31 PM, Phil Race wrote:
> So this means your speculation below that it was needed for the main
> display
> turns out to be untrue and we can definitely just drop it ?
>
> ===============
> On 9/25/19 11:13 PM, Prasanta Sadhukhan wrote:
>>
>> Hi Phil,
>>
>> On 25-Sep-19 9:58 PM, Philip Race wrote:
> ...
>>> 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.
> ===============
>
> 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.|
|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
>>>
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/2d-dev/attachments/20191010/79700bb9/attachment-0001.html>
More information about the 2d-dev
mailing list