On Fri, 22 Sep 2023 15:47:13 +0100 John Cox <j...@kynesim.co.uk> wrote:
> Hi > > >On 9/14/23 14:24, John Cox wrote: > > > >> Hi > >> > >> A, hopefully, simple question - should I expect a wl_buffer::release > >> event from the buffer previously committed to a surface after I've > >> attached (and invalidated & committed) a NULL buffer to the surface? it > >> doesn't seem to happen for me (I have WAYLAND_DEBUG=1 logs showing it > >> not happening). > >> > >> If I shouldn't expect a release - when is it safe to reuse/free the > >> buffer storage? > > > >The compositor may continue using the buffer even if you attach a null > >buffer to the wl_surface. For example, the compositor may do it to play > >an animation if the window is unmapped. > > You've completely lost me with this example. Are you suggesting that > the compositor is reusing my buffer for its own purposes? Not re-using, but simply for needing the old surface contents for longer than the client would expect. Window closing animations are a good example of that: if the window is unmapped (e.g. removing the contents by committing a NULL wl_buffer is a way to unmap a surface, if the surface role allows it), instead of removing the window from screen in the very next refresh, the compositor may start an animation instead where it needs the last known contents of the surface. The window might fade out, shrink and disappear, or fly away, whatever. The compositor needs the last contents to be able to draw that animation over time. From client perspective there is no difference on the wl_surface though, the window is unmapped immediately when the compositor processes the unmapping request. The client does not know about any closing animation, it only sees the buffer release taking a relatively long time. During the closing animation, the compositor won't send input on the wl_surface etc. because from the client perspective it was already unmapped. What's being animated is just a ghost of a window. Thanks, pq
pgp84W8o3j3VK.pgp
Description: OpenPGP digital signature