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

[Linux, flatpak] Crash due to "Error code 2 received from xdg-portal" #555

Closed
quebexer opened this issue Nov 14, 2023 · 8 comments
Closed
Labels
bug Something isn't working

Comments

@quebexer
Copy link

What happened?

Whenever I click on the NormCap icon, it wont launch it.

I also tried launching it from the terminal but that didn't work either.

How did you install NormCap?

FlatPak (Linux)

Operating System + Version?

Fedora 39

[Linux only] Display Server (DS) + Desktop environment (DE)?

Gnome 45 / Wayland

Debug log output?*

latincanuck@fedora:~$ flatpak run --command=normcap com.github.dynobo.normcap -v debug
12:46:48 - INFO    - normcap:30 - Start NormCap v0.4.4
12:46:48 - DEBUG   - normcap:81 - Set XCURSOR_SIZE=24
12:46:48 - DEBUG   - normcap:86 - Set QT_QPA_PLATFORM=wayland
12:46:48 - DEBUG   - normcap.gui.tray:60 - System info:
{'cli_args': '/app/bin/normcap -v debug', 'is_briefcase_package': False, 'is_flatpak_package': True, 'platform': 'linux', 'pyside6_version': '6.5.1', 'qt_version': '6.5.1', 'qt_library_path': '/usr/share/runtime/lib/plugins, /app/lib/python3.10/site-packages/PySide6/Qt/plugins, /usr/bin', 'config_directory': PosixPath('/home/latincanuck/.var/app/com.github.dynobo.normcap/config/normcap'), 'normcap_version': '0.4.4', 'ressources_path': PosixPath('/app/lib/python3.10/site-packages/normcap/resources'), 'tesseract_path': PosixPath('/app/bin/tesseract'), 'tessdata_path': PosixPath('/home/latincanuck/.var/app/com.github.dynobo.normcap/config/normcap/tessdata'), 'envs': {'TESSDATA_PREFIX': '/app/share', 'LD_LIBRARY_PATH': ''}, 'desktop_environment': <DesktopEnvironment.GNOME: 1>, 'display_manager_is_wayland': True, 'screens': [Screen(is_primary=True, device_pixel_ratio=1.0, rect=Rect(left=0, top=590, right=1920, bottom=1670), index=0, screenshot=None), Screen(is_primary=False, device_pixel_ratio=1.0, rect=Rect(left=1920, top=0, right=3840, bottom=1080), index=1, screenshot=None), Screen(is_primary=False, device_pixel_ratio=1.0, rect=Rect(left=1920, top=1080, right=3840, bottom=2280), index=2, screenshot=None)]}
12:46:48 - DEBUG   - normcap.gui.tray:342 - Listen on local socket v0.4.4-normcap.
12:46:48 - DEBUG   - normcap.gui.settings:128 - Skip update of non existing setting (cli_mode: False)
12:46:48 - DEBUG   - normcap.gui.settings:128 - Skip update of non existing setting (background_mode: False)
12:46:48 - DEBUG   - normcap.screengrab:37 - Select capture method DBUS portal
12:46:48 - DEBUG   - normcap.screengrab.dbus_portal:196 - Request screenshot with interactive=False
12:46:48 - DEBUG   - normcap.screengrab.dbus_portal:79 - Request accepted
12:46:48 - ERROR   - normcap.screengrab.dbus_portal:103 - Error code 2 received from xdg-portal!
12:46:48 - DEBUG   - normcap.screengrab.dbus_portal:106 - Parse response
Traceback (most recent call last):
  File "/app/lib/python3.10/site-packages/normcap/screengrab/dbus_portal.py", line 107, in got_signal
    uri = str(message).split('[Variant(QString): "')[1]
IndexError: list index out of range
Traceback (most recent call last):
  File "/app/bin/normcap", line 8, in <module>
    sys.exit(main())
  File "/app/lib/python3.10/site-packages/normcap/app.py", line 57, in main
    tray = SystemTray(app, vars(args))
  File "/app/lib/python3.10/site-packages/normcap/gui/tray.py", line 100, in __init__
    self._update_screenshots(delayed=False)
  File "/app/lib/python3.10/site-packages/normcap/gui/tray.py", line 425, in _update_screenshots
    screens = capture()
  File "/app/lib/python3.10/site-packages/normcap/screengrab/dbus_portal.py", line 197, in capture
    result = _synchronized_capture(interactive=False)
  File "/app/lib/python3.10/site-packages/normcap/screengrab/dbus_portal.py", line 152, in _synchronized_capture
    raise error
normcap.screengrab.ScreenshotResponseError: Error code 2 received from xdg-portal!
@quebexer quebexer added bug Something isn't working triage Needs confirmation and priotization labels Nov 14, 2023
@jasiralavi
Copy link

Same here on new install of Ubuntu 23.10 / gnome45 / wayland.
See output below.

Appimage is working without issues, but cannot add additional languages with that. Getting download error.

/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=normcap com.github.dynobo.normcap
10:36:26 - ERROR   - normcap.screengrab.dbus_portal:103 - Error code 2 received from xdg-portal!
10:36:26 - CRITICAL - normcap:161 - Uncaught exception! Quitting NormCap!

System:

{  'cli_args': '/app/bin/normcap',
   'config_directory': PosixPath('/home/REDACTED/.var/app/com.github.dynobo.normcap/config/normcap'),
   'desktop_environment': <DesktopEnvironment.GNOME: 1>,
   'display_manager_is_wayland': True,
   'envs': {'LD_LIBRARY_PATH': '', 'TESSDATA_PREFIX': '/app/share'},
   'is_briefcase_package': False,
   'is_flatpak_package': True,
   'normcap_version': '0.4.4',
   'platform': 'linux',
   'pyside6_version': '6.5.1',
   'qt_library_path': '/usr/share/runtime/lib/plugins, '
                      '/app/lib/python3.10/site-packages/PySide6/Qt/plugins, '
                      '/usr/bin',
   'qt_version': '6.5.1',
   'ressources_path': PosixPath('/app/lib/python3.10/site-packages/normcap/resources'),
   'screens': [  Screen(is_primary=True,
                        device_pixel_ratio=1.0,
                        rect=Rect(left=0, top=0, right=1920, bottom=1080),
                        index=0,
                        screenshot=None)],
   'tessdata_path': PosixPath('/home/REDACTED/.var/app/com.github.dynobo.normcap/config/normcap/tessdata'),
   'tesseract_path': PosixPath('/app/bin/tesseract')}

Variables:

                    'code': 2,
                    'message': <PySide6.QtDBus.QDBusMessage(type=Signal, service=":1.85", path="/org/freedesktop/portal/desktop/request/1_457/normcap_hbcigbif", interface="org.freedesktop.portal.Request", member="Response", signature="ua{sv}", contents=(2, [Argument: a{sv} {}]) ) at 0x7f07010f3f80>,
                    'msg': 'Error code 2 received from xdg-portal!',
                    'self': 'REDACTED'}}

Exception:

  IndexError: list index out of range

Traceback:

  File "/app/lib/python3.10/site-packages/normcap/screengrab/dbus_portal.py", line 107, in got_signal
    uri = str(message).split('[Variant(QString): "')[1]

10:36:26 - CRITICAL - normcap:192 - Please open an issue with the output above on https://github.com/dynobo/normcap/issues

@quebexer
Copy link
Author

@jasiralavi thanks for the tip. I will install the AppImage version.

@dynobo
Copy link
Owner

dynobo commented Dec 1, 2023

Yeah, unfortunately (screenshot) permission management on Wayland is quite broken and constant subject of change. Many 3rd party screenshot tools are suffering from that.

The upcoming NormCap 0.5.0 includes some workarounds to mitigate this issue, but until Wayland, or more precisely, the underlying xdg-desktop-portal protocol, which Wayland implements, gets improved, those workarounds are just tiny band-aids...

Related issues are:

@dynobo
Copy link
Owner

dynobo commented Dec 1, 2023

Appimage is working without issues, but cannot add additional languages with that. Getting download error.

@jasiralavi, would you mind opening a new issue for that download issue, and attach a corresponding debug log? I think a language download error is not on my radar, yet.
(And if I see it correctly, the debug log you shared here is also about the screenshot error, not the download error?)

@dynobo dynobo added wayland and removed triage Needs confirmation and priotization labels Dec 1, 2023
@jasiralavi
Copy link

@jasiralavi, would you mind opening a new issue for that download issue, and attach a corresponding debug log? I think a language download error is not on my radar, yet. (And if I see it correctly, the debug log you shared here is also about the screenshot error, not the download error?)

Sure. Done that here #562

@dynobo dynobo changed the title NormCap won't open [Linux] Crash due to "Error code 2 received from xdg-portal" Dec 2, 2023
@dynobo dynobo changed the title [Linux] Crash due to "Error code 2 received from xdg-portal" [Linux, flatpak] Crash due to "Error code 2 received from xdg-portal" Dec 2, 2023
@dynobo dynobo removed the wayland label Dec 3, 2023
@dynobo
Copy link
Owner

dynobo commented Dec 17, 2023

This problem should be mitigated with the latest release. Could you please confirm?

@jasiralavi
Copy link

I installed the flatpak through the gnome Software app.
There was a pop saying I'll need to give permission to manage screenshots, after clicking Ok.
However, I didn't see a second popup /window for that. It went straight to the 'how to use' startup window.

Anyways, it's working ok now.
The language download is working ok as well.
Thank you once again for the great app!

Here are the screenshots of the two windows, just in case anyone's curious.

image

image

@dynobo
Copy link
Owner

dynobo commented Dec 22, 2023

Thanks for the info, @jasiralavi. Interesting, that you didn't see the second confirmation dialog, but I'm glad that it still worked. I also noticed in the past, that the behavior depends a lot on the versions of the desktop environment etc.

Let's hope that the underlying upstream issue in xdg-desktop-portal protocol gets fixed at some point, so we can get rid of this fragile workarounds. Progress on that front is tracked in #320.

I am closing this issue, please re-open it or create a new one if the problem occurs again.

@dynobo dynobo closed this as completed Dec 22, 2023
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

No branches or pull requests

3 participants