[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: [OpenJDK 2D-Dev] <Swing Dev> [14] RFR: JDK-8223158: Docked MacBook cannot start any Java Swing a
From:       Sergey Bylokhov <Sergey.Bylokhov () oracle ! com>
Date:       2019-09-26 21:28:08
Message-ID: ee11a18f-d9ce-f175-0e05-a81e512e3551 () oracle ! com
[Download RAW message or body]

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.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic