<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Gallium EGL on Wayland blocks in eglInitialize (no display thread bound)"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=65427">65427</a>
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Gallium EGL on Wayland blocks in eglInitialize (no display thread bound)
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jay@jcornwall.me
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>git
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=80361" name="attach_80361" title="Potential fix for Gallium EGL Wayland protocol">attachment 80361</a> <a href="attachment.cgi?id=80361&action=edit" title="Potential fix for Gallium EGL Wayland protocol">[details]</a></span>
Potential fix for Gallium EGL Wayland protocol

wayland_drm_display_init_screen (via wayland_roundtrip) blocks indefinitely in
wl_display_dispatch_queue. The man page explains this behavior:

[A user created queue is dispatched with wl_display_dispatch_queue(). If there
are no events to dispatch this function will block. If this is called by the
main thread, this will attempt to read data from the display fd and queue any
events on the appropriate queues. If calling from any other thread, the
function will block until the main thread queues an event on the queue being
dispatched.]

The calling thread is not identified by libwayland-client as the "main thread".
The protocol used in Wayland test programs is to call
wl_display_dispatch_pending() prior to this point, which sets the calling
thread as the "main thread". See attached patch and test case.

While this fixes the test case (and all EGL calls for a single-threaded
application), this problem may also affect other calls, e.g. eglSwapBuffers(),
which is specified to be callable from different threads. The same
wl_display_dispatch_queue() call could be introduced into this path (rebinding
the "main thread" with each call), but the overhead of doing so has not been
measured.

It may be preferable to do this in wayland_roundtrip() or to consider a change
in Wayland itself.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>