<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 09-Oct-19 9:31 PM, Phil Race wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:670aa65b-b142-b493-773c-72aad4478324@oracle.com">So this
      means your speculation below that it was needed for the main
      display
      <br>
      turns out to be untrue and we can definitely just drop it ?
      <br>
      <br>
      ===============
      <br>
      On 9/25/19 11:13 PM, Prasanta Sadhukhan wrote:
      <br>
      <blockquote type="cite">
        <br>
        Hi Phil,
        <br>
        <br>
        On 25-Sep-19 9:58 PM, Philip Race wrote:
        <br>
      </blockquote>
      ...
      <br>
      <blockquote type="cite">
        <blockquote type="cite">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>
      ===============
      <br>
      <br>
      In that case, OK. this simplifies things, but I still don't
      understand why
      <br>
      when what we are doing looks to be correct that the call fails.
      <br>
      <br>
    </blockquote>
    <p>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 <code><span class="syntax-built_in">NSOpenGLPixelFormat#init
          fails as that mask is probably not supported.</span></code></p>
    <code><span class="syntax-built_in">Regards</span></code><br>
    <code><span class="syntax-built_in">Prasanta<br>
      </span> </code>
    <blockquote type="cite"
      cite="mid:670aa65b-b142-b493-773c-72aad4478324@oracle.com">-phil.
      <br>
      <br>
      On 10/9/19 1:06 AM, Prasanta Sadhukhan wrote:
      <br>
      <blockquote type="cite">Hi Sergey,
        <br>
        <br>
        On 27-Sep-19 2:58 AM, Sergey Bylokhov wrote:
        <br>
        <blockquote type="cite">Hi, Prasanta.
          <br>
          On 9/25/19 11:13 pm, Prasanta Sadhukhan wrote:
          <br>
          <blockquote type="cite">
            <blockquote type="cite">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>
            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><br>
            <br>
            |/* 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 |
            <br>
          </blockquote>
          <br>
          NSOpenGLPFAScreenMask attribute and its usage it is quite
          interesting. It is used only once
          <br>
          mostly at startup to initialize the "sharedPixelFormat" and
          "sharedContext". Later we create
          <br>
          context per GraphicsConfig on top of these "sharedPixelFormat"
          and "sharedContext".
          <br>
          <br>
          In the single monitor configuration this logic is clear, we
          request "sharedPixelFormat"
          <br>
          which supports "NSOpenGLPFAScreenMask" for the main display
          and it just work.
          <br>
          <br>
          But how it should work when the new screen will be attached
          dynamically, and/or old
          <br>
          screen for which we requested NSOpenGLPFAScreenMask will be
          detached.
          <br>
          <br>
          For example in the test case for this bug:
          <br>
           - If the screen via dock is attached before start of the app,
          we get an exception because
          <br>
             we cannot initialize the "sharedContext".
          <br>
           - If the screen via dock is attached after start of the app,
          it works, right?
          <br>
          <br>
        </blockquote>
        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.
        <br>
        <blockquote type="cite">
          <br>
          It looks like we "ignore" this attribute most of the time in
          the multi-monitor config,
          <br>
          probably we can drop if completely?
          <br>
          <br>
        </blockquote>
        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.
        <br>
        <br>
        <a class="moz-txt-link-freetext" href="http://cr.openjdk.java.net/~psadhukhan/8223158/webrev.2/">http://cr.openjdk.java.net/~psadhukhan/8223158/webrev.2/</a>
        <br>
        <br>
        Regards
        <br>
        Prasanta
        <br>
        <blockquote type="cite">
          <br>
          <blockquote type="cite">
            <br>
            <br>
            <br>
            <blockquote type="cite">-phil.
              <br>
              <br>
              On 9/25/19, 3:49 AM, Prasanta Sadhukhan wrote:
              <br>
              <blockquote type="cite">
                <br>
                Hi All,
                <br>
                <br>
                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.
                <br>
                <br>
                It was found
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration()
                is returning null in this particular setup.
                <br>
                <br>
                Since it was difficult to reproduce locally, enabling
                tracing reveals that
                CGLGraphicsConfig#getCGLConfigInfo() was failing in
                NSOpenGLPixelFormat.initWithAttributes()
                <br>
                <br>
                Appkit documentation
<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><br>
                says that it will return "|nil| 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 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 class="moz-txt-link-freetext" href="https://bugs.openjdk.java.net/browse/JDK-8223158">https://bugs.openjdk.java.net/browse/JDK-8223158</a>
                <br>
                <br>
                webrev:
                <a class="moz-txt-link-freetext" href="http://cr.openjdk.java.net/~psadhukhan/8223158/webrev.0/">http://cr.openjdk.java.net/~psadhukhan/8223158/webrev.0/</a>
                <br>
                <br>
                Regards
                <br>
                Prasanta
                <br>
              </blockquote>
            </blockquote>
          </blockquote>
          <br>
          <br>
        </blockquote>
      </blockquote>
      <br>
    </blockquote>
  </body>
</html>