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

Content captured by scrot -f -s differs from the content that is frozen on. #381

Open
xnoe opened this issue Jun 23, 2024 · 5 comments · May be fixed by #382
Open

Content captured by scrot -f -s differs from the content that is frozen on. #381

xnoe opened this issue Jun 23, 2024 · 5 comments · May be fixed by #382
Labels
bug Something isn't working

Comments

@xnoe
Copy link

xnoe commented Jun 23, 2024

Hello all,

After having upgraded my installation of scrot to version 1.11.1 earlier today, I found that when trying to screenshot content such as YouTube videos with scrot -f -s, when the screenshot is taken, the content of the screenshot differs from what was frozen on during selection.

Using git bisect I found that the commit that introduced this difference in behavior was 93e475d

Removing the lines from src/scrot_selection.c that were added with that commit restores scrot to its original behaviour even on latest version.

diff --git a/src/scrot_selection.c b/src/scrot_selection.c
index 9e00df0..76d973a 100644
--- a/src/scrot_selection.c
+++ b/src/scrot_selection.c
@@ -159,7 +159,6 @@ static void scrotSelectionDestroy(void)
      * have been updated. a compositor might also buffer frames adding
      * latency. so wait a bit for the screen to update and the selection
      * borders to go away. */
-    scrotSleepFor(clockNow(), 80);
 }

 static void scrotSelectionMotionDraw(int x0, int y0, int x1, int y1)

I am running Arch Linux with i3-gaps under X11 as my Window Manager, using picom as my compositor.

Is this an intentional change in behavior?

@N-R-K
Copy link
Collaborator

N-R-K commented Jun 24, 2024

Is this an intentional change in behavior?

No, not intentional.

Using git bisect I found that the commit that introduced this difference in behavior was 93e475d

Just realized that --freeze never actually worked on edge mode at all. E.g:

$ scrot -f -s --line 'mode=edge'   # doesn't freeze

The manpage doesn't say anything about --freeze being exclusive to classic mode so I'm assuming that's a bug too. (ping: @daltomi)

@N-R-K N-R-K added the bug Something isn't working label Jun 24, 2024
@N-R-K
Copy link
Collaborator

N-R-K commented Jun 24, 2024

Looking at it closer, it seems that the --freeze flag was always racy:

> grab server
> get selection
> ungrab server
> + newly added sleep
> capture screenshot

The sleep basically widened the race window and made it visible. The proper ordering should be to ungrab the server after the screenshot is captured, not before.

@N-R-K
Copy link
Collaborator

N-R-K commented Jun 24, 2024

The manpage doesn't say anything about --freeze being exclusive to classic mode so I'm assuming that's a bug too.

Okay, it seems that --freeze and --line mode=edge cannot work well together. The edge window draws over and damages the underlying windows, but since the server is grabbed, those underlying windows cannot repaint themselves.

This was without using any compositor, maybe using compositor it would work?

@N-R-K
Copy link
Collaborator

N-R-K commented Jun 24, 2024

@xnoe Try out the following commit and see if that fixes your issue. https://github.com/N-R-K/scrot/commit/c7e91b190b9d95d9b47380492d0609659b5a5779.patch

Also, since you're using a compositor, please try both of the following:

$ scrot -f -s --line 'mode=edge'
$ scrot -f -s --line 'mode=classic'

@xnoe
Copy link
Author

xnoe commented Jun 24, 2024

Hello,

I have just tested that commit and tried both of those commands, freezing and capturing work fine with both.

However, when I use the scrot -f -s --line 'mode=edge' on this commit, there is no longer a border of any sort around the selection when I have picom running. Killing picom makes the border appear around the selection again. Freezing/capturing acts the same regardless of whether or not picom is running or not for me.

N-R-K added a commit to N-R-K/scrot that referenced this issue Jun 24, 2024
this patch makes a couple different changes:

* previously the grab/ungrab was happening inside of
  selection_classic::{create,destroy}. this meant that
  `--freeze` was ineffective when edge mode was used.
  the patch moves those calls outside of it, so that `--freeze`
  can work on edge mode as well.
* because the grab/ungrab was happening inside selection
  destroy, there were multiple races. one of them was that the
  server would be ungrabbed after selection was done but
  *before* the shot was captured. the sleep introduced in commit
  93e475d widened the race window and made it more easily
  noticeable. the patch makes it so that we don't ungrab the
  server until the shot is actually taken.

Fixes: resurrecting-open-source-projects#381
@N-R-K N-R-K linked a pull request Jun 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants