Timing problem in xdg_surface causes crash with tooltips
I believe this is related to the discussion here - #3206
I'm using wayfire with a custom panel in which I have ported the Network Manager controller to run as a plugin. This all works fine except in one very specific circumstance. If a tooltip from the panel is on display and while it is displayed, the Network Manager controller opens a dialog on a timed event - such as when a wifi password has been entered incorrectly - at the moment the dialog opens, the panel crashes. I think the proximate cause of the crash is that the text on the tooltip gets updated and almost immediately thereafter the tooltip is closed as a result of the dialog opening.
After a lot of debugging, I have traced this to a timing problem in wlr_xdg_surface.c. (I am using version 0.16.2, the current Sid release.)
At present, the variable 'surface->configured' is set to false in unmap_xdg_surface; this is called when the tooltip closes as the dialog opens. At some point thereafter, xdg_surface_handle_commit is called, presumably in response to the update of the tooltip text, and as 'configured' is now false, this throws the error "xdg_surface has never been configured", which is not the case - the surface is in the process of being destroyed. This error seems to cause the crash.
The surface is not actually destroyed completely until a subsequent call to xdg_surface_role_destroy.
What I have done to fix the problem for me is to remove the call to set 'surface->configured' to false in unmap_xdg_surface, and instead to set it to false immediately after the call to reset_xdg_surface in xdg_surface_role_destroy. I have no idea if that is the correct thing to do, but it seems to fix the problem I am seeing and has no obvious side effects that I can see.
I see some of this code has already changed in top-of-tree, so this bug and the fix may no longer be relevant, but raising it here just in case it is.