image-copy: Hold references to Buffers to block release

The `wl_buffer` now won't be released until sync fence polls ready.
This commit is contained in:
Ian Douglas Scott 2026-07-07 11:46:42 -07:00 committed by Victoria Brekenfeld
parent d84d5d46ce
commit dd6ebd03c9
3 changed files with 103 additions and 43 deletions

View file

@ -1674,7 +1674,7 @@ fn send_screencopy_result<'a>(
pre_postprocess_data: &mut PrePostprocessData,
tx: &std::sync::mpsc::Sender<PendingImageCopyData>,
frame_result: &RenderFrameResult<GbmBuffer, GbmFramebuffer, CosmicElement<GlMultiRenderer<'a>>>,
elements: &[CosmicElement<GlMultiRenderer>],
elements: &[CosmicElement<GlMultiRenderer<'a>>],
(session, frame, res): (
&ScreencopySessionRef,
ScreencopyFrame,
@ -1855,6 +1855,8 @@ fn send_screencopy_result<'a>(
transform,
damage.as_deref(),
sync,
// Don't reference `Buffer`s since we blit from framebuffer/postprocess buffer
vec![],
)? {
if frame_result.is_empty {
data.frame

View file

@ -41,7 +41,9 @@ use crate::{
compositor::FRAME_TIME_FILTER,
corner_radius::{pad_rect, surface_corners, surface_padding},
data_device::get_dnd_icon,
image_copy_capture::{FrameHolder, SessionData, render_session},
image_copy_capture::{
FrameHolder, SessionData, render_element_buffers, render_session,
},
},
protocols::workspace::WorkspaceHandle,
},
@ -1505,11 +1507,16 @@ where
}
}
Ok(RenderOutputResult {
damage: res.0,
sync,
states: res.1,
})
let buffers = render_element_buffers(renderer, &elements);
Ok((
RenderOutputResult {
damage: res.0,
sync,
states: res.1,
},
buffers,
))
},
)? {
pending_image_copy_data.send_success_when_ready(