<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi Phil,<br>
</p>
<div class="moz-cite-prefix">On 25-Sep-19 9:58 PM, Philip Race
wrote:<br>
</div>
<blockquote type="cite" cite="mid:5D8B95BE.6000208@oracle.com">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
Why is this sent to swing-dev ? That's completely the wrong list.<br>
You want 2d-dev. I'll am replying on 2d-dev not swing-dev.<br>
<br>
<br>
<br>
I wonder why I don't see this when I have my Mac closed and
connect to an external monitor ?<br>
What is special here ?<br>
<br>
</blockquote>
I am not sure, probably connecting via dock might be playing a role
here as there is a DisplayLink dock driver handling the display.<br>
<blockquote type="cite" cite="mid:5D8B95BE.6000208@oracle.com"> >
Now, when the main display is closed, the
CGDisplayIDToOpenGLDisplayMask(displayID) is returning 2 as glMask<br>
<br>
The phrasing here is misleading suggesting that "glMask" is an API
name.<br>
<br>
The method is returning the value 2, which we then store in a
variable we call glMask .. <br>
and then hand off as the value for NSOpenGLPFAScreenMask <br>
<br>
Why would the call error out on this ? It seems like the right
thing to do <br>
<br>
<br>
What is the implication of not having glMask ? If we don't need
it, why specify it at all ?<br>
<br>
</blockquote>
I guess we need it for displaying on main display.<br>
<blockquote type="cite" cite="mid:5D8B95BE.6000208@oracle.com"> What
will happen if the second call fails too ? Won't we be back to the
crash ?<br>
<br>
</blockquote>
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.<br>
<blockquote type="cite" cite="mid:5D8B95BE.6000208@oracle.com">
Nits: <br>
<br>
1) Can we split that very long debugging trace statement ?<br>
<br>
</blockquote>
<a class="moz-txt-link-freetext" href="http://cr.openjdk.java.net/~psadhukhan/8223158/webrev.1/">http://cr.openjdk.java.net/~psadhukhan/8223158/webrev.1/</a><br>
<blockquote type="cite" cite="mid:5D8B95BE.6000208@oracle.com"> 2) I
guess we don't need to free "attrs" or "attrs1" since it is stack
allocated .. <br>
Unfortunate that we have to repeat the entire initialisation minus
glMask.<br>
Can you think of a better way to do this ?<br>
<br>
</blockquote>
<p>As per
<a class="moz-txt-link-freetext" href="https://developer.apple.com/documentation/appkit/nsopenglpixelformat/1436219-initwithattributes?language=objc">https://developer.apple.com/documentation/appkit/nsopenglpixelformat/1436219-initwithattributes?language=objc</a></p>
<pre class="code-source" data-language="occ"><code><span class="syntax-comment">/* Check if initWithAttributes succeeded. */</span>
<span class="syntax-keyword">if</span>(pixFmt == <span class="syntax-literal">nil</span>) {
<span class="syntax-comment">/* initWithAttributes failed. Try to alloc/init with a different list of attributes. */</span>
}
it is appropriate to try with another list, which is what I tried here.
Regards
Prasanta
</code></pre>
<section id="see-also" class="contenttable section
alt-light-container row">
<div class="alt-light">
<div class="section-content">
<h2 class="contenttable-title"><br>
</h2>
</div>
</div>
</section>
<blockquote type="cite" cite="mid:5D8B95BE.6000208@oracle.com">
-phil.<br>
<br>
On 9/25/19, 3:49 AM, Prasanta Sadhukhan wrote:
<blockquote
cite="mid:d06c8817-44dc-bbfa-efbd-3a7949db3a9a@oracle.com"
type="cite">
<meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<p>Hi All,</p>
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, <br>
no Java swing applications will start.
<p>It was found
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration()
is returning null in this particular setup.</p>
<p>Since it was difficult to reproduce locally, enabling tracing
reveals that CGLGraphicsConfig#getCGLConfigInfo() was failing
in NSOpenGLPixelFormat.initWithAttributes()</p>
Appkit documentation <a moz-do-not-send="true"
class="moz-txt-link-freetext"
href="https://developer.apple.com/documentation/appkit/nsopenglpixelformat/1436219-initwithattributes?language=objc">https://developer.apple.com/documentation/appkit/nsopenglpixelformat/1436219-initwithattributes?language=objc</a><br>
says that it will return "<code class="code-voice"><span>nil</span></code>
if an object with the desired attributes could not be
initialized".<br>
Now, when the main display is closed, the <br>
CGDisplayIDToOpenGLDisplayMask(displayID)<br>
is returning 2 as glMask which when passed as an attribute to
NSOpenGLPixelFormat, it fails to initialize.<br>
Normally, with main Display being used, glMask is 1.<br>
<br>
Proposed fix is to see if first initialization fails, then retry
initialization without the offending glMask value for
NSOpenGLPFAScreenMask attributes,<br>
as documentation <a moz-do-not-send="true"
class="moz-txt-link-freetext"
href="https://developer.apple.com/documentation/appkit/1436213-opengl_pixel_format_attributes/nsopenglpfascreenmask?language=objc">https://developer.apple.com/documentation/appkit/1436213-opengl_pixel_format_attributes/nsopenglpfascreenmask?language=objc</a><br>
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.<br>
<br>
Bug: <a moz-do-not-send="true" class="moz-txt-link-freetext"
href="https://bugs.openjdk.java.net/browse/JDK-8223158">https://bugs.openjdk.java.net/browse/JDK-8223158</a><br>
<p>webrev: <a moz-do-not-send="true"
class="moz-txt-link-freetext"
href="http://cr.openjdk.java.net/%7Epsadhukhan/8223158/webrev.0/">http://cr.openjdk.java.net/~psadhukhan/8223158/webrev.0/</a></p>
Regards<br>
Prasanta<br>
</blockquote>
</blockquote>
</body>
</html>