wl_surface.attach with NULL wl_buffer behaviour

Pekka Paalanen ppaalanen at gmail.com
Wed Sep 2 23:47:27 PDT 2015


On Wed, 2 Sep 2015 13:38:50 -0500
Prabhu S <prabhusundar at gmail.com> wrote:

> With the below change in simple-shm.c, weston+fbdev backend will be stuck
> and other compositors may work. It depends on compositor implementation and
> the actual behavior supposed to be is not clearly defined. I'm still trying
> to identify fix in weston, it looks like state information is overwritten
> before idle_repaint is being called.
> 
>     window->callback = wl_surface_frame(window->surface);
>     wl_callback_add_listener(window->callback, &frame_listener, window);
>     wl_surface_commit(window->surface);
> 
>    + wl_surface_attach(window->surface, 0, 0, 0);
>     +wl_surface_damage(window->surface,
>               0, 0, 0, 0);
>    + wl_surface_commit(window->surface);
> 

I think this is even worse than compositor-dependent. I think this is a
race, which you usually win or lose based on how the compositor works,
but never guarantees that you always win or lose. I bet the behaviour
you see will differ also depending on whether there are other apps
updating. The race here is, that you do not know if the compositor has
time to display the first buffer before you replace it with the NULL
buffer. If you waited for the frame callback *before* committing the
NULL buffer, things would be race-free. However, pay attention to
Jasper's comments too.

On the first commit you ask for a frame callback. If you then do
another commit, it is like saying "I do not care about the old frame
callback anymore, I am committing now instead." In that case you should
just destroy the wl_callback object from before and be done with it.

Obviously you cannot go and destroy the wl_callback EGL internally
uses. It is best to not commit buffers manually to a wl_surface you are
also updating with eglSwapBuffers().

I do not think there is anything to fix in Weston in this respect.


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20150903/4993a479/attachment.sig>


More information about the wayland-devel mailing list