ext-image-copy-capture-v1: scale not specified race-free
The ext_image_copy_capture_session_v1
interface has a ::buffer_size
event to specify the size of the buffer to be attached; however, neither it nor ext_image_copy_capture_frame_v1
provide information about what the logical size of the capture source is at the time the frame is captured. (This information is useful when capturing multiple outputs at the same time or when recording a resizing window.) When capturing outputs, the logical size can be estimated by looking at zxdg_output_v1::logical_size
; however, that event is not synchronized with the frame capture operations.
For example, say the following sequence of events happens on a system with a single wl_output
.
- To start: Output scale is 1.5, logical size is 1000x1000 (according to
zxdg_output_v1::logical_size
), and physical size is 1500x1500 (according towl_output::geometry
.) - Image copy capture session created for the output
-
ext_image_copy_capture_session_v1::buffer_size(1500,1500)
is sent - In parallel:
- Output scale changes to 3 and logical size is reduced to 500x500; physical size remains unchanged. A new
zxdg_output_v1::logical_size
is sent. - client requests
ext_image_copy_capture_session_v1::create_frame
, attaches and damages a 1500x1500 buffer, sendsext_image_copy_capture_frame_v1::capture
- Output scale changes to 3 and logical size is reduced to 500x500; physical size remains unchanged. A new
The compositor may have received ext_image_copy_capture_frame_v1::capture
either before or after the output scale change, and because the same buffer size works in both cases, could have sent a frame from either before or after the output scale change. The screen copy operation may be done asynchronously, so that in either case, ready
may arrive after the zxdg_output_v1::logical_size
message. As a result, the client has no way to tell what the logical size of the content is for a specific frame.
Possible solutions:
- introduce sequence numbers for captured frames and
zxdg_output_v1
(may not work for foreign toplevel capture sources) - Add a
logical_size
event toext_image_copy_capture_frame_v1
(Or, to be more precise when fractional scaling is used and the mapping from physical to logical pixels can be ambiguous, afractional_scale
event.)