shutter-project / shutter

Screenshot tool for Linux
https://shutter-project.org/
GNU General Public License v3.0
503 stars 34 forks source link

Screenshot takes 2-3 seconds to make on Ubuntu #549

Open amcsi opened 1 year ago

amcsi commented 1 year ago

Brief summary of issue

It takes 2-3 seconds to make a screenshot with Shutter. This is a problem, because I often attempt to make a screenshot, then alt-tab to somewhere else, and then later realize that what I made a screenshot of was what I alt-tabbed into.

See lower down for a video.

Steps to reproduce the issue

  1. Run shutter --full --delay=0 -e -o ~/Pictures/Screenshot_%Y-%m-%d_%H_%M_%S.png
  2. Observe how long it takes to make the screenshot
  3. Rather than the screenshot being nearly instantaneous, it takes 2-3 seconds.

Error output

Extra information, such as Shutter version, display server in use (Xorg or Wayland), operating system and ideas for how to solve:

0.99.2 Rev.1593 Ubuntu 22.04.2 LTS Display Server: x11

Ideas: with all this unsolicited debug information I got, perhaps the PPA leads me to some heavily unoptimized debug build of the application?

Video: https://user-images.githubusercontent.com/116494/220852726-a08accb3-51a5-44b0-b029-b688cd238efc.mp4

File: https://gist.github.com/amcsi/1312272217e68857314d576105ca005a

vadi2 commented 1 year ago

What resolution are you running?

amcsi commented 1 year ago

I have 2x 1080p monitors.

Photon89 commented 1 year ago

Shutter takes some seconds to load indeed. Also, the debug output is expected, see https://github.com/shutter-project/shutter/issues/338 But once Shutter has started and is sitting in the tray, taking screenshots should be fast, both from CLI and from GUI.

amcsi commented 1 year ago

I was hoping the issue was as simple to fix as that, but I tried, and not quite.

First of all, yes I can start shutter by itself, and it brings up a window, adds itself to the try, and stays open.

Then when I run the command to make a screenshot (not using the GUI), it takes a screenshot in 1 second. Still not instantaneous, but a better than 2-3 seconds. As a reminder: the delays are bad, because I can alt-tab away from the windows I wanted to make screenshots of, taking a screenshot of the thing I alt-tabbed into instead by mistake.

Then as soon as the screenshot is made, shutter that's on the tray exists. And from then on it's back to 2-3 second screenshots.

Photon89 commented 1 year ago

Then as soon as the screenshot is made, shutter that's on the tray exists.

That shouldn't happen. Could you please

  1. Run shutter from CLI.
  2. Run shutter -f while Shutter is sitting in the tray in a different terminal window.
  3. If Shutter exists and is not present in the tray any more, post the additional output from your shutter command in step 1 which has been shown after step 2.
amcsi commented 1 year ago

@Photon89 shutter -f did not exist shutter. I realized that it's because it didn't have -e in the command like mine. After removing -e from my command, it also stopped existing shutter in the try.

That being said, I still saved the outputs: https://gist.github.com/amcsi/05ea58ed8e0490bf3a9ddce1cc54cfa8

So the situation is much better. Though there's still a ~1 second delay when making a screenshot from CLI even still. It would be really awesome if something could be done with that delay too.

It appears that when making a screenshot through the GUI, the delay is even less ~500ms, which is pretty good already, but I can't achieve that using the CLI which I bound to global hotkeys.

Photon89 commented 1 year ago

I think, that's because Shutter starts loading stuff when executed from CLI and only after half a second notices that an instance is already running and then connects to it. Maybe the check for an existing instance could be placed earlier in the launching routine? @DarthGandalf, any thoughts?

DarthGandalf commented 1 year ago

Potentially this time could be decreased, but I don't know how much: CLI definitely loads too much stuff it won't use, but I can't remove some of it without breaking GUI (because of how Perl works with GLib). Likely rewriting shutter on Rust or whatever will yield more performance improvement.