The sad state of screen sharing on desktop Linux
TL;DR: make sure you have pipewire and xdg-desktop-portal installed, look up how to enable pipewire for your browser. It <i>might</i> help.<p>Well, this blog post barely scratches the surface.<p>The Linux userspace display stack is currently undergoing a big overhaul, following the changes that happened in the kernel a few years ago (DRI3, KMS, atomic modesetting, etc).<p>All of this made Wayland possible. That, plus the fact that apps rasterize their surfaces themselves nowadays (GPU-accelerated trough OpenGL&#x2F;Vulkan).<p>So, here comes Wayland with a new security model: you can&#x27;t spy on other windows, so you cannot hack together a desktop sharing solution. A proper, cross-desktop solution is actually being worked on: pipewire[1].<p>Pipewire aims to replace both pulseaudio <i>and</i> jack for audio, and bring video in as well. So you will be able to direct which video feed goes where, use the same webcam for multiple applications, and have applications take a video feed, transform it, and plug it elsewhere. You can see where this is fitting with desktop sharing: one feed per window, one feed per screen, one feed for the whole desktop, plus variants. Want to overlay a webcam? No problem. Everything is backed by Gstreamer for realtime hardware-accelerated video encoding&#x2F;decoding.<p>And the icing on the cake: Flatpak spearheaded the development of &quot;portals&quot;[2]: cross-desktop interfaces for individual programs to ask the user when accessing restricted resources (like a microphone, or a folder on your computer).<p>So, what&#x27;s needed here is:<p>* Finish up pipewire and have it shipped on most distributions (should be installed in fedora 31, optional for sound in 32, default for sound in 33)<p>* Have compositors talk to pipewire [3]<p>* Have browsers and other software talk to pipewire [4]<p>* ???<p>* Profit<p>Good progress is being made on these points, except maybe the last? I expect support to start working out-of-the-box in some distros&#x2F;browser&#x2F;compositor combinations in 2020. Actually, support seems further along than I thought it was. But it seems that wlroots-based compositor haven&#x27;t yet decided to support the xdg screensharing portal, and rely instead on a custom wayland extension. I wouldn&#x27;t be surprised if such a portal is implemented for those.<p>The main issue here is everyone waiting on everyone else before enabling&#x2F;implementing it. But it looks like we&#x27;re 80% there, and it just needs to be enabled in some cases (and pipewire installed). Then it will trickle down to most distros and electrons apps.<p>However, I don&#x27;t think legacy X apps will be able to continue sharing the desktop (they can still be shared by wayland capture programs, or capture the desktop if they implement the new interface). I guess pipewire might be able to create a virtual webcam for these, though.<p>Valve might be working on their own stack with their &quot;Gamescope&quot; wayland compositor[5], for their streaming solution.<p>And in the end, this should work much better, with hardware encoding, actual security, zero copy, etc. Hopefully there won&#x27;t be a &quot;next big thing&quot; that breaks everything in just a few years.<p>[1] <a href="https:&#x2F;&#x2F;pipewire.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pipewire.org&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;wiki.archlinux.org&#x2F;index.php&#x2F;PipeWire" rel="nofollow">https:&#x2F;&#x2F;wiki.archlinux.org&#x2F;index.php&#x2F;PipeWire</a><p>[2] <a href="https:&#x2F;&#x2F;flatpak.github.io&#x2F;xdg-desktop-portal&#x2F;portal-docs.html" rel="nofollow">https:&#x2F;&#x2F;flatpak.github.io&#x2F;xdg-desktop-portal&#x2F;portal-docs.htm...</a><p>[2] <a href="https:&#x2F;&#x2F;flatpak.github.io&#x2F;xdg-desktop-portal&#x2F;portal-docs.html#gdbus-org.freedesktop.portal.ScreenCast" rel="nofollow">https:&#x2F;&#x2F;flatpak.github.io&#x2F;xdg-desktop-portal&#x2F;portal-docs.htm...</a><p>[3] <a href="http:&#x2F;&#x2F;jgrulich.cz&#x2F;2018&#x2F;03&#x2F;06&#x2F;screen-sharing-in-plasma-wayland-session&#x2F;" rel="nofollow">http:&#x2F;&#x2F;jgrulich.cz&#x2F;2018&#x2F;03&#x2F;06&#x2F;screen-sharing-in-plasma-wayla...</a><p>[3] <a href="https:&#x2F;&#x2F;jgrulich.cz&#x2F;2018&#x2F;07&#x2F;04&#x2F;how-to-enable-and-use-screen-sharing-on-wayland&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jgrulich.cz&#x2F;2018&#x2F;07&#x2F;04&#x2F;how-to-enable-and-use-screen-...</a><p>[3] <a href="https:&#x2F;&#x2F;wiki.gnome.org&#x2F;Projects&#x2F;Mutter&#x2F;RemoteDesktop" rel="nofollow">https:&#x2F;&#x2F;wiki.gnome.org&#x2F;Projects&#x2F;Mutter&#x2F;RemoteDesktop</a><p>[3] <a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;linux&#x2F;comments&#x2F;8le7rm&#x2F;first_steps_for_kde_screencast_on_wayland&#x2F;dzfqftz&#x2F;?context=8&amp;depth=9" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;linux&#x2F;comments&#x2F;8le7rm&#x2F;first_steps_f...</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;emersion&#x2F;xdg-desktop-portal-wlr&#x2F;issues&#x2F;1" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;emersion&#x2F;xdg-desktop-portal-wlr&#x2F;issues&#x2F;1</a><p>[4] <a href="https:&#x2F;&#x2F;bugzilla.mozilla.org&#x2F;show_bug.cgi?id=1496359" rel="nofollow">https:&#x2F;&#x2F;bugzilla.mozilla.org&#x2F;show_bug.cgi?id=1496359</a> (looks disabled by default at compile time)<p>[4] <a href="https:&#x2F;&#x2F;bugs.chromium.org&#x2F;p&#x2F;chromium&#x2F;issues&#x2F;detail?id=682122" rel="nofollow">https:&#x2F;&#x2F;bugs.chromium.org&#x2F;p&#x2F;chromium&#x2F;issues&#x2F;detail?id=682122</a> (pipewire disabled in chrome:&#x2F;&#x2F;flags until v81 due to waiting on <a href="https:&#x2F;&#x2F;github.com&#x2F;flatpak&#x2F;xdg-desktop-portal-gtk&#x2F;issues&#x2F;204" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;flatpak&#x2F;xdg-desktop-portal-gtk&#x2F;issues&#x2F;204</a> &quot;dialog hell&quot; it seems)<p>[4] zoom currently uses a gnome-specific screenshot API as a workaround: <a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;swaywm&#x2F;comments&#x2F;dr8yld&#x2F;zoom_screenshare_via_screenshot_emulation&#x2F;f6gfzds&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;swaywm&#x2F;comments&#x2F;dr8yld&#x2F;zoom_screens...</a><p>[5] <a href="https:&#x2F;&#x2F;www.gamingonlinux.com&#x2F;articles&#x2F;valve-give-a-little-more-info-on-what-gamescope-actually-does-for-linux-gaming.15783&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.gamingonlinux.com&#x2F;articles&#x2F;valve-give-a-little-m...</a>