Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wlgrab fixes #1978

Merged
merged 5 commits into from
Jan 5, 2024
Merged

Wlgrab fixes #1978

merged 5 commits into from
Jan 5, 2024

Conversation

cgutman
Copy link
Collaborator

@cgutman cgutman commented Jan 3, 2024

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 by PARALLEL_ENCODING), because it called wl_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 the Couldn'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) #1442

  • wlgrab 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 and poll() to let us sleep until the compositor has new data for us.

Screenshot

Issues Fixed or Closed

Fixes #238
Fixes #1442

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

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.

  • I want maintainers to keep my branch updated

@rathmerdominik
Copy link

rathmerdominik commented Jan 4, 2024

That was fast! Right after commenting on the existing issue.
Thank you for your hard work! 😄

@cgutman cgutman merged commit 0dff8b1 into LizardByte:nightly Jan 5, 2024
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants