A destroyed and recreated wl_subsurface is visible before the pending state of the parent surface is applied
See wayland#414 (closed) and wayland#414 (comment 2135486).
The following patch seems to fix the problem shown by the example client, but I don't know if it breaks something else.
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 4ec81c4e..cffc7be0 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -5433,7 +5433,7 @@ weston_subsurface_link_parent(struct weston_subsurface *sub,
parent->pending.status |= WESTON_SURFACE_DIRTY_SUBSURFACE_CONFIG;
- wl_list_insert(&parent->subsurface_list, &sub->parent_link);
+ wl_list_init(&sub->parent_link);
wl_list_insert(&parent->subsurface_list_pending,
&sub->parent_link_pending);