StreamController icon indicating copy to clipboard operation
StreamController copied to clipboard

BUG: "ValueError: Namespace Xdp not available" when built from source and run via flatpak

Open kawaiishay opened this issue 8 months ago • 17 comments

Describe the bug When StreamController is built from source and run:

>>> flatpak run com.core447.StreamController
Traceback (most recent call last):
  File "/app/bin/StreamController/main.py", line 39, in <module>
    from src.app import App
  File "/app/bin/StreamController/src/app.py", line 24, in <module>
    from src.windows.Store.ResponsibleNotesDialog import ResponsibleNotesDialog
  File "/app/bin/StreamController/src/windows/Store/ResponsibleNotesDialog.py", line 20, in <module>
    import globals as gl
  File "/app/bin/StreamController/globals.py", line 9, in <module>
    from src.backend.DeckManagement.HelperMethods import find_fallback_font
  File "/app/bin/StreamController/src/backend/DeckManagement/HelperMethods.py", line 36, in <module>
    from autostart import is_flatpak
  File "/app/bin/StreamController/autostart.py", line 21, in <module>
    gi.require_version("Xdp", "1.0")
  File "/usr/lib/python3.12/site-packages/gi/__init__.py", line 122, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Xdp not available

I have the dependencies installed:

>>> sudo apt install xdg-desktop-portal xdg-desktop-portal-gtk libportal-dev libportal-gtk4-1
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
xdg-desktop-portal is already the newest version (1.18.4-1ubuntu2.24.04.1).
xdg-desktop-portal-gtk is already the newest version (1.15.1-1build2).
libportal-dev is already the newest version (0.7.1-5build5).
libportal-dev set to manually installed.
libportal-gtk4-1 is already the newest version (0.7.1-5build5).
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.

To Reproduce Steps to reproduce the behavior:

  1. build from source
  2. run via flatpak

Expected behavior App opens and runs

Screenshots Looks like the libraries for Xdp need to be in the manifest for flatpak? [https://mamot.fr/@krafting/113950708043499060] Image

Same as https://github.com/StreamController/StreamController/issues/120 when building from source

kawaiishay avatar Apr 01 '25 18:04 kawaiishay

Modifying the com.core447.StreamController.yml file for libportal to:

  - name: libportal
    buildsystem: meson
    config-opts:
      - --libdir=/app/lib
      - -Dbackend-gtk3=disabled
      - -Dbackend-gtk4=enabled
      - -Dbackend-qt5=disabled
      - -Ddocs=false
      - -Dtests=false
      - -Dvapi=false
    sources:
      - type: git
        url: https://github.com/flatpak/libportal.git
        tag: 0.9.1

Got me passed this issue, but looks like the commit https://github.com/StreamController/StreamController/commit/c0387296416576709fc87ef3d2f833e951a966b7 (on main) breaks support for x11 users:

Image

I don't use wayland at all. purely x11 on kde-plasma/ubuntu

kawaiishay avatar Apr 01 '25 18:04 kawaiishay

wrapping the import in main.py addressed the second issue:

try:
    from src.backend.Wayland.Wayland import Wayland
except ImportError:
    pass

kawaiishay avatar Apr 01 '25 18:04 kawaiishay

newwww error:

Image

full log:

flatpak run com.core447.StreamController
2025-04-01 14:51:11.032 | WARNING  | __main__:main:286 - Should you get an Error 71 (Protocol error) please add GSK_RENDERER=ngl to your "/etc/environment" file
2025-04-01 14:51:11.032 | INFO     | __main__:quit_running:223 - Checking if another instance is running
2025-04-01 14:51:11.036 | INFO     | __main__:quit_running:231 - No other instance running, continuing
2025-04-01 14:51:11.036 | ERROR    | __main__:quit_running:232 - org.freedesktop.DBus.Error.ServiceUnknown: The name com.core447.StreamController was not provided by any .service files
2025-04-01 14:51:11.291 | ERROR    | src.backend.GnomeExtensions:connect_dbus:31 - Failed to connect to D-Bus: org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Shell was not provided by any .service files
2025-04-01 14:51:11.293 | INFO     | src.backend.PageManagement.PageManagerBackend:update_auto_change_info:333 - Updated auto-change info in 0.0002834796905517578 seconds
2025-04-01 14:51:11.293 | INFO     | src.backend.PageManagement.PageManagerBackend:remove_old_backups:448 - Removed old page backups: 2025-03-26T10:27:49.529028
2025-04-01 14:51:12.128 | INFO     | src.backend.WindowGrabber.WindowGrabber:init_integration:64 - Initializing window grabber for environment: kde under server: x11
2025-04-01 14:51:12.225 | INFO     | __main__:load:119 - Loading app
2025-04-01 14:51:12.225 | INFO     | __main__:update_assets:183 - Updating store assets
2025-04-01 14:51:12.268 | INFO     | src.backend.DeckManagement.DeckManager:__init__:67 - Running under Flatpak. Using separate thread to detect device disconnection.
2025-04-01 14:51:12.269 | INFO     | src.backend.DeckManagement.DeckManager:__init__:71 - Beta resume mode: False
2025-04-01 14:51:12.302 | ERROR    | src.backend.DeckManagement.DeckManager:load_hardware_decks:90 - Failed to open deck. Maybe it's already connected to another instance?

(process:3): Gtk-WARNING **: 14:51:12.304: Theme parser error: style.css:397:19-27: Unknown name of pseudo-class
2025-04-01 14:51:12.356 | TRACE    | src.app:on_activate:80 - running: on_activate
2025-04-01 14:51:12.357 | TRACE    | src.windows.mainWindow.mainWindow:build:93 - Building main window
2025-04-01 14:51:12.449 | INFO     | src.backend.Store.StoreBackend:get_stores:74 - Official store branch: main
2025-04-01 14:51:12.574 | ERROR    | src.windows.mainWindow.mainWindow:build:157 - An error has been caught in function 'build', process 'MainProcess' (3), thread 'MainThread' (137765492143936):
Traceback (most recent call last):

  File "/app/bin/StreamController/main.py", line 315, in <module>
    main()
    └ <function main at 0x7d4bb574ea20>

  File "/app/bin/StreamController/main.py", line 312, in main
    load()
    └ <function load at 0x7d4bb574d940>

  File "/app/bin/StreamController/main.py", line 122, in load
    gl.main = Main(application_id="com.core447.StreamController", deck_manager=gl.deck_manager)
    │         │                                                                │  └ <src.backend.DeckManagement.DeckManager.DeckManager object at 0x7d4b9e603d40>
    │         │                                                                └ <module 'globals' from '/app/bin/StreamController/globals.py'>
    │         └ <class '__main__.Main'>
    └ <module 'globals' from '/app/bin/StreamController/globals.py'>

  File "/app/bin/StreamController/main.py", line 115, in __init__
    self.app.run(gl.argparser.parse_args().app_args)
    │    │   │   │  │         └ <function ArgumentParser.parse_args at 0x7d4c005f7740>
    │    │   │   │  └ ArgumentParser(prog='main.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handl...
    │    │   │   └ <module 'globals' from '/app/bin/StreamController/globals.py'>
    │    │   └ <function Application.run at 0x7d4c0532bd80>
    │    └ <app.App object at 0x7d4bb0356780 (src+app+App at 0x6137a81ec500)>
    └ <__main__.Main object at 0x7d4b9e7429f0>

  File "/usr/lib/python3.12/site-packages/gi/overrides/Gio.py", line 42, in run
    return Gio.Application.run(self, *args, **kwargs)
           │   │           │   │      │       └ {}
           │   │           │   │      └ ([],)
           │   │           │   └ <app.App object at 0x7d4bb0356780 (src+app+App at 0x6137a81ec500)>
           │   │           └ gi.FunctionInfo(run, bound=None)
           │   └ <class 'gi.repository.Gio.Application'>
           └ <IntrospectionModule 'Gio' from '/usr/lib/x86_64-linux-gnu/girepository-1.0/Gio-2.0.typelib'>

  File "/app/bin/StreamController/src/app.py", line 81, in on_activate
    self.main_win = MainWindow(application=app, deck_manager=self.deck_manager)
    │    │          │                      │                 │    └ <src.backend.DeckManagement.DeckManager.DeckManager object at 0x7d4b9e603d40>
    │    │          │                      │                 └ <app.App object at 0x7d4bb0356780 (src+app+App at 0x6137a81ec500)>
    │    │          │                      └ <app.App object at 0x7d4bb0356780 (src+app+App at 0x6137a81ec500)>
    │    │          └ <class 'src.windows.mainWindow.mainWindow.MainWindow'>
    │    └ <mainWindow.MainWindow object at 0x7d4b9e662e00 (src+windows+mainWindow+mainWindow+MainWindow at 0x6137a82bd5b0)>
    └ <app.App object at 0x7d4bb0356780 (src+app+App at 0x6137a81ec500)>

  File "/app/bin/StreamController/src/windows/mainWindow/mainWindow.py", line 59, in __init__
    self.build()
    │    └ <function MainWindow.build at 0x7d4bb8138860>
    └ <mainWindow.MainWindow object at 0x7d4b9e662e00 (src+windows+mainWindow+mainWindow+MainWindow at 0x6137a82bd5b0)>

> File "/app/bin/StreamController/src/windows/mainWindow/mainWindow.py", line 157, in build
    gl.tray_icon.initialize(self)
    │  │         │          └ <mainWindow.MainWindow object at 0x7d4b9e662e00 (src+windows+mainWindow+mainWindow+MainWindow at 0x6137a82bd5b0)>
    │  │         └ <function TrayIcon.initialize at 0x7d4bb5729ee0>
    │  └ <src.tray.TrayIcon object at 0x7d4bb57334a0>
    └ <module 'globals' from '/app/bin/StreamController/globals.py'>

  File "/app/bin/StreamController/src/tray.py", line 41, in initialize
    self.register()
    │    └ <function DBusTrayIcon.register at 0x7d4bb5729bc0>
    └ <src.tray.TrayIcon object at 0x7d4bb57334a0>

  File "/app/bin/StreamController/src/backend/trayicon.py", line 428, in register
    self.sni_service.register()
    │    │           └ <function StatusNotifierItemService.register at 0x7d4bb57294e0>
    │    └ <src.backend.trayicon.StatusNotifierItemService object at 0x7d4bb5733860>
    └ <src.tray.TrayIcon object at 0x7d4bb57334a0>

  File "/app/bin/StreamController/src/backend/trayicon.py", line 361, in register
    watcher.RegisterStatusNotifierItem('(s)', self.dbus_path)
    │                                         │    └ '/com/core447/StreamController/Menu'
    │                                         └ <src.backend.trayicon.StatusNotifierItemService object at 0x7d4bb5733860>
    └ <Gio.DBusProxy object at 0x7d4b9e6ae700 (GDBusProxy at 0x6137a96109b0)>

  File "/usr/lib/python3.12/site-packages/gi/overrides/Gio.py", line 374, in __call__
    result = self.dbus_proxy.call_sync(self.method_name, arg_variant,
             │    │          │         │    │            └ GLib.Variant('(s)', ('/com/core447/StreamController/Menu',))
             │    │          │         │    └ 'RegisterStatusNotifierItem'
             │    │          │         └ <gi.overrides.Gio._DBusProxyMethodCall object at 0x7d4b9e61e5a0>
             │    │          └ gi.FunctionInfo(call_sync, bound=None)
             │    └ <Gio.DBusProxy object at 0x7d4b9e6ae700 (GDBusProxy at 0x6137a96109b0)>
             └ <gi.overrides.Gio._DBusProxyMethodCall object at 0x7d4b9e61e5a0>

gi.repository.GLib.GError: g-dbus-error-quark: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown (2)
MESA-INTEL: warning: ../src/intel/vulkan/anv_formats.c:782: FINISHME: support YUV colorspace with DRM format modifiers
MESA-INTEL: warning: ../src/intel/vulkan/anv_formats.c:814: FINISHME: support more multi-planar formats with DRM modifiers
2025-04-01 14:51:12.875 | SUCCESS  | src.app:on_activate:112 - Finished loading app
2025-04-01 14:51:12.883 | INFO     | autostart:request_background_callback:58 - request_background success=True
2025-04-01 14:51:13.450 | INFO     | src.backend.Store.StoreBackend:get_stores:74 - Official store branch: main
2025-04-01 14:51:13.566 | INFO     | src.backend.Store.StoreBackend:get_stores:74 - Official store branch: main
2025-04-01 14:51:13.647 | INFO     | __main__:update_assets:191 - Updating 0 store assets took 1.4214468002319336 seconds
2025-04-01 14:51:25.574 | INFO     | src.app:on_reopen:116 - awake
2025-04-01 14:51:42.065 | INFO     | src.backend.DeckManagement.DeckManager:on_connect:133 - Device /dev/bus/usb/003/050 with info: {'ID_MODEL_ID': '0084', 'ID_MODEL': 'Stream_Deck_Plus', 'ID_MODEL_FROM_DATABASE': '', 'ID_VENDOR': 'Elgato', 'ID_VENDOR_ID': '0fd9', 'ID_VENDOR_FROM_DATABASE': 'Elgato Systems GmbH', 'ID_USB_INTERFACES': ('030000',), 'ID_USB_CLASS_FROM_DATABASE': '', 'DEVNAME': '/dev/bus/usb/003/050', 'DEVTYPE': 'usb_device'} connected
Exception in thread USB Monitor:
Traceback (most recent call last):
  File "/usr/lib/python3.12/threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "/app/lib/python3.12/site-packages/pyudev/monitor.py", line 544, in run
    self._callback(device)
  File "/app/lib/python3.12/site-packages/usbmonitor/__platform_specific_detectors/_linux_usb_detector.py", line 73, in __handle_device_event
    on_connect(device_id, device_info)
  File "/app/bin/StreamController/src/backend/DeckManagement/DeckManager.py", line 138, in on_connect
    self.connect_new_decks()
  File "/app/bin/StreamController/src/backend/DeckManagement/DeckManager.py", line 150, in connect_new_decks
    self.add_newly_connected_deck(deck)
  File "/app/bin/StreamController/src/backend/DeckManagement/DeckManager.py", line 179, in add_newly_connected_deck
    deck_controller = DeckController(self, deck)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/bin/StreamController/src/backend/DeckManagement/DeckController.py", line 325, in __init__
    self.deck.open(self.deck_manager.beta_resume_mode)
TypeError: StreamDeck.open() takes 1 positional argument but 2 were given

kawaiishay avatar Apr 01 '25 18:04 kawaiishay

For ^^^ I had to manually remove the pip streamdeck package for a previous installation and install streamcontroller-streamdeck.

for flatpak I needed to update pypi-requirements.yaml and update build-commands: to remove streamdeck and include streamcontroller-streamdeck

as well as the sources:

  url: https://files.pythonhosted.org/packages/7a/8e/a186982a8e5036308e1ec631d6a928c3967dcc43b09b1197735c1e30015a/streamcontroller_streamdeck-0.1.4-py3-none-any.whl
  sha256: 66310efeb85736eb1fb765a1eed25b5ad5c465d8065d35bc60cc845538373382

kawaiishay avatar Apr 01 '25 20:04 kawaiishay

Had to add - --talk-name=org.kde.StatusNotifierWatcher to com.core447.StreamController.yml to allow flatpak to work with the tray icon and update to runtime-version: '48' to fix an issue with Adw.ToggleGroup() not existing in the Adw repository.

I have a fork of this (as I address some other minor hiccups I'm too impatient to wait for a release for here that reflects these changes. but overall I think I'm in good shape now with latest main~

We can close this ticket I believe. Sorry for the brain dump here!

kawaiishay avatar Apr 02 '25 02:04 kawaiishay

Modifying the com.core447.StreamController.yml file for libportal to:

  - name: libportal
    buildsystem: meson
    config-opts:
      - --libdir=/app/lib
      - -Dbackend-gtk3=disabled
      - -Dbackend-gtk4=enabled
      - -Dbackend-qt5=disabled
      - -Ddocs=false
      - -Dtests=false
      - -Dvapi=false
    sources:
      - type: git
        url: https://github.com/flatpak/libportal.git
        tag: 0.9.1

Got me passed this issue, but looks like the commit c038729 (on main) breaks support for x11 users:

Image

I don't use wayland at all. purely x11 on kde-plasma/ubuntu

Looks like this is specifically related to the new wayland package being missing from the flatpak package manifests. This issue should be fixed next time @Core447 regenerates those files.

dennisrijsdijk avatar Apr 03 '25 18:04 dennisrijsdijk

wrapping the import in main.py addressed the second issue:

try:
    from src.backend.Wayland.Wayland import Wayland
except ImportError:
    pass

Wrapping the import in a try-catch is not the correct behavior here. While the package is not installed, the issue will present on both Wayland and X11 systems. While wrapping the import fixes X11 systems, Wayland systems will try to use the Wayland class, which would not have been imported due to the package missing and would still fail.

dennisrijsdijk avatar Apr 03 '25 18:04 dennisrijsdijk

@dennisrijsdijk agreed for sure. That's why I created a fork for my changes (to target my use case without having to go too deep) instead of a PR. These for sure are a "hacky fix/workaround" at least for my system in general.

kawaiishay avatar Apr 03 '25 19:04 kawaiishay

Can you please try again with the newest upstream versions of both StreamController and the flatpak manifest?

Idk which flatpak manifest you used, but to get the current release please use: https://github.com/flathub/com.core447.StreamController

Core447 avatar Apr 19 '25 07:04 Core447

@Core447 I finally got around to trying a clean checkout of your main -- dev_upstream and pretty much all my issues still persist:

I used the flatback manifest you have committed here https://github.com/StreamController/StreamController/blob/main/com.core447.StreamController.yml in main but I do see it's outdated. When using the referenced one in your comment:

  1. All the runtime issues mentioned in this thread still exist (including the first one that caused me to open this bug). --- and I'm building with your install.sh ./flatpak/install.sh --repo=current --make-bundle --- I then just install manually sudo flatpak install /home/shayna/Unrelated_Setup_Stuff/StreamDeck/StreamController/StreamController/StreamController.flatpak on my branch dev_upstream
  2. Dial labels don't update when there is a background video (once I pull in my changes to get the app to launch) --- https://github.com/StreamController/StreamController/issues/341

In order to get back to my working status again I had to just pull upstream/main in my dev branch with the changes I've already committed.

kawaiishay avatar Apr 26 '25 01:04 kawaiishay

So just to verify, you're getting these errors:

  • ValueError: Namespace Xdp not available
  • ModuleNotFoundError: No module named 'wayland' ?

but you should now longer get: TypeError: StreamDeck.open() takes 1 positional argument but 2 were given

May I also ask why you're trying to build it manually (maybe there's an easier way to achieve what you want)?

Core447 avatar Apr 28 '25 20:04 Core447

@Core447 correct. I get these runtime errors when compiling from source.

I'm building from source since I have a fork to address a few issues for my StreamDeck Plus. For example: https://github.com/StreamController/StreamController/commit/b590481fcaaaeb0c999ea12053806d315276430c addresses https://github.com/StreamController/StreamController/issues/341

and other minor fixes for my system that the version in the flathub repo is running into. Since I've got experience in development - rather than spam my open tickets with update demands (since I know how annoying that is!) I just forked to fix the issues myself.

This ticket isn't critical to me personally -- I've already "fixed" these issues in my fork. But others may run into them.

kawaiishay avatar Apr 30 '25 17:04 kawaiishay

I'm building from source since I have a fork to address a few issues for my StreamDeck Plus. For example: b590481

I just applied this with: d4ee7bfb157ffab145fd286175c353ad36172e69

  1. All the runtime issues mentioned in this thread still exist (including the first one that caused me to open this bug). --- and I'm building with your install.sh ./flatpak/install.sh --repo=current --make-bundle --- I then just install manually sudo flatpak install /home/shayna/Unrelated_Setup_Stuff/StreamDeck/StreamController/StreamController/StreamController.flatpak on my branch dev_upstream

Just noticed you're building differently than me. Can you please try this?:

  • flatpak kill com.core447.StreamController - or close it completely using the option in the hamburger menu
  • flatpak uninstall com.core447.StreamController
  • git clone https://github.com/flathub/com.core447.StreamController --recursive
  • cd com.core447.StreamController
  • flatpak-builder --repo=repo --force-clean --install --user build-dir com.core447.StreamController.yml

Core447 avatar Apr 30 '25 18:04 Core447

@Core447 will try this today and report back! On a side note, it looks like I get a ton of "bad window" errors from flatpak and often times the actions have to be triggered twice to run (have to press a button twice) -- memory usage is also pretty high when my system is idling:

Image

kawaiishay avatar May 05 '25 18:05 kawaiishay

@Core447 also just gave your steps a shot and same errors occurred:

StreamController.log

kawaiishay avatar May 05 '25 18:05 kawaiishay

@Core447 also just gave your steps a shot and same errors occurred:

StreamController.log

Ok, very weird. Unfortunately, I don't think I can really help debugging this, as this happens on none of my (virtual-)machines and also not on the Flathub build servers.

Core447 avatar May 05 '25 19:05 Core447

@Core447 all good! Ive got it solved on my fork (well the runtime errors of xdp and wayland at least) - Ill keep chugging away at the other little stuff I run in to! Thank you for your hard work on this!

kawaiishay avatar May 05 '25 20:05 kawaiishay

FWIW I had to also install xdg-desktop-portal-gnome on arch. I think I was missing libportal-gtk4 when I did my initial setup.

maillota avatar Jun 08 '25 07:06 maillota

Since this is resolved according to @kawaiishay, closing the issue

ImDevinC avatar Jun 26 '25 17:06 ImDevinC