Okay I think I understand it now. gdk_wayland_window_set_transient_for() does not check it previous parent is the same and deletes the subsurface even when nothing changes. So we need to call gdk_wayland_window_set_transient_for() of if there's a change to avoid the unmap.
Bug 1772073 Comment 20 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Okay I think I understand it now. gdk_wayland_window_set_transient_for() does not check if previous parent is the same and deletes the subsurface even when nothing changes. So we need to call gdk_wayland_window_set_transient_for() of if there's a change to avoid the unmap.