<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Leaks buffer when closing wayland window"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=108996">108996</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Leaks buffer when closing wayland window
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr>

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

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

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

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

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

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>EGL/Wayland
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>wayland-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>sjoerd@luon.net
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hey,

When closing a EGL using window on wayland it seems there is always a (color)
buffer leaked until the process exits; We first noticed this with Qt using apps
on an etnaviv based system, however the same can be reproduce on Intel gpu's

To reproduce I created a modified weston-simple-egl[0] which simply every 60
frames will destroy the current surface and create a new one[1].

As mentioned the issue both occurs on both etnaviv and intel systems where
there is seemingly one dmabuf leaked every time the window gets closed (as per
/sys/kernel/debug/dma_buf/bufinfo). It can also be reproduce by using software
rendering (LIBGL_ALWAYS_SOFTWARE=1) in which case memory grows every time the
window is recreated (presumably for the same reason).

While tracing it down as far as i could it seems that the `current` buffer of
the relevant dri2_egl_surface has extra references on it when ->destroyImage
gets called on match color_buffer in `dri2_wl_destroy_surface` (while the other
allocated buffers/driImages don't). Why these extra references (presumably for
the next render?) aren't cleared up is unfortunately a bit beyond my
understanding of mesa.

This is reproducable both with mesa 18.2.6 and git master


[0] <a href="https://gitlab.freedesktop.org/sjoerd/weston/tree/mesa-leak">https://gitlab.freedesktop.org/sjoerd/weston/tree/mesa-leak</a>
[1]
<a href="https://gitlab.freedesktop.org/sjoerd/weston/commit/934e195c1b4d5fdd7ec006c8f7048ad30df8738f">https://gitlab.freedesktop.org/sjoerd/weston/commit/934e195c1b4d5fdd7ec006c8f7048ad30df8738f</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>