<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    1) -XstartOnFirstThread  should be thought of more as
    -XdontStartAnEventLoop<br>
    And with no event loop running, yes, UI apps hang.<br>
    To understand why the option is named as it is, you need to know
    that on most platforms<br>
    and situations the application's "main" method will run on the first
    thread that is started<br>
    But on macOS in order to allow the event loop to run on that thread,
    it hops over to another<br>
    thread that is created. But with this special option, that doesn't
    happen, so some other code<br>
    has a chance to use it for that.<br>
    The reason for it is that a toolkit like SWT may come along later
    and start a loop.<br>
    It is possible to check there's already a loop (AWT + JavaFX both
    do) but perhaps SWT doesn't ?<br>
    In summary this option is not (SFAICS) for your use case and that
    bug is "not a bug" and I've closed it.<br>
    <br>
    2) The class referenced by Sergey<br>
    <br>
    <a class="moz-txt-link-freetext" href="https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/java2d/opengl/OGLUtilities.java">https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/java2d/opengl/OGLUtilities.java</a><br>
    <br>
    isn't one I know anything about. I can see it pre-dates us even
    having a macOS port, and its completely<br>
    unsupported, probably unsupportable, no idea if it actually works,
    especially on macOS.<br>
    Not sure if its even a direction you should head down. Caveat
    emptor. Big time.<br>
    <br>
    3) JAWT is a JDK native API that lets you use native code to draw
    into a Java-owned window.<br>
<a class="moz-txt-link-freetext" href="https://docs.oracle.com/en/java/javase/17/docs/specs/AWT_Native_Interface.html">https://docs.oracle.com/en/java/javase/17/docs/specs/AWT_Native_Interface.html</a><br>
    It doesn't provide much more than that. Any rendering that needs to
    happen on a particular thread<br>
    etc is out of scope of what it provides.<br>
    <br>
    4) Your error isn't obviously directly opengl related even though it
    mentions "GLUT". Its more about the toolkit.<br>
    <pre class="moz-quote-pre" wrap="">java[92246:2751169] GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: NSWindow drag regions should only be invalidated on the Main Thread!</pre>
    I would have thought that the advice which I think you need (in this
    somewhat confusing thread) people<br>
    have already offered and this is to jump onto the main thread when
    needed.<br>
    You can look at the code in the JDK's libosxapp/ThreadUtilities.m as
    a sample to see how you'd do this.<br>
    Do not rely on JDK internals. Ultimately you will need to end up
    using this Apple macOS API -<br>
<a class="moz-txt-link-freetext" href="https://developer.apple.com/documentation/objectivec/nsobject/1414900-performselectoronmainthread">https://developer.apple.com/documentation/objectivec/nsobject/1414900-performselectoronmainthread</a><br>
    - if you aren't already on the main thread that is.<br>
    If there's some complication with that which I'm not understanding,
    I don't know what you'd do instead.<br>
    <br>
    I don't have time to look into this any more deeply so this reply
    must be taken as not fully researched,<br>
    but it is the best I can offer you.<br>
    <br>
    -Phil<br>
    <br>
    <div class="moz-cite-prefix">On 3/23/23 4:00 AM, Martin Pernollet
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:E_tRKyd0UtKK-LSEom7zomuhBxHFjWLuXRwstZC5zNpd3g0FjMQGHrn2zhfBk0ssh5f2vWjTk3yVUe8uQS3Q2oJIlyC1vLdqKUCvaur3eXo=@protonmail.com">
      
      <div style="font-family: Arial, sans-serif; font-size: 14px;"><br>
      </div>
      <div style="font-family: Arial, sans-serif; font-size: 14px;"><br>
      </div>
      <div class="protonmail_signature_block" style="font-family: Arial,
        sans-serif; font-size: 14px;">
        <div class="protonmail_signature_block-user
          protonmail_signature_block-empty"> </div>
      </div>
      <div class="protonmail_quote">
        <blockquote class="protonmail_quote" type="cite">
          <div>
            <div><span style="font-size: 0.875rem;">Start another java
                process -XstartOnMainThread that does the OpenGL part
                from a Swing application? </span></div>
          </div>
        </blockquote>
        <div style="font-family: Arial, sans-serif; font-size: 14px;
          color: rgb(0, 0, 0);"><span style="font-size: 0.875rem;"><br>
          </span></div>
        <div style="font-family: Arial, sans-serif; font-size: 14px;
          color: rgb(0, 0, 0);"><span style="font-size: 0.875rem;">Sorry
            I do not understand your question. </span><span style="font-size: 0.875rem;">If you speak about triggering
            two process with -XstartOnFirstThread, I think they might
            both freeze</span><span style="font-size: 0.875rem;">. Or
            worse, one freeze and the other one get kick/stopped by the
            former.</span></div>
        <div style="font-family: Arial, sans-serif; font-size: 14px;
          color: rgb(0, 0, 0);"><span style="font-size: 0.875rem;"><br>
          </span></div>
        <div style="font-family: Arial, sans-serif; font-size: 14px;
          color: rgb(0, 0, 0);"><span style="font-size: 0.875rem;">I can
            try this next week because I do not have a macOS with me up
            to next thursday.</span></div>
        <div style="font-family: Arial, sans-serif; font-size: 14px;
          color: rgb(0, 0, 0);"><span style="font-size: 0.875rem;"><br>
          </span></div>
        <blockquote class="protonmail_quote" type="cite">
          <div>
            <div><span style="font-size: 0.875rem;">One hang up there
                though might be that I don’t think java applications
                that include the java native commands are allowed in the
                Mac App Store. Another bug due to each command has it’s
                own unique CFBundleIdentifier but that identifier is
                always the same and Apple doesn’t allow duplicates in
                the App Store.</span></div>
          </div>
        </blockquote>
        <div style="font-family: Arial, sans-serif; font-size: 14px;
          color: rgb(0, 0, 0);"><span style="font-size: 0.875rem;"><br>
          </span></div>
        <div style="font-family: Arial, sans-serif; font-size: 14px;
          color: rgb(0, 0, 0);">Being able to deploy on App Store is not
          an immediate need for me but this is a very interesting point
          to consider. I'll try to understand how CFBundleIdentifier
          relates to -XstartOnFIrstThread.</div>
        <div style="font-family: Arial, sans-serif; font-size: 14px;
          color: rgb(0, 0, 0);"><br>
        </div>
        <div style="font-family: Arial, sans-serif; font-size: 14px;
          color: rgb(0, 0, 0);">Regards,</div>
        <div style="font-family: Arial, sans-serif; font-size: 14px;
          color: rgb(0, 0, 0);"><br>
        </div>
        <div style="font-family: Arial, sans-serif; font-size: 14px;
          color: rgb(0, 0, 0);">Martin</div>
        <div style="font-family: Arial, sans-serif; font-size: 14px;
          color: rgb(0, 0, 0);"><br>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>