Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an error I noticed in #1497 where it the renderer couldn't access an shm buffer that had been destroyed. I believe using a strong reference to the
WlBuffer
won't cause issues here.For dmabuf buffers, retaining a strong
Dmabuf
would not be correct, since the caching is based on strong references to theDmabuf
. I've tested that the same error doesn't occur with dmabufs though. I guess as long as there is a strong reference in theWaylandSurfaceRenderElement
, the user data of theWlBuffer
has a strong reference to theDmabuf
.So no corresponding change is needed for dmabufs, though perhaps its worth thinking if caching could be done differently. It could cache by
Weak<WlBuffer>
instead ofWeakDmabuf
by implementingImportDmaWl
. Though usingWeakDmabuf
allows this to be used with dmabufs that aren't from Wayland. (And it could be nice to disentangle renderers fromwayland_backend
, but that would also require anShmbuf
type or such, instead of just aWlBuffer
reference...)Doing tests with dmabufs, I also noticed that
PixmanRenderer::import_dmabuf()
succeeds for non dmabuf fds (then anvil crashed later when trying to usesync_plane
). Seems good to test this inimport_dmabuf()
and error there, and I can't think of a better way at the moment than callingsync_plane
there.Comparing the gles renderer, I also noticed it was pushing to
dmabuf_cache
regardless ofwayland_frontend
, but only evicting from the cache with that feature. So I removed that#[cfg]
.