Bug 108996 - Leaks buffer when closing wayland window
Summary: Leaks buffer when closing wayland window
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/etnaviv (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Etnaviv Developers
QA Contact: Etnaviv Developers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-09 21:43 UTC by Sjoerd Simons
Modified: 2019-01-15 13:08 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Sjoerd Simons 2018-12-09 21:43:46 UTC
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] https://gitlab.freedesktop.org/sjoerd/weston/tree/mesa-leak
[1] https://gitlab.freedesktop.org/sjoerd/weston/commit/934e195c1b4d5fdd7ec006c8f7048ad30df8738f
Comment 1 Sjoerd Simons 2018-12-12 13:36:05 UTC
Tomeu pointed out that the reproduction case forgot to call eglDestroyContext. With that chagne the issue no longer occurs on my Amd based system, but the issue still happens on etnaviv with mesa 18.2.4. Debugging this further now.

Updated the branch to reproduce with that fix as well
Comment 2 Emil Velikov 2019-01-15 13:08:45 UTC
IIRC the outtake was that the example patch fails to teardown the old ctx before setting up a new one.

Although the root problem was a leak in the etnaviv driver, which should be addressed with the following. Marking as fixed, feel free to reopen if that's not the case.


commit bf1dfcc3e8120400c9a78d03dd914a786728b5f7
Author: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Date:   Mon Dec 17 09:56:00 2018 +0100

    etnaviv: Consolidate buffer references from framebuffers


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.