After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 682626 - Area Screenshot fails with "Unable to capture a screenshot"
Area Screenshot fails with "Unable to capture a screenshot"
Status: RESOLVED OBSOLETE
Product: gnome-screenshot
Classification: Core
Component: general
3.4.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-screenshot-maint
gnome-screenshot-maint
Depends on:
Blocks:
 
 
Reported: 2012-08-24 17:29 UTC by Matt Reid
Modified: 2020-11-26 15:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Error Message (9.22 KB, image/png)
2012-08-24 17:29 UTC, Matt Reid
  Details
gnome-screenshot_arearapidclick.patch (467 bytes, patch)
2013-10-14 16:13 UTC, manuel.BACHMANN@eurogiciel.fr
none Details | Review

Description Matt Reid 2012-08-24 17:29:14 UTC
Created attachment 222353 [details]
Error Message

Recently when trying to capture area selection screenshots using gnome-screenshot in 64 bit Fedora 17, I get intermittent failures, with a message of "Unable to capture a screenshot" "All possible methods failed". Instead of giving me a cursor to make my area selection, both of my monitors flash, as it tried to take a screenshot, and then it displays that error message. It seems like it will always fail once I get that first failure until I change my active windows and try again.

I have two monitors, one being my Lenovo T520 in a dock, and an external hooked up to the dock via DVI, both are 1080p displays (if any of that matters). I preupgraded from F16 to F17, but I only noticed this happening a few weeks ago, and I upgraded earlier than that.

Package Info:
gnome-screenshot-3.4.1-2.fc17.x86_64
Comment 1 Ewan.LEBIDEAU-CANEVET 2013-06-06 09:18:15 UTC
Reproduced on Fedora Beta 19 with file File-Roller 3.8.2
Comment 2 Ewan.LEBIDEAU-CANEVET 2013-06-06 09:30:06 UTC
Sorry mistake on comment : 

reproduced on Fedora beta 19 with gnome-screenshot 3.8.2
Comment 3 manuel.BACHMANN@eurogiciel.fr 2013-10-14 16:13:44 UTC
Created attachment 257274 [details] [review]
gnome-screenshot_arearapidclick.patch

Problem is due to a case where the GdkRectangle struct isn't null ; however due to the rapid click, widht-height are 0, hence the bug.

Please consider the attached patch, which corrects this behavior.

At worst, gnome-screenshot will now fall back to "capture the whole screen".
Comment 4 Margarita Manterola 2017-06-13 13:43:53 UTC
I don't think the above mentioned patch is the right thing to do, as it means that the behavior is to take the full screenshot instead of showing the crosshairs.

What should happen is that if the rectangle is empty, it should wait with the crosshairs.

I want to point out that while this bug has sat idle for 4 years, there's been plenty of reports of this in other places:

https://github.com/linuxmint/Cinnamon/issues/3981
https://github.com/mate-desktop/mate-utils/issues/37
https://unix.stackexchange.com/questions/344319/run-gnome-screenshot-a-with-cinnamon-keyboard-shortcut

i.e. it's 2017 and anything that uses gnome-screenshot still has this issue where pressing Shift+PrtScn for a few extra milliseconds leads to gnome-screenshot -a not working.
Comment 5 Margarita Manterola 2017-06-13 13:59:40 UTC
I suspect that this is not an issue in GNOME proper, because the screenshot uses the internal screenshot capabilities and it's only a problem on other Desktop Environments that try to use gnome-screenshot command. In that case, the application falls back to using the X11 screen grabbing and that's the one that fails.

It seems to me that the issue might be here:
https://github.com/GNOME/gnome-screenshot/blob/master/src/screenshot-area-selection.c#L266

The code is trying to grab the keyboard and if it can't do that, it just dies.  No retries of any kind.

My suspicion is that if the PrtScn key is pressed while the program is starting, it can't grab the keyboard and thus it fails. A possible fix would be to retry grabbing the keyboard until a timeout is reached.
Comment 6 Cosimo Cecchi 2017-06-13 18:55:28 UTC
(In reply to Margarita Manterola from comment #5)
> I suspect that this is not an issue in GNOME proper, because the screenshot
> uses the internal screenshot capabilities and it's only a problem on other
> Desktop Environments that try to use gnome-screenshot command. In that case,
> the application falls back to using the X11 screen grabbing and that's the
> one that fails.
> 
> It seems to me that the issue might be here:
> https://github.com/GNOME/gnome-screenshot/blob/master/src/screenshot-area-
> selection.c#L266
> 
> The code is trying to grab the keyboard and if it can't do that, it just
> dies.  No retries of any kind.
> 
> My suspicion is that if the PrtScn key is pressed while the program is
> starting, it can't grab the keyboard and thus it fails. A possible fix would
> be to retry grabbing the keyboard until a timeout is reached.

Thanks for looking into this -- it sounds like a plausible explanation for this issue. I would accept a patch that adds a retry in case gdk_device_grab() indicates that another grab is already in effect.
Comment 7 Emmanuele Bassi (:ebassi) 2020-11-26 15:45:55 UTC
Patch failed to materialise in 3 years, and to be honest other desktop environments should not expect gnome-screenshot to work for them; it's the *GNOME* screenshot tool, not "generic X11 screenshot tool". The X11 fallback code path is there mostly for legacy reasons, and it's not meant to exist forever.

If somebody wishes to write a patch, they are absolutely free to open a merge request:

https://gitlab.gnome.org/GNOME/gnome-screenshot/