scene-graph debug about the wl_buffer is misleading
static void
debug_scene_view_print_buffer(FILE *fp, struct weston_view *view)
{
struct weston_buffer *buffer = view->surface->buffer_ref.buffer;
struct wl_shm_buffer *shm;
struct linux_dmabuf_buffer *dmabuf;
const struct pixel_format_info *pixel_info = NULL;
if (!buffer) {
fprintf(fp, "\t\t[buffer not available]\n");
return;
}
While this is all correct, it is not really interesting: compositor_accumulate_damage()
will reset that pointer to NULL
so it will look like most surfaces have no buffer available most of the time. Only if you manage to look at the scene-graph in between a client posting a new buffer and the first output repainting after that, you can actually see the buffer here.
This caused me to go on a wild goose chase when with Pixman-renderer all surfaces were marked as "buffer not available" when that would clearly be a bug of use-after-free caliber. Turned out it was a red herring.
However, printing more accurate information here is not easy. A renderer and a backend may each hold references. At the very least one would have to add API to ask a renderer what kind of buffer it has for the surface.
There is also the question of what this debug print is used for. If you want to look at the ephemeral state of a surface when it has an update, then this is exactly it if it happens to be printed at the right time. But for looking at the scene-graph at arbitrary times this is not the right information.
Maybe we need describe_surface_buffer(struct weston_surface *s, FILE *fp)
added in the renderer API, and then add that (not replace) with the existing buffer information (maybe relabel it as "current update")?