flameshot-org / flameshot

Powerful yet simple to use screenshot software :desktop_computer: :camera_flash:
https://flameshot.org
GNU General Public License v3.0
24.22k stars 1.55k forks source link

Flameshot runs without any response and GUI #3363

Closed untainsYD closed 9 months ago

untainsYD commented 9 months ago

Flameshot Version

> pacman -Q --info flameshot
Name            : flameshot
Version         : 12.1.0-3
Description     : Powerful yet simple to use screenshot software
Architecture    : x86_64
URL             : https://github.com/flameshot-org/flameshot
Licenses        : GPL
Groups          : None
Provides        : None
Depends On      : qt5-svg  hicolor-icon-theme  kguiaddons5
Optional Deps   : gnome-shell-extension-appindicator: for system tray icon if you are using Gnome
                  grim: for wlroots wayland support [installed]
                  xdg-desktop-portal: for wayland support, you will need the implementation for your wayland desktop environment [installed]
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 2.80 MiB
Packager        : Antonio Rojas <arojas@archlinux.org>
Build Date      : Sun 01 Oct 2023 10:22:14 AM EEST
Install Date    : Thu 05 Oct 2023 05:19:37 PM EEST
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

Installation Type

Linux, pacman package flameshot

Operating System type and version

Linux 6.5.5-arch1-1

Description

Previously, Flameshot worked flawlessly without any issues, but now I'm encountering an unusual problem. The graphical user interface (GUI) for selecting the capture area doesn't appear, although I can see Flameshot processes running when checking with 'htop'. When I attempt to run it from the command line (CLI), nothing seems to happen. The exit status code returned is 0, indicating success.

> flameshot gui | echo $?
0

For instance, when running:

> flameshot full -p ~/screenshot.png

Flameshot seems to hang without providing any response.

I've checked the system journal and found no error messages related to Flameshot. The only warning I've come across in dmesg is as follows:

> sudo dmesg | grep flameshot
[sudo] password for untainsYD:
[   29.372392] warning: `flameshot' uses wireless extensions which will stop working for Wi-Fi 7 hardware; use nl80211

XDG portals are running without any errors.

When i am trying to install flameshot-git from aur, i have error described flameshot-git#comment-936871.

Steps to reproduce

run flameshot gui command

Screenshots or screen recordings

No response

System Information

Wayland, Sway, with xdg-desktop portal installed, dbus activated, and all environment variables like DESKTOP, etc. are set.

Dnnd commented 9 months ago

I have the same environment (Archlinux, sway 1.8.1, flameshot 12.1.0-3) and facing the same problem.

I haven't figure out the root cause, but downgrading xdg-desktop-portal from 1.18.0-2 to 1.16.0-3 solved the issue for me.

UPD. I suspect that flameshot gui hangs here: https://github.com/flameshot-org/flameshot/blob/70be63d478a271da549597d69bd4868607c0a395/src/utils/screengrabber.cpp#L75

I've tried monitoring dbus messages and with xdg-desktop-portal 1.18.0-2 flameshot never gets a response from the call to org.freedesktop.portal.Desktop :

>> dbus-monitor "interface='org.freedesktop.portal.Screenshot'" "interface=org.freedesktop.portal.Request"

   string ":1.116"
method call time=1696524514.942752 sender=:1.117 -> destination=org.freedesktop.portal.Desktop serial=16 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.Screenshot; member=Screenshot
   string ""
   array [
      dict entry(
         string "handle_token"
         variant             string "48adc54824e9457ebcd62f970aa9e7da"
      )
      dict entry(
         string "interactive"
         variant             boolean false
      )
   ]

with xdg-desktop-portal 0.16.0-3 everything seems fine:

>>  dbus-monitor "interface='org.freedesktop.portal.Screenshot'" "interface=org.freedesktop.portal.Request"

method call time=1696524436.538271 sender=:1.108 -> destination=org.freedesktop.portal.Desktop serial=16 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.Screenshot; member=Screenshot
   string ""
   array [
      dict entry(
         string "handle_token"
         variant             string "651eb3ac218d4ac48b767c4cd61d2824"
      )
      dict entry(
         string "interactive"
         variant             boolean false
      )
   ]
signal time=1696524436.646919 sender=:1.96 -> destination=:1.108 serial=212 path=/org/freedesktop/portal/desktop/request/1_108/651eb3ac218d4ac48b767c4cd61d2824; interface=org.freedesktop.portal.Request; member=Response
   uint32 0
   array [
      dict entry(
         string "uri"
         variant             string "file:///tmp/out.png"
      )
   ]
method call time=1696524436.675529 sender=:1.108 -> destination=org.freedesktop.portal.Desktop serial=17 path=/org/freedesktop/portal/desktop/request/1_108/651eb3ac218d4ac48b767c4cd61d2824; interface=org.freedesktop.portal.Request; member=Close

I suspect that's a bug in xdg-desktop-portal or xdg-desktop-portal-wlr , but on flameshot side it probably make sense to have a timeout on DBus RPC ?...

untainsYD commented 9 months ago

Thank you for answer, i have installed flameshot-git from aur, and it works, the build error gone (idk how, it's a magic), but there with git version of flameshot i have this error/warning:

> XDG_CURRENT_DESKTOP=Sway flameshot gui
flameshot: warning: grim's screenshot component is implemented based on wlroots, it may not be used in GNOME or similar desktop environments
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
flameshot: info: Screenshot aborted.
Dnnd commented 9 months ago

I think that flameshot-git from AUR enables an option to use grim instead of xdg-dekstop-portal for screenshots on Wayland: -DUSE_WAYLAND_GRIM=true is set in flameshot-git PKGBUILD, but PKGBUILD from the main repo is compiled without it. I guess, that's also an option to mitigate the issue.

untainsYD commented 9 months ago

@Dnnd maybe we should reference this issue in xdg-desktop-portal repo? And how about xdg-desktop-portal-wlr? Did you also downgrade it?

Dnnd commented 9 months ago

And how about xdg-desktop-portal-wlr? Did you also downgrade it?

I didn't.

@Dnnd maybe we should reference this issue in xdg-desktop-portal repo?

I skimmed through the issues in xdg-desktop-portal repo and found a proper solution without downgrading anything - https://github.com/flatpak/xdg-desktop-portal/issues/1077#issuecomment-1715896552:

Starting from 0.17.0 xdg-desktop-portal requires a configuration file (e.g. in config/xdg-desktop-portal/sway-portals.conf):

[preferred]
# use xdg-desktop-portal-gtk for every portal interface
default=gtk
# except for the xdg-desktop-portal-wlr supplied interfaces
org.freedesktop.impl.portal.Screencast=wlr
org.freedesktop.impl.portal.Screenshot=wlr

Seems like it's not a bug, just a misconfiguration.

untainsYD commented 9 months ago

Seems like it's not a bug, just a misconfiguration.

Oh, thank you for the solution, I didn't know.

alxndr13 commented 9 months ago

i am also having an issue which mostly looks the one you guys described here.

Running wayland & sway.

 yay -Q flameshot                                  
flameshot 12.1.0-3

When running flameshot gui the program instantly errors and there's no message in the dbus monitor:

~ ❯ flameshot gui; echo $?
1

Running flameshot full -p ~/screenshot.png though, makes flameshot hang and I see a dbus message:

method call time=1696764116.848573 sender=:1.100 -> destination=org.freedesktop.portal.Desktop serial=16 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.Screenshot; member=Screenshot
   string ""
   array [
      dict entry(
         string "handle_token"
         variant             string "d9760b87159649c2852976babf91fa93"
      )
      dict entry(
         string "interactive"
         variant             boolean false
      )
   ]

I added the xdg config file as @Dnnd described, did not change a thing. Screensharing works, so i'm sure my portal is properly configured and running.

Update: Downgrading xdg-desktop-portal to 1.14.6 makes flameshot work again. I had xdg-desktop-portal in my ignored packages, now I remember why 😂

I'll go back to my grim / slurp and swappy stack.

altger commented 9 months ago

Starting from 0.17.0 xdg-desktop-portal requires a configuration file (e.g. in config/xdg-desktop-portal/sway-portals.conf):

[preferred]
# use xdg-desktop-portal-gtk for every portal interface
default=gtk
# except for the xdg-desktop-portal-wlr supplied interfaces
org.freedesktop.impl.portal.Screencast=wlr
org.freedesktop.impl.portal.Screenshot=wlr

Seems like it's not a bug, just a misconfiguration.

This one worked for me (requires sway restart). Thanks!

untainsYD commented 9 months ago

@Dnnd I have tested it recently, and it really works, thank you!

I skimmed through the issues in xdg-desktop-portal repo and found a proper solution without downgrading anything - flatpak/xdg-desktop-portal#1077 (comment):

Starting from 0.17.0 xdg-desktop-portal requires a configuration file (e.g. in config/xdg-desktop-portal/sway-portals.conf):

[preferred]
# use xdg-desktop-portal-gtk for every portal interface
default=gtk
# except for the xdg-desktop-portal-wlr supplied interfaces
org.freedesktop.impl.portal.Screencast=wlr
org.freedesktop.impl.portal.Screenshot=wlr

Seems like it's not a bug, just a misconfiguration.

davendu commented 1 month ago

Starting from 0.17.0 xdg-desktop-portal requires a configuration file (e.g. in config/xdg-desktop-portal/sway-portals.conf):

[preferred]
# use xdg-desktop-portal-gtk for every portal interface
default=gtk
...

@Dnnd Hi. I'm not familiar with xdg-desktop-portal* but since the default is set to gtk, does it mean xdg-desktop-portal-gtk should also be installed along with xdg-desktop-portal and xdg-desktop-portal-wlr?

Oh seems I know why. According to the source code of xdg-desktop-portal:

https://github.com/flatpak/xdg-desktop-portal/blob/11c8a96b147aeae70e3f770313f93b367d53fedd/src/xdg-desktop-portal.c#L303-L322

The screenshot service org.freedesktop.impl.portal.Screenshot is only exported if org.freedesktop.impl.portal.Access, but xdg-desktop-portal-wlr does not provides org.freedesktop.impl.portal.Access. So unless another program provides it, the screenshot is actually not exported to the DBus. Thus screenshot is impossible.