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

List:       openjdk-openjfx-dev
Subject:    Re: Wayland
From:       Thiago_Milczarek_Sayão <thiago.sayao () gmail ! com>
Date:       2024-04-29 21:35:19
Message-ID: CAAP_wumDKeeQM-_Sv_MwZXi0Oq+DmKe1eLOueuxxbDg+5tA-fg () mail ! gmail ! com
[Download RAW message or body]

I thought about possible legal conflicts.

The code is on my github - I'm exploring and testing before starting the
real work.

wayland-scanner generates code from the protocol specs, which are xml files.
https://wayland.app/protocols/

I will write a new generator/scanner from scratch - it's not too much work.
The generator/scanner itself does not necessarily need to be part of the
PR, but it might be a good idea to include it, since the protocol changes
over time.

-- Thiago.



Em seg., 29 de abr. de 2024 Ã s 18:10, Kevin Rushforth <
kevin.rushforth@oracle.com> escreveu:

> As a reminder, contributors must not include 3rd-party code in any openjdk
> repo. Per the terms of the OCA, all code that you contribute to OpenJDK
> must be your own code. This includes code you push to openjdk/jfx-sandbox
> and code in a branch of a personal fork of openjdk/jfx from which you
> create a PR.
> 
> -- Kevin
> 
> 
> On 4/28/2024 2:45 PM, Thiago Milczarek Sayão wrote:
> 
> Hi,
> 
> I managed to display a very basic wayland toplevel surface from java:
> https://github.com/tsayao/glass-wayland
> 
> If you are using intellij, just run the "Test App" (with java 22).
> 
> generate.sh will jextract the code from wayland-client.
> 
> I rushed to get the window displayed - so it doesn't look good yet (but I
> do accept suggestions).
> 
> It uses a java wayland-scanner (included) to read protocol xml files and
> generate code that uses jextracted calls.
> 
> The sample also binds EGL and GL apis, but just because wayland requires a
> buffer to display the surface. Maybe it was easier to use a shared memory :)
> 
> Credits to (I adapted it to ouput jextract compatible code):
> https://github.com/gfxstrand/wayland-java/tree/master/scanner
> 
> Cheers
> 
> Em ter., 23 de abr. de 2024 às 09:11, Thiago Milczarek Sayão <
> thiago.sayao@gmail.com> escreveu:
> 
> > I'm doing some work here:
> > https://github.com/tsayao/glass-wayland
> > 
> > So far it's been a good experience to use FFM / jextract.
> > 
> > The idea is to plug it as a glass wayland backend when it's good enough.
> > 
> > 
> > 
> > Em seg., 22 de abr. de 2024 Ã s 16:16, Nir Lisker <nlisker@gmail.com>
> > escreveu:
> > 
> > > Not sure it helps with warmup, but marking a foreign function as
> > > critical can improve performance:
> > > https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/foreign/Linker.Option.html#critical(boolean)
> > >                 
> > > .
> > > 
> > > On Mon, Apr 22, 2024 at 10:02 PM Philip Race <philip.race@oracle.com>
> > > wrote:
> > > 
> > > > No, it wasn't. I didn't even use jextracted code.
> > > > The startup cost is around initialisation of FFM - around 70 ms (IIRC)
> > > > overhead on my MacBook
> > > > Then creation of VarHandles and MethodHandles - 2-5 ms each is what I
> > > > measured, so do these lazily if you can.
> > > > And warmup cost is that it takes about 10000 iterations to get code
> > > > fully compiled.
> > > > 
> > > > java -XX:+PrintFlagsFinal -version 2>&1 | grep CompileThreshold
> > > > intx CompileThreshold                         =
> > > > 10000                                  {pd product} {default}
> > > > double CompileThresholdScaling                  =
> > > > 1.000000                                  {product} {default}
> > > > uintx IncreaseFirstTierCompileThresholdAt      =
> > > > 50                                        {product} {default}
> > > > intx Tier2CompileThreshold                    =
> > > > 0                                         {product} {default}
> > > > intx Tier3CompileThreshold                    =
> > > > 2000                                      {product} {default}
> > > > intx Tier4CompileThreshold                    =
> > > > 15000                                     {product} {default}
> > > > 
> > > > -phil.
> > > > 
> > > > 
> > > > On 4/22/24 11:45 AM, Thiago Milczarek Sayão wrote:
> > > > 
> > > > I think the startup time might be related to all static symbol lookups.
> > > > So I'm manually including just what is needed:
> > > > 
> > > > jextract --output src -t com.sun.glass.wayland.extracted \
> > > > --header-class-name GlassWayland \
> > > > `pkg-config --libs glib-2.0 gio-2.0 libportal wayland-client` \
> > > > `pkg-config --cflags-only-I glib-2.0 gio-2.0 libportal wayland-client` \
> > > > glass-wayland.h \
> > > > --include-function xdp_portal_initable_new \
> > > > --include-function xdp_session_close \
> > > > --include-function xdp_portal_open_file \
> > > > --include-function xdp_portal_open_file_finish \
> > > > --include-function g_object_unref \
> > > > --include-function g_timeout_add \
> > > > --include-function g_add_idle \
> > > > --include-function g_main_loop_run \
> > > > --include-function g_main_loop_new \
> > > > --include-function g_main_loop_ref \
> > > > --include-function g_main_loop_unref \
> > > > --include-function g_main_loop_quit \
> > > > --include-function g_settings_new \
> > > > --include-function g_settings_get_int \
> > > > --include-function wl_display_connect \
> > > > --include-function wl_display_disconnect \
> > > > --include-function wl_display_roundtrip \
> > > > --include-function wl_display_dispatch_pending \
> > > > --include-typedef GAsyncReadyCallback \
> > > > --include-typedef GSourceFunc \
> > > > --include-typedef GError
> > > > 
> > > > 
> > > > Em seg., 22 de abr. de 2024 Ã s 13:24, Philip Race <
> > > > philip.race@oracle.com> escreveu:
> > > > 
> > > > > As a reminder, using FFM will require all FX *applications* to specify
> > > > > --enable-native-access on the command line
> > > > > Although this is likely coming to JNI soon too.
> > > > > 
> > > > > https://docs.oracle.com/en/java/javase/21/core/restricted-methods.html
> > > > > 
> > > > > But one thing to watch out for with FFM is startup + warm up time.
> > > > > I struggled a lot with that in using FFM for just one library in the
> > > > > java.desktop module.
> > > > > 
> > > > > -phil
> > > > > 
> > > > > On 4/22/24 9:12 AM, Nir Lisker wrote:
> > > > > 
> > > > > Sorry, we bumped to Java 21 in JavaFX 22 I think since we preserve the
> > > > > N-1 rule.
> > > > > 
> > > > > On Mon, Apr 22, 2024 at 6:03 PM Nir Lisker <nlisker@gmail.com> wrote:
> > > > > 
> > > > > > I think that we'll be able to bump to Java 25 in JavaFX 25, like we
> > > > > > did with 21. I suggested initially to bump to Java 22 exactly for FFM as
> > > > > > it's very useful for JavaFX, but was told we shouldn't since it's not an
> > > > > > LTS version.
> > > > > > 
> > > > > > I have no idea how long the work on Wayland will take including the
> > > > > > code review (a rather long process), but you should be able to request \
> > > > > > code reviews with FFM and have it ready for integration by Java 25.
> > > > > > 
> > > > > > On Mon, Apr 22, 2024 at 5:49 PM Thiago Milczarek Sayão <
> > > > > > thiago.sayao@gmail.com> wrote:
> > > > > > 
> > > > > > > I was just experimenting, but it seems to be less work than going
> > > > > > > with JNI.
> > > > > > > If I am correct, the next Java LTS will be 25, which will be
> > > > > > > required on JavaFX 29 to be released on September/29.
> > > > > > > 
> > > > > > > It's 7 years - that's really too much.
> > > > > > > 
> > > > > > > Maybe it's still worthwhile to prototype using FFM and then port
> > > > > > > everything to JNI.
> > > > > > > 
> > > > > > > -- Thiago.
> > > > > > > 
> > > > > > > 
> > > > > > > Em seg., 22 de abr. de 2024 Ã s 11:21, Kevin Rushforth <
> > > > > > > kevin.rushforth@oracle.com> escreveu:
> > > > > > > 
> > > > > > > > Note also that we cannot use Panama in the JavaFX internals yet,
> > > > > > > > since
> > > > > > > > the minimum version of the JDK is 21.
> > > > > > > > 
> > > > > > > > -- Kevin
> > > > > > > > 
> > > > > > > > 
> > > > > > > > On 4/21/2024 10:51 AM, Thiago Milczarek Sayão wrote:
> > > > > > > > > Hi,
> > > > > > > > > 
> > > > > > > > > I did a small test app to explore Wayland client and portals (for
> > > > > > > > > Robot and dialogs such as file open/save).
> > > > > > > > > 
> > > > > > > > > https://github.com/tsayao/wayland-test/blob/main/wayland-test.c
> > > > > > > > > 
> > > > > > > > > It seems it will work as a glass backend, but some walls will be
> > > > > > > > hit
> > > > > > > > > on the way :)
> > > > > > > > > 
> > > > > > > > > I have tried to use jextract (from project Panama) to work
> > > > > > > > directly
> > > > > > > > > with java, but it seems it does not support wl_ types.
> > > > > > > > > 
> > > > > > > > > -- Thiago.
> > > > > > > > 
> > > > > > > > 
> > > > > 
> > > > 
> 


[Attachment #3 (text/html)]

<div dir="ltr"><div dir="ltr">I thought about possible legal conflicts.</div><div \
dir="ltr"><br></div><div>The code is on my github - I&#39;m exploring and testing \
before starting the real work.</div><div \
dir="ltr"><div><br></div><div>wayland-scanner generates code from the protocol specs, \
which are xml files.</div><div><a \
href="https://wayland.app/protocols/">https://wayland.app/protocols/</a><br></div><div><br></div><div>I \
will write a new generator/scanner from scratch - it&#39;s not too much work.  \
</div><div>The generator/scanner itself does not necessarily  need to be part of the \
PR, but it might be a good idea to include it, since the protocol changes over \
time.<br></div><div><br></div><div>-- \
Thiago.</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div \
dir="ltr" class="gmail_attr">Em seg., 29 de abr. de 2024 Ã s 18:10, Kevin Rushforth \
&lt;<a href="mailto:kevin.rushforth@oracle.com">kevin.rushforth@oracle.com</a>&gt; \
escreveu:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>

  
  <div>
    As a reminder, contributors must not include 3rd-party code in any
    openjdk repo. Per the terms of the OCA, all code that you contribute
    to OpenJDK must be your own code. This includes code you push to
    openjdk/jfx-sandbox and code in a branch of a personal fork of
    openjdk/jfx from which you create a PR.<br>
    <br>
    -- Kevin<br>
    <br>
    <br>
    <div>On 4/28/2024 2:45 PM, Thiago Milczarek
      Sayão wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">Hi,
        <div><br>
        </div>
        <div>I managed to display a very basic wayland toplevel surface
          from java:</div>
        <div><a href="https://github.com/tsayao/glass-wayland" \
target="_blank">https://github.com/tsayao/glass-wayland</a><br>  </div>
        <div><br>
        </div>
        <div>If you are using intellij, just run the &quot;Test App&quot; (with
          java 22).</div>
        <div><br>
        </div>
        <div>generate.sh will jextract the code from wayland-client.</div>
        <div><br>
        </div>
        <div>I rushed to get the window displayed - so it doesn&#39;t look
          good yet (but I do accept suggestions).</div>
        <div><br>
        </div>
        <div>It uses a java wayland-scanner (included) to read protocol
          xml files and generate code that uses jextracted calls.</div>
        <div><br>
        </div>
        <div>The sample also binds EGL and GL apis, but just because
          wayland requires a buffer to display the surface. Maybe it was
          easier to use a shared memory :)</div>
        <div><br>
        </div>
        <div>Credits to (I adapted it to ouput jextract compatible
          code):</div>
        <div><a href="https://github.com/gfxstrand/wayland-java/tree/master/scanner" \
target="_blank">https://github.com/gfxstrand/wayland-java/tree/master/scanner</a><br> \
</div>  <div><br>
        </div>
        <div>Cheers</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">Em ter., 23 de abr. de 2024 Ã s
          09:11, Thiago Milczarek Sayão &lt;<a href="mailto:thiago.sayao@gmail.com" \
target="_blank">thiago.sayao@gmail.com</a>&gt;  escreveu:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  <div dir="ltr">
            <div>I&#39;m doing some work here:</div>
            <div><a href="https://github.com/tsayao/glass-wayland" \
target="_blank">https://github.com/tsayao/glass-wayland</a><br>  </div>
            <div><br>
            </div>
            <div>So far it&#39;s been a good experience to use FFM /
              jextract.</div>
            <div><br>
            </div>
            <div>The idea is to plug it as a glass wayland backend when
              it&#39;s good enough.</div>
            <div><br>
            </div>
            <div><br>
            </div>
          </div>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">Em seg., 22 de abr. de
              2024 Ã s 16:16, Nir Lisker &lt;<a href="mailto:nlisker@gmail.com" \
target="_blank">nlisker@gmail.com</a>&gt;  escreveu:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  <div dir="ltr">Not \
sure it helps with warmup, but marking  a foreign function as critical can improve \
performance:  <a href="https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/foreign/Linker.Option.html#critical(boolean)" \
target="_blank">https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/foreign/Linker.Option.html#critical(boolean)</a>.</div>
  <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Mon, Apr 22, 2024
                  at 10:02 PM Philip Race &lt;<a \
href="mailto:philip.race@oracle.com" target="_blank">philip.race@oracle.com</a>&gt;  \
wrote:<br>  </div>
                <blockquote class="gmail_quote" style="margin:0px 0px 0px \
                0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                  <div> No, it wasn&#39;t. I didn&#39;t even use jextracted
                    code.<br>
                    The startup cost is around initialisation of FFM -
                    around 70 ms (IIRC) overhead on my MacBook<br>
                    Then creation of VarHandles and MethodHandles - 2-5
                    ms each is what I measured, so do these lazily if
                    you can.<br>
                    And warmup cost is that it takes about 10000
                    iterations to get code fully compiled.<br>
                    <br>
                    java -XX:+PrintFlagsFinal -version 2&gt;&amp;1 |
                    grep CompileThreshold<br>
                             intx CompileThreshold                                    \
                =
                    10000                                                             \
{pd product}  {default}<br>
                           double CompileThresholdScaling                             \
                
                    = 1.000000                                                        \
  {product} {default}<br>
                           uintx IncreaseFirstTierCompileThresholdAt           =
                    50                                                                \
{product}  {default}<br>
                             intx Tier2CompileThreshold                               \
                =
                    0                                                                 \
{product}  {default}<br>
                             intx Tier3CompileThreshold                               \
                =
                    2000                                                              \
{product}  {default}<br>
                             intx Tier4CompileThreshold                               \
                =
                    15000                                                             \
{product}  {default}<br>
                    <br>
                    -phil.<br>
                    <br>
                    <br>
                    <div>On 4/22/24 11:45 AM, Thiago Milczarek Sayão
                      wrote:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">I think the startup time might be
                        related to all static symbol lookups.
                        <div>So I&#39;m manually including just what is
                          needed:<br>
                        </div>
                        <div>
                          <div>
                            <div \
style="background-color:rgb(30,31,34);color:rgb(188,190,196)">  <pre \
style="font-family:&quot;JetBrains Mono&quot;,monospace;font-size:9.8pt"><span \
style="color:rgb(197,118,51)">jextract </span>--output src -t \
                com.sun.glass.wayland.extracted \
  --header-class-name GlassWayland \
  <span style="color:rgb(197,118,51)">`pkg-config </span>--libs glib-2.0 gio-2.0 \
libportal wayland-client<span style="color:rgb(197,118,51)">`</span> \  <span \
style="color:rgb(197,118,51)">`pkg-config </span>--cflags-only-I glib-2.0 gio-2.0 \
libportal wayland-client<span style="color:rgb(197,118,51)">`</span> \  \
                glass-wayland.h \
   --include-function xdp_portal_initable_new \
   --include-function xdp_session_close \
   --include-function xdp_portal_open_file \
   --include-function xdp_portal_open_file_finish \
   --include-function g_object_unref \
   --include-function g_timeout_add \
   --include-function g_add_idle \
   --include-function g_main_loop_run \
   --include-function g_main_loop_new \
   --include-function g_main_loop_ref \
   --include-function g_main_loop_unref \
   --include-function g_main_loop_quit \
   --include-function g_settings_new \
   --include-function g_settings_get_int \
   --include-function wl_display_connect \
   --include-function wl_display_disconnect \
   --include-function wl_display_roundtrip \
   --include-function wl_display_dispatch_pending \
   --include-typedef GAsyncReadyCallback \
   --include-typedef GSourceFunc \
   --include-typedef GError
</pre>
                            </div>
                          </div>
                        </div>
                      </div>
                      <br>
                      <div class="gmail_quote">
                        <div dir="ltr" class="gmail_attr">Em seg., 22 de
                          abr. de 2024 Ã s 13:24, Philip Race &lt;<a \
href="mailto:philip.race@oracle.com" target="_blank">philip.race@oracle.com</a>&gt;  \
escreveu:<br>  </div>
                        <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  <div> As a reminder, \
using FFM will require  all FX *applications* to specify
                            --enable-native-access on the command line<br>
                            Although this is likely coming to JNI soon
                            too.<br>
                            <br>
                            <a \
href="https://docs.oracle.com/en/java/javase/21/core/restricted-methods.html" \
target="_blank">https://docs.oracle.com/en/java/javase/21/core/restricted-methods.html</a><br>
  <br>
                            But one thing to watch out for with FFM is
                            startup + warm up time.<br>
                            I struggled a lot with that in using FFM for
                            just one library in the java.desktop module.<br>
                            <br>
                            -phil<br>
                            <br>
                            <div>On 4/22/24 9:12 AM, Nir Lisker wrote:<br>
                            </div>
                            <blockquote type="cite">
                              <div dir="ltr">Sorry, we bumped to Java 21
                                in JavaFX 22 I think since we
                                preserve  the N-1 rule.</div>
                              <br>
                              <div class="gmail_quote">
                                <div dir="ltr" class="gmail_attr">On
                                  Mon, Apr 22, 2024 at 6:03 PM Nir
                                  Lisker &lt;<a href="mailto:nlisker@gmail.com" \
target="_blank">nlisker@gmail.com</a>&gt;  wrote:<br>
                                </div>
                                <blockquote class="gmail_quote" style="margin:0px 0px \
0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  <div dir="ltr">I \
think that we&#39;ll be  able to bump to Java 25 in JavaFX
                                    25, like we did with 21. I suggested
                                    initially to bump to Java 22 exactly
                                    for FFM as it&#39;s very useful for
                                    JavaFX, but was told we shouldn&#39;t
                                    since it&#39;s not an LTS version.
                                    <div><br>
                                    </div>
                                    <div>I have no idea how long the
                                      work on Wayland will take
                                      including the code review (a
                                      rather long process), but you
                                      should be able to request code
                                      reviews with FFM and have it ready
                                      for integration by Java 25.</div>
                                  </div>
                                  <br>
                                  <div class="gmail_quote">
                                    <div dir="ltr" class="gmail_attr">On
                                      Mon, Apr 22, 2024 at 5:49 PM
                                      Thiago Milczarek Sayão &lt;<a \
href="mailto:thiago.sayao@gmail.com" target="_blank">thiago.sayao@gmail.com</a>&gt;  \
wrote:<br>  </div>
                                    <blockquote class="gmail_quote" style="margin:0px \
0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  <div \
dir="ltr">I was just  experimenting, but it seems to
                                        be less work than going with
                                        JNI.
                                        <div>If I am correct, the next
                                          Java LTS will be 25, which
                                          will be required on JavaFX 29
                                          to be released on
                                          September/29.<br>
                                        </div>
                                        <div><br>
                                        </div>
                                        <div>It&#39;s 7 years - that&#39;s
                                          really too much.</div>
                                        <div><br>
                                        </div>
                                        <div>Maybe it&#39;s still worthwhile
                                          to prototype using FFM and
                                          then port everything to JNI.</div>
                                        <div><br>
                                        </div>
                                        <div>-- Thiago.</div>
                                        <div><br>
                                        </div>
                                      </div>
                                      <br>
                                      <div class="gmail_quote">
                                        <div dir="ltr" class="gmail_attr">Em seg., 22
                                          de abr. de 2024 Ã s 11:21,
                                          Kevin Rushforth &lt;<a \
href="mailto:kevin.rushforth@oracle.com" \
target="_blank">kevin.rushforth@oracle.com</a>&gt;  escreveu:<br>
                                        </div>
                                        <blockquote class="gmail_quote" \
style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">Note  also that we cannot use Panama
                                          in the JavaFX internals yet,
                                          since <br>
                                          the minimum version of the JDK
                                          is 21.<br>
                                          <br>
                                          -- Kevin<br>
                                          <br>
                                          <br>
                                          On 4/21/2024 10:51 AM, Thiago
                                          Milczarek Sayão wrote:<br>
                                          &gt; Hi,<br>
                                          &gt;<br>
                                          &gt; I did a small test app to
                                          explore Wayland client and
                                          portals (for <br>
                                          &gt; Robot and dialogs such as
                                          file open/save).<br>
                                          &gt;<br>
                                          &gt; <a \
href="https://github.com/tsayao/wayland-test/blob/main/wayland-test.c" \
rel="noreferrer" target="_blank">https://github.com/tsayao/wayland-test/blob/main/wayland-test.c</a><br>
  &gt;<br>
                                          &gt; It seems it will work as
                                          a glass backend, but some
                                          walls will be hit <br>
                                          &gt; on the way :)<br>
                                          &gt;<br>
                                          &gt; I have tried to use
                                          jextract (from project Panama)
                                          to work directly <br>
                                          &gt; with java, but it seems
                                          it does not support wl_ types.<br>
                                          &gt;<br>
                                          &gt; -- Thiago.<br>
                                          <br>
                                        </blockquote>
                                      </div>
                                    </blockquote>
                                  </div>
                                </blockquote>
                              </div>
                            </blockquote>
                            <br>
                          </div>
                        </blockquote>
                      </div>
                    </blockquote>
                    <br>
                  </div>
                </blockquote>
              </div>
            </blockquote>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </div>

</blockquote></div></div>



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

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