weston: Add fix for using layer_entry_remove directly
authorMarius Vlad <marius.vlad@collabora.com>
Tue, 9 Apr 2024 15:30:57 +0000 (18:30 +0300)
committerJan-Simon Möller <jsmoeller@linuxfoundation.org>
Fri, 26 Apr 2024 14:15:24 +0000 (16:15 +0200)
Patch was proposed initially with a different fix upstream but
was changed a bit later.

Bug-AGL: SPEC-5105
Change-Id: I3fb6cc3d4a7b2a63b4296a2d36a998a55ccb8bc5
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/29817
Tested-by: Scott Murray <scott.murray@konsulko.com>
Reviewed-by: Scott Murray <scott.murray@konsulko.com>
meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Add-paint-node-destruction-into-weston_lay.patch [new file with mode: 0644]
meta-agl-core/recipes-graphics/wayland/weston_13.0_aglcore.inc

diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Add-paint-node-destruction-into-weston_lay.patch b/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Add-paint-node-destruction-into-weston_lay.patch
new file mode 100644 (file)
index 0000000..19eadcf
--- /dev/null
@@ -0,0 +1,60 @@
+From cfde02d47a503cbfd0629bbfe0cb776686af8a91 Mon Sep 17 00:00:00 2001
+From: Marius Vlad <marius.vlad@collabora.com>
+Date: Tue, 9 Apr 2024 18:34:22 +0300
+Subject: [PATCH] libweston: Add paint node destruction into
+ weston_layer_entry_remove()
+
+This prevents a potential crash where users of
+weston_layer_entry_insert/layer_entry_remove() would see when moving
+views into a NULL layer (effectively unmapping the surface/view).
+
+Users that have migrated to the weston_view_move_to_layer() are immune
+to this issue because that takes care paint node destruction.
+
+Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
+---
+ libweston/compositor.c | 17 ++++++++++-------
+ 1 file changed, 10 insertions(+), 7 deletions(-)
+
+diff --git a/libweston/compositor.c b/libweston/compositor.c
+index bb29b83b5..ea257bb90 100644
+--- a/libweston/compositor.c
++++ b/libweston/compositor.c
+@@ -3980,17 +3980,10 @@ weston_view_move_to_layer(struct weston_view *view,
+                         struct weston_layer_entry *layer)
+ {
+       bool was_mapped = view->is_mapped;
+-      struct weston_paint_node *pnode, *pntmp;
+       if (layer == &view->layer_link)
+               return;
+-      /* Remove all paint nodes because we have no idea what a layer change
+-       * does to view visibility on any output.
+-       */
+-      wl_list_for_each_safe(pnode, pntmp, &view->paint_node_list, view_link)
+-              weston_paint_node_destroy(pnode);
+-
+       view->surface->compositor->view_list_needs_rebuild = true;
+       /* Damage the view's old region, and remove it from the layer. */
+@@ -4020,6 +4013,16 @@ weston_view_move_to_layer(struct weston_view *view,
+ WL_EXPORT void
+ weston_layer_entry_remove(struct weston_layer_entry *entry)
+ {
++      struct weston_paint_node *pnode, *pntmp;
++      struct weston_view *view;
++
++      /* Remove all paint nodes because we have no idea what a layer change
++       * does to view visibility on any output.
++       */
++      view = container_of(entry, struct weston_view, layer_link);
++      wl_list_for_each_safe(pnode, pntmp, &view->paint_node_list, view_link)
++              weston_paint_node_destroy(pnode);
++
+       wl_list_remove(&entry->link);
+       wl_list_init(&entry->link);
+       entry->layer = NULL;
+-- 
+2.43.0
+
index 1438789..843a068 100644 (file)
@@ -4,6 +4,7 @@ PACKAGECONFIG:append = "${@bb.utils.contains('DISTRO_FEATURES', 'weston-remoting
 
 SRC_URI:append = " \
                  file://0001-clients-Handle-missing-pointer_surface-is-there-s-no.patch \
+                 file://0001-libweston-Add-paint-node-destruction-into-weston_lay.patch \
 "