Screen sharing with Wayland Gnome

A couple of days ago screen sharing stopped working. I primarily use it with JitSi in Firefox and it used to work just fine. Now when I try to share my screen:

  • the browser asks for permission to share the screen,
  • I select “Use operating system settings”, then
  • I get a selector that looks like it’s native GTK and it correctly lists my screens and windows.
  • When I select any of them the orange screen sharing indicator in Gnome panel shows up

All of the above is same as before, but then:

  • In the terminal where I ran Firefox I see:
    [E][000000378.275192][context.c:224 pw_context_new()] context 0x7fb26b509400: can't load config client.conf: No such file or directory
  • Nothing changes in the app - the screen is not shared.

I can take screenshots with Gnome Screenshot, record the screen with Ctrl-Alt-Shift-R and Peek.

I tried few things, but to no effect.

  • set xdg.portal.enable in /etc/nixos/configuration.nix
  • add pkgs.xdg-desktop-portal-gtk to home.packages in Home Manager
  • run Firefox with GTK_USE_PORTAL=1 firefox

None of the above had any effect. At this point I’m a clueless. Any directions will be appreciated.

Here’s my nix-info:

  • system: "x86_64-linux"
  • host os: Linux 5.11.11, NixOS, 20.09.3777.ad7604ddbd9 (Nightingale)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.4pre20210317_8a5203d
  • channels(root): "nixos-20.09.3777.ad7604ddbd9"
  • channels(tad): "home-manager, nixpkgs"
  • nixpkgs: /home/tad/.nix-defexpr/channels/nixpkgs
1 Like

Following the instructions at https://nixos.wiki/wiki/Firefox I’ve added this to /etc/nixos/configuration.nix:

xdg = {
  portal = {
    enable = true;
    extraPortals = with pkgs; [
      xdg-desktop-portal-wlr
      xdg-desktop-portal-gtk
    ];
    gtkUsePortal = true;
  };
};

and this to home.nix:

  programs.firefox = {
    enable = true;
    package = pkgs.wrapFirefox pkgs.firefox-unwrapped {
      forceWayland = true;
      extraPolicies = {
        ExtensionSettings = {};
      };
    };
  };

This made Gnome Shell startup very slow (~ 1 minute from entering the password to getting desktop ready) and didn’t fix the sharing problem.

By switching to an old generation of Home Manager (from March 5, so more than a month ago) I got the screen sharing to work. One difference between now and then is the version of Firefox (it was 85.2 and current is 87.0). I’ve also found a thread on Arch forum that suggests that the version of Firefox might be the problem. I’d like to probe it. How can I downgrade Firefox while keeping the rest of my system the same?

you can get a pinned firefox e.g. via overlay

1 Like

Thanks @igel. Based on your suggestion I’ve used the https://lazamar.co.uk/nix-versions/ website to find the right commit and I’ve been able to run Firefox 85.0.1. With this previous version the screen sharing works as expected.

$ nix-shell \
  -p firefox-wayland \
  -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/bed08131cd29a85f19716d9351940bdc34834492.tar.gz
...
[nix-shell:~]$ firefox --version
Mozilla Firefox 85.0.1

[nix-shell:~]$ firefox
...

Also, @sternenseemann pointed me on Matrix chat to https://github.com/NixOS/nixpkgs/issues/119445#issuecomment-820507505. Thanks. Unfortunately I couldn’t apply it to my issue because I’m using Gnome and the problem and fix seems to be Sway specific.

I guess I should open a separate issue.

I’ve opened an issue with nixpkgs: https://github.com/NixOS/nixpkgs/issues/119810.

Screen sharing still doesn’t work after upgrading to Firefox 88.

To make my life easier I figured out a one-liner to launch Firefox 85 (where screen sharing works) along side whatever version is installed by default. I’m sharing it in case someone else is also struggling with this issue:

nix run \
  https://github.com/NixOS/nixpkgs/archive/bed08131cd29a85f19716d9351940bdc34834492.tar.gz#firefox \
  -- \
  --new-instance \
  -P wayland-screen-sharing-downgrade

The -P option is for setting profile by name (somewhat confusingly --profile sets it by path). First time you run it, it will open a profile manager because there is no wayland-screen-sharing-downgrade profile yet. Just create it. Next time it will run without asking. Using separate profile is important, because the new version may be incompatible with the old. I ran into weird problems and I think that was the reason.

Since it’s technically a different browser than the one you have installed, it will also ask to set it as default. That’s probably not what you want.

It’s a workaround and I still hope to find a proper fix.

Just in case, maybe you missed the pipewire installation. You might try to enable it through this setting: NixOS Search. As I know xdg portal is the protocol while pipewire is the impl.

1 Like

I just got it working, apparently by moving Firefox from ~/.config/nixpkgs/home.nix to /etc/nixos/configuration.nix. Perhaps the issue was caused by using 20.09 channel for NixOS and unstable for Home Manager.

It was @abdillah who inspired me to try this. Although I already had pipewire enabled in configuration.nix I thought that since it’s using a different channel than Home Manager there might be some incompatibility.

The way it works now is a bit wonky. After I select the screen to share once the sharing doesn’t start. Instead the same selection dialog appears - sometimes immediately, sometimes with a delay of up to few seconds. Sometimes it appears below the main Firefox window and I have to “dig it up”. After selecting the screen again the sharing starts.

I consider this good enough. Thanks to everyone who offered their help.

1 Like

Thank you @tad-lispy i had given up on screen sharing in chrome using wayland gnome. But moving the chrome install from home-manager to my nixos configuration solved the problem for me!

1 Like