Skip to content

Fix buffers being destroyed before the wl_buffer.release is received

Olivier Fourdan requested to merge ofourdan/xserver:fix-buffer-release-cb into master

The Wayland buffers in Xwayland are tied to the Pixmaps.

Xwayland tends to destroy the pixmaps as soon as those aren't needed, including the window backend pixmaps and the cursor pixmaps (which is hardcoded to use SHM).

The window buffer mechanism would free the pixmap and its corresponding Wayland buffer as soon as window buffers are disposed (when resizing or 1 closing an X11 window for example).

Yet, the Wayland compositor may still use the buffer until it sends wl_buffer.release event, therefore Xwayland should not destroy the Wayland buffer before a release event is received.

This MR aims at fixing that issue by increasing the reference counter on the pixmap to hold a reference on the pixmap whose buffer will be attached to the surface, and drop that reference when receiving the wl_buffer.release notification.

If the buffer pixmap is to be destroyed before the buffer is released by the compositor, set up a dedicated release callback for that reference to keep the buffer until released by the compositor.

  1. Resizing is fine already in the code from the master branch actually, even though it doesn't use the pixmap's refcount directly, we do not recycle buffers until released, that was the whole point of the window multi-buffer mechanism.

Edited by Olivier Fourdan

Merge request reports