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

Cropped pipewire source spills over the bounding box #4982

Closed
Hubro opened this issue Jul 6, 2021 · 1 comment
Closed

Cropped pipewire source spills over the bounding box #4982

Hubro opened this issue Jul 6, 2021 · 1 comment
Labels
Linux Affects Linux

Comments

@Hubro
Copy link

Hubro commented Jul 6, 2021

Operating System Info

Other

Other OS

Arch Linux

OBS Studio Version

27.0.1

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/6ZlEHr2nRlovNAUT

OBS Studio Crash Log URL

No response

Expected Behavior

When capturing a cropped Pipewire source, the source should be rendered as expected in OBS.

Current Behavior

When capturing a cropped Pipewire source, the crop is correctly applied to the left side of the source, but the right side spills over the bounding box. Screenshot:

image

In this case I am running OBS on a 5120x1440 monitor with Pipewire set up to share a 2560x1440 rectangle at the center of the monitor. OBS appears to correctly display the bounding box, but it's not actually cropping the right side of the source.

If I apply a local crop in the Transform settings of the source in OBS, the overflow immediately disappears:

image

It doesn't matter which side of the bounding box I add the crop to. I just need to add 1 px to any side.

Steps to Reproduce

  1. Set up a Pipewire stream with cropping metadata (see Allow sharing of a region of a monitor emersion/xdg-desktop-portal-wlr#154 for an example)
  2. Capture the stream using "Window Capture (Pipewire)" or "Desktop Capture (Pipewire) on OBS, running in Wayland mode
  3. Resize the canvas or the source so you can see the right edge of the pipewire source. The contents should be spilling over the bounding box edge to the right.

It may also spill over the bottom bounding box, but I haven't tested that.

Anything else we should know?

See emersion/xdg-desktop-portal-wlr#154 for the context of how this bug was discovered

@Hubro Hubro changed the title Cropped pipewire source is not properly cropped in OBS Cropped pipewire source spills over the bounding box Jul 6, 2021
@kkartaltepe kkartaltepe added the Linux Affects Linux label Jul 6, 2021
@Hubro
Copy link
Author

Hubro commented Jul 6, 2021

image

I tested cropping the Pipewire screen capture to a 1280x800 rectangle at the center of my monitor. The source spills over the bounding box both to the right and at the bottom.

Again, applying a local crop under "Edit Transform..." (1px to any edge) fixes the overflow:

image

GeorgesStavracas added a commit to GeorgesStavracas/obs-studio that referenced this issue Jul 7, 2021
The gs_draw_sprite_subregion() function is used when a cropping
rectangle is received from PipeWire. It is usually used by
compositors to implement window screencast - where a large and
mostly empty frame is sent, the window contents are only a small
part of it, and the crop rectangle tells us that.

Recently the wlroots implementation of portals started to use it
to implement cropping, and it exposed a bug in the PipeWire code
in OBS Studio. The gs_draw_sprite_subregion() function takes a
pair of floats representing position (x, y) and a pair of floats
representing size (width, height). The PipeWire code, however,
passes a second pair of positions (x2, y2) instead of sizes, and
it causes overrendering the crop area.

This bug wasn't hit yet because both GNOME and KDE implementations
always send (0, 0) as position, which practically never trigger
this condition.

Pass only width and height to gs_draw_sprite_subregion(), instead
of summing them with x and y.

Fixes obsproject#4982
GeorgesStavracas added a commit to GeorgesStavracas/obs-studio that referenced this issue Jul 7, 2021
The gs_draw_sprite_subregion() function is used when a cropping
rectangle is received from PipeWire. It is usually used by
compositors to implement window screencast - where a large and
mostly empty frame is sent, the window contents are only a small
part of it, and the crop rectangle tells us that.

Recently the wlroots implementation of portals started to use it
to implement cropping, and it exposed a bug in the PipeWire code
in OBS Studio. The gs_draw_sprite_subregion() function takes a
pair of floats representing position (x, y) and a pair of floats
representing size (width, height). The PipeWire code, however,
passes a second pair of positions (x2, y2) instead of sizes, and
it causes overrendering the crop area.

This bug wasn't hit yet because both GNOME and KDE implementations
always send (0, 0) as position, which practically never trigger
this condition.

Pass only width and height to gs_draw_sprite_subregion(), instead
of adding x and y to them.

Fixes obsproject#4982
GeorgesStavracas added a commit to GeorgesStavracas/obs-studio that referenced this issue Jul 7, 2021
The gs_draw_sprite_subregion() function is used when a cropping
rectangle is received from PipeWire. It is usually used by
compositors to implement window screencast - where a large and
mostly empty frame is sent, the window contents are only a small
part of it, and the crop rectangle tells us that.

Recently the wlroots implementation of portals started to use it
to implement cropping, and it exposed a bug in the PipeWire code
in OBS Studio. The gs_draw_sprite_subregion() function takes a pair
of integers representing position (x, y) and a pair of integers
representing size (width, height). The PipeWire code, however,
passes a second pair of positions (x2, y2) instead of sizes, and
it causes overrendering the crop area.

This bug wasn't hit yet because both GNOME and KDE implementations
always send (0, 0) as position, which practically never trigger
this condition.

Pass only width and height to gs_draw_sprite_subregion(), instead
of adding x and y to them.

Fixes obsproject#4982
@jp9000 jp9000 closed this as completed in ec3e814 Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linux Affects Linux
Projects
None yet
Development

No branches or pull requests

2 participants