From f962b4895891a495e147d795cc47a7af9ca441f6 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 1 Jun 2022 16:56:49 +0100 Subject: [PATCH] compositor: Only create paint nodes for mapped surfaces/views If a surface or a view is not mapped, then we should not be trying to paint it. Check if this is the case and ensure that we only insert paint nodes for mapped surfaces & views. Signed-off-by: Daniel Stone Fixes: #621 --- include/libweston/libweston.h | 4 ++++ libweston/compositor.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index acfad1b3..dbf80b15 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -1311,6 +1311,10 @@ struct weston_compositor { struct weston_log_scope *libseat_debug; struct content_protection *content_protection; + + /* One-time warning about a view appearing in the layer list when it + * or its surface are not mapped. */ + bool warned_about_unmapped_surface_or_view; }; struct weston_buffer { diff --git a/libweston/compositor.c b/libweston/compositor.c index 47226f73..bd1ad5e8 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -2991,6 +2991,26 @@ view_list_add(struct weston_compositor *compositor, struct weston_subsurface *sub; weston_view_update_transform(view); + + /* It is possible for a view to appear in the layer list even though + * the view or the surface is unmapped. This is erroneous but difficult + * to fix. */ + if (!weston_surface_is_mapped(view->surface) || + !weston_view_is_mapped(view) || + !weston_surface_has_content(view->surface)) { + if (!compositor->warned_about_unmapped_surface_or_view) { + weston_log("Detected an unmapped surface or view in " + "the layer list, which should not occur.\n"); + compositor->warned_about_unmapped_surface_or_view = true; + } + + pnode = weston_view_find_paint_node(view, output); + if (pnode) + weston_paint_node_destroy(pnode); + + return; + } + pnode = view_ensure_paint_node(view, output); if (wl_list_empty(&view->surface->subsurface_list)) {