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.
Description
This PR fixes several bugs in the wlgrab capture code used for wlroots-derived compositors.
wlgrab was using the logical size instead of the physical size for capture buffers, which caused problems for environments with a scaling factor != 1.0 (Scaling on Wayland breaks video streaming #238)
wlgrab's
dummy_img()
was not safe to call on a separate thread (as required byPARALLEL_ENCODING
), because it calledwl_display_dispatch()
which can block indefinitely when racing with another thread. When these races didn't lead to hangs, they would randomly lead to corrupt frames being captured that contained an amalgamation of metadata and buffers from partial frames that resulted in theCouldn't import RGB Image: 0000300C
errors. This is fixed by updating VAAPI code to understand dummy images and sampling from a blank RGB texture instead of an imported DMA-BUF. Core dumped with Error: Couldn't import RGB Image: 0000300C (Wayland) #1442wlgrab was calling
wl_display_roundtrip()
in a tight loop when waiting for a new frame. This function is nominally blocking but it just pings the compositor, so this was leading to high CPU usage while waiting for new frames. I've replaced this with a solution that uses the thread-safe event dispatching APIs andpoll()
to let us sleep until the compositor has new data for us.Screenshot
Issues Fixed or Closed
Fixes #238
Fixes #1442
Type of Change
.github/...
)Checklist
Branch Updates
LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.