How to fix/debug discord screenshare issues on KDE

It might have gotten better, and it might work on other distros, but it does not work for NixOS, pipewire is enabled, I do not know how to debug this issue or what to look for, sharing other windows or even screen does not work on browser, nor desktop app (more specifically vesktop, but i tried the native client). Any idea how to fix this? Or atleast debug

This is the latest KDE (6.3), and I am on unstable (updated yesterday), on wayland

Tbh it’s not something i have tried out myself, but i have read somewhere, that you would need to have xwaylandvideobridge installed.

Alternatively, use discord in a wayland-compatible browser (I think both firefox and chrom* work ootb these days) and have no wayland-related issues, while also being safer because you’re not using electron that is just a year-old chromium in disguise.

1 Like

I installed xwayland video bridge, on browsers it refuses to let me stream anything, especially tabs and windows

In browsers wont work for me either, it simply refuses to stream anything, especially tabs and windows

Can you run journalctl -f --user and then attempt to screenshare, then share your logs?

When I try web (librewolf):

When I try native client:

Brave:

@TLATER

You seem to be missing a desktop portal (though if I read it correctly you also used flatpak and both the browsers from that are built for Xorg and therefore won’t work - use the nix packages).

KDE should be installing its portal by default, can you share your config?

I’ll try the nix packages at some point, also i dont use plasma-manager, idk if thats relevent

Also, is there any packages I can install? to install the portals which does not seem to be present on my system. Or should I file a issue with nixpkgs, I mean in either case this shouldnt be happening unless I explicitly told kde to not install the portals which I did not.

Well, that’s the thing, the plasma module already does that for you, and afaict you enable it. Installing it again is pointless.

I’d give native Firefox a shot before trying anything else, I have no idea if brave is compiled with chrome’s wayland settings.

If that also doesn’t work we’ll have to narrow things down further. Your configuration is in a bit of a state, so I’m a bit suspicious of all the cruft you have in there, but there’s too much to sift through it at a glance.

You might want to learn about git branches, tags, stashes and the interactive rebase by the way. You should never want a backup file if you’re using git; you even appear to use emacs, magit is like half the reason to use emacs and makes all these concepts very visually grokkable and easy to use.

So have you tried discord only trough Flatpak? Or have you installed it trough nixpkgs.
On my system I have not installed xdg portals but discord screen sharing works completely fine on wayland. Even with sound.

I tried through the native app, and flatpak, I also tried to install the portal via:

  xdg.portal = {
    enable = true;
    extraPortals = [ pkgs.kdePackages.xdg-desktop-portal-kde ];
  };

I also put kdePackages.xwaylandvideobridge in systemPackages, do you have any other ideas on what I could try? Would you be willing to look a tiny bit at my configuration (it isnt exactly clean, but its readable). Or should i just file a bug under nixpkgs.

Well I did try with firefox? more specifically a firefox derivative, and I sent three pastebin trying it on various platforms, if needed I will send the native discord client logs. Also I will look at them again after enabling xdg and specifying portals to see if there is any update:

Discord client (vencord is enabled here, i use nixcord, so not exactly native):

Brave:

Librewolf (couldnt get logging to work on native firefox):

I did this again because I though some of those xdg settings and wayland video bridge would make it atleast log diffrently, i am not too sure. Also xwaylandvideo bridge is running, its minimized to the system tray.

Right, let me explain what’s going on, so maybe you understand where the mismatch is.


So, modern Linux DEs have now universally adopted wayland. X11 is still available, but it’s in the middle of being phased out.

Some desktop applications have however not yet caught on. This is because the second- or third-to-last ubuntu LTS is practically the universal development target for applications that don’t care about Linux support, and that means there is about a 4-8 year lag between what applications like discord do and what the Linux desktop actually needs. It also generally means that these applications are horribly insecure and shouldn’t be used.

This is alright in wayland land, because wayland has this integration layer called xwayland which sits in-between and translates X11 stuff to wayland. For the most part, this works well, except when wayland behaves fundamentally differently (notably, scaling on hidpi displays, font scaling, window resizing, window positioning between multiple screens, etc.). X11 just doesn’t have all the features we need for modern computer display purposes, so there’s no good way forward without fully abandoning it - but yeah, that’ll take a decade.

What does this have to do with screensharing? Well, wayland doesn’t permit applications to just randomly get output buffers from other applications. This is to prevent security issues; on traditional X11 systems it’s stupid easy to drop keyloggers n stuff which just capture everything happening on your desktop. It also allows wayland to optimize things a little under the hood.

For this reason, to be able to screenshare, an application needs to ask for permission on wayland. Applications that run on xwayland are completely incapable of this, because there is no concept like this in X11. You need a wayland-compatible application - or this xwaylandvideobridge, apparently, which I guess will just share buffers with any application the way X11 does, but asks for permission first. I wouldn’t be surprised if it’s a bit wonky and doesn’t always work.

Once we have an application that correctly asks for permission, wayland itself does not implement a UI of any kind, so we need some additional tool to show a popup and ask you if (and which) you want to share a window. The “xdg portal” of various desktop environments implement a protocol which wayland uses for this purpose, and pipewire is used underneath all of this to then actually share the buffee contents instead of directly giving things access to wayland memory.

So this leads to where we are here. You’re using the plasma desktop env, which by default sets up its xdg portal if you use the NixOS module for it. You should remove any additional portal configuration to minimize the amount of potentially incompatible things you have configured.

Next, you should confirm that whatever applications you’re trying to screenshare with actually use wayland. For this, I’d try disabling xwayland - not sure how to do that with plasma. If your browser doesn’t start anymore after that, it’s incompatible.

Once you’ve confirmed you have a browser that renders with wayland, and screensharing still does not work, we then will need to check the logs of pipewire and your xdg desktop portal to see if pipewire fails to send things around or if your portal fails to ask for permission.

Well, don’t we already have a idea of whats going wrong? Its lacking the portal, and I need to somehow get it on my system, according to the brave and librewolf logs that what it seems to say, I don’t know if lacking permissions will tell you the interface does not exist, I also dont know how to check if it exists in dbus/freedesktop, but im assuming not.

Well, yeah, assuming you’ve confirmed you actually have a working browser, and have removed the duplication re xdg portals, we go on to the next step. Check journalctl:

journalctl -ex --user --unit pipewire --unit xdg-desktop-portal.service --unit xdg-desktop-portal-kde.service

^ with librewolf when i try screenshare
Same result. No extra logs
^ with brave
Same log with vesktop
^ with vesktop
Same logs as everything else (this screenshares, but only a black screen)
^ Vencord and discord (kinda diffrent,)

Your terminal size is a little too small to read the names, but it looks like the kde portal isn’t started? Can you check if it’s in any of the subdirectories of /etc/systemd and that systemctl status xdg-desktop-portal-kde.service finds it?

[spiderunderurbed@daspidercave:~]$ systemctl status xdg-desktop-portal-kde.service
Unit xdg-desktop-portal-kde.service could not be found.
[ble: exit 4]

[spiderunderurbed@daspidercave:~]$

It does not exist.
I also tried this:

[spiderunderurbed@daspidercave:~]$ find /etc/systemd -type f -name 'xdg-desktop-portal-kde.service'

[spiderunderurbed@daspidercave:~]$

and this:

[spiderunderurbed@daspidercave:~]$ find /etc/systemd -type f -name 'xdg-desktop-portal*'

[spiderunderurbed@daspidercave:~]$