-
Notifications
You must be signed in to change notification settings - Fork 341
Conversation
The texture is managed by the surface's wlr_buffer now. In particular, the buffer can destroy the texture early if it becomes invalid.
This reverts commit d27eeaa.
After some discussions on #wayland, it seems that as soon as you hold a reference to a DMA-BUF (via EGLImage for instance), the underlying memory won't get free'd. The client is allowed to re-use the DMA-BUF and upload something else to it though.
The last commit stops destroying textures when the wl_buffer is destroyed. I still want to retain the same
|
// client destroyed it. Reading the texture itself should be fine because | ||
// we still hold a reference to the DMA-BUF via the texture. However the | ||
// client could decide to re-use the same DMA-BUF for something else, in | ||
// which case we'll read garbage. We decide to accept this risk. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the comment mention that it's a protocol violation on the client side, to reuse the buffers in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's not clear that it's a protocol violation.
types/wlr_buffer.c
Outdated
|
||
struct wlr_buffer *buffer = calloc(1, sizeof(struct wlr_buffer)); | ||
if (buffer == NULL) { | ||
return NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The texture isn't stored anywhere at this point, does it need to be freed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Fixed.
WFM |
Thanks! |
Running rootston through valgrind revealed that when resizing xwayland is destroying buffers before they are released. So merging #1060 fixes the invalid reads.
This PR is just a combination of #1050 and #1060. Fixes #1061.
cc @Ongy @Timidger @ammen99: this is a breaking change. Here's the sway PR: swaywm/sway#2135