Properly destroying wl_registry
wl_registry
does not have a destructor request. While clients can destroy the client-side proxy, the server-side resource will remain until the Wayland connection closes. Originally this was thought to be not a problem, because there is no reason for a client to create more than one wl_registry
instance in a connection's life time. Except there are reasons due to existing API design. E.g. Vulkan has no place to cache connection-wide data, and even if it had, I hear the locking requirements do not allow it to work. I believe Vulkan is far from the only API having this problem as Wayland-related component libraries tend to create their own registries, although maybe not as pathological as Vulkan.
We cannot easily version wl_registry
to add new messages, because it is created directly from wl_display
which has a fixed version. Ideas like #106 have floated around. This is another idea:
Define a protocol extension, advertised through wl_registry
, whose global interface has a request destroy_registry(wl_registry)
.
This would need an extension definition XML file (wayland-fixes.xml
in libwayland? or wayland-protocols? or just addition in wayland.xml
?), and a server-side implementation in libwayland-server. The extension could be automatically added when a server struct wl_display
is created.
Client-side implementation would have to be manual, or rely on two new libwayland-client entry points:
- A blocking function that establishes any wayland-fixes extensions available and stores them with the client
struct wl_display
. I believe this is necessary to avoid making existing functions unexpectedly blocking. - A function to destroy
wl_registry
that uses the extension if it was available, or uses the old way otherwise. This is necessary, because the existingwl_registry_destroy()
is astatic inline
generated function callingwl_proxy_destroy()
.
While these two changes need to be done in all client code, I think they are worth it. It avoids unexpected changes in function behavior. The extension establishing function could be used for other fixes as well, if the need arises.