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

firefox: add pipewire patch for wayland users #84233

Merged
merged 1 commit into from Sep 21, 2020

Conversation

colemickens
Copy link
Member

@colemickens colemickens commented Apr 4, 2020

Motivation for this change

This enables WebRTC Screensharing for Firefox users on Wayland.

This patch is sourced from Fedora: https://src.fedoraproject.org/rpms/firefox/blob/master/f/firefox-pipewire-0-3.patch

an excerpt from my profiles/sway.nix:

{ pkgs, lib, config, inputs, ... }:

{
  imports = [ 
    #...
  ];
  config = {
    services.pipewire.enable = true;

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

    home-manager.users.cole = { pkgs, ... }: {
      home.sessionVariables = {
        MOZ_ENABLE_WAYLAND = "1";
        MOZ_USE_XINPUT2 = "1";
        XDG_SESSION_TYPE = "wayland";
        XDG_CURRENT_DESKTOP = "sway";
      };
    home.packages = with pkgs; [ firefox ];
  };
}

(This patch is required is due to limitations at the boundary of Firefox and WebRTC build systems: (I think it's this root issue:) https://bugzilla.mozilla.org/show_bug.cgi?id=1534615)

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@andir
Copy link
Member

andir commented Apr 4, 2020

I have seen those in the past.. I have the feeling that we do not have the same bandwidth that fedora has to carry custom patches from release to release. I surely am not looking forward to rebase a patch.

What is the current situation on upstream bugzilla regarding this?

On a related note: Fedora also carried a bunch of other wayland patches last time I checked. If we go this route, would those make also sense?

@colemickens
Copy link
Member Author

@andir

  1. I understand wanting to minimize maintenance overhead. Some thoughts though -- this patch isn't actually from Fedora, it's from another package maintainer that maintains this patch for Nightly: https://github.com/xhorak/firefox-devedition-flatpak/blob/master/org.mozilla.FirefoxNightly/firefox-pipewire.patch. It actually just happens to apply on Stable. To me this lowers the risk - the patch is likely to be available well ahead of when it's needed here for Stable.

  2. The issue on Bugzilla is basically that the change is wanted, but due to some complexity of their build system, is not really possible to enable upstream. I found a reddit comment that provides additional context as well. bugzilla explaining why this blocks pipewire/webrtc and the bugzilla explaining the blocking bug

  3. I can't speak to the other Fedora patches. (maybe relevant: https://src.fedoraproject.org/rpms/firefox/tree/master)

@colemickens colemickens changed the title firefox: add fedora's pipewire patch for wayland users firefox: add pipewire patch for wayland users Apr 4, 2020
@@ -94,6 +94,7 @@ stdenv.mkDerivation ({
patches = [
./env_var_for_system_dir.patch
]
++ lib.optional waylandSupport ./fedora-pipewire.patch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will update the filename

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you fetch it from fedora instead of putting it in-tree?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtojnar I'll update. Please note, this isn't the Fedora patch though (when I took the relevant patch from master, it didn't build, idk if our Firefox is newer?). This patch is here, which I believe was the repo building the Nightly Flatpak that most folks have been using for quite sometime: https://github.com/xhorak/firefox-devedition-flatpak

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, use https://github.com/xhorak/firefox-devedition-flatpak/raw/303388734fb213a9c4e5836f5017a4a849372bdb/org.mozilla.FirefoxNightly/firefox-pipewire.patch then.

@flokli flokli mentioned this pull request Apr 7, 2020
10 tasks
@worldofpeace
Copy link
Contributor

I for sure want this for gnome integration 👍

@worldofpeace
Copy link
Contributor

If this patch becomes a burden just forward the task to me.

@jtojnar
Copy link
Contributor

jtojnar commented Apr 14, 2020

There is also the issue of trademarks. We are only permitted to use the Firefox logo and name for builds that do not deviate from upstream too much, see #31843 (comment).

@worldofpeace
Copy link
Contributor

There is also the issue of trademarks. We are only permitted to use the Firefox logo and name for builds that do not deviate from upstream too much, see #31843 (comment).

Does that mean Fedora somehow has special privileges?

I believe these are the relevant bugs in firefox:

@jtojnar
Copy link
Contributor

jtojnar commented Apr 14, 2020

No idea. Maybe legal people just did not notice yet.

@colemickens colemickens force-pushed the nixpkgs-firefox-pipewire branch 3 times, most recently from 029730e to f41df2b Compare April 22, 2020 07:30
@@ -0,0 +1,473 @@
diff --git a/config/system-headers.mozbuild b/config/system-headers.mozbuild
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required if you use fetchpatch.

@colemickens
Copy link
Member Author

By the way, this builds now, but I can't really validate this properly due to sway/wlroots/xdg stuff that needs a lot of attention first.

@worldofpeace
Copy link
Contributor

@colemickens I can do this, since it should be straightforward in a GNOME environment.

@worldofpeace
Copy link
Contributor

was getting

      |          ^~~~~~~~~~~~
free(): invalid pointer
In file included from /build/firefox-75.0/obj-x86_64-pc-linux-gnu/dist/include/nsThreadUtils.h:18,
                 from /build/firefox-75.0/xpcom/base/nsInterfaceRequestorAgg.cpp:11,
                 from Unified_cpp_xpcom_base2.cpp:2:
/build/firefox-75.0/obj-x86_64-pc-linux-gnu/dist/include/mozilla/Tuple.h: In instantiation of 'struct mozilla::detail::TupleImpl<7, long unsigned int, long unsigned int, bool, bool, mozilla::dom::UserActivation::State, bool, RefPtr<mozilla::dom::FeaturePolicy>, unsigned int, nsID, bool, bool, bool, mozilla::dom::GVAutoplayRequestStatus, mozilla::dom::GVAutoplayRequestStatus, float, mozilla::dom::OrientationType, nsTString<char16_t>, mozilla::Maybe<nsTString<char16_t> > >':
/build/firefox-75.0/obj-x86_64-pc-linux-gnu/dist/include/mozilla/Tuple.h:114:8:   recursively required from 'struct mozilla::detail::TupleImpl<1, bool, bool, nsILoadInfo::CrossOriginEmbedderPolicy, nsILoadInfo::CrossOriginOpenerPolicy, long unsigned int, long unsigned int, long unsigned int, long unsigned int, bool, bool, mozilla::dom::UserActivation::State, bool, RefPtr<mozilla::dom::FeaturePolicy>, unsigned int, nsID, bool, bool, bool, mozilla::dom::GVAutoplayRequestStatus, mozilla::dom::GVAutoplayRequestStatus, float, mozilla::dom::OrientationType, nsTString<char16_t>, mozilla::Maybe<nsTString<char16_t> > >'
/build/firefox-75.0/obj-x86_64-pc-linux-gnu/dist/include/mozilla/Tuple.h:114:8:   required from 'struct mozilla::detail::TupleImpl<0, nsTString<char16_t>, bool, bool, nsILoadInfo::CrossOriginEmbedderPolicy, nsILoadInfo::CrossOriginOpenerPolicy, long unsigned int, long unsigned int, long unsigned int, long unsigned int, bool, bool, mozilla::dom::UserActivation::State, bool, RefPtr<mozilla::dom::FeaturePolicy>, unsigned int, nsID, bool, bool, bool, mozilla::dom::GVAutoplayRequestStatus, mozilla::dom::GVAutoplayRequestStatus, float, mozilla::dom::OrientationType, nsTString<char16_t>, mozilla::Maybe<nsTString<char16_t> > >'
/build/firefox-75.0/obj-x86_64-pc-linux-gnu/dist/include/mozilla/Tuple.h:224:7:   required from 'class mozilla::Tuple<nsTString<char16_t>, bool, bool, nsILoadInfo::CrossOriginEmbedderPolicy, nsILoadInfo::CrossOriginOpenerPolicy, long unsigned int, long unsigned int, long unsigned int, long unsigned int, bool, bool, mozilla::dom::UserActivation::State, bool, RefPtr<mozilla::dom::FeaturePolicy>, unsigned int, nsID, bool, bool, bool, mozilla::dom::GVAutoplayRequestStatus, mozilla::dom::GVAutoplayRequestStatus, float, mozilla::dom::OrientationType, nsTString<char16_t>, mozilla::Maybe<nsTString<char16_t> > >'
/build/firefox-75.0/obj-x86_64-pc-linux-gnu/dist/include/mozilla/dom/SyncedContext.h:163:14:   required from 'struct mozilla::dom::syncedcontext::FieldStorage<void, nsTString<char16_t>, bool, bool, nsILoadInfo::CrossOriginEmbedderPolicy, nsILoadInfo::CrossOriginOpenerPolicy, long unsigned int, long unsigned int, long unsigned int, long unsigned int, bool, bool, mozilla::dom::UserActivation::State, bool, RefPtr<mozilla::dom::FeaturePolicy>, unsigned int, nsID, bool, bool, bool, mozilla::dom::GVAutoplayRequestStatus, mozilla::dom::GVAutoplayRequestStatus, float, mozilla::dom::OrientationType, nsTString<char16_t>, mozilla::Maybe<nsTString<char16_t> > >'
/build/firefox-75.0/obj-x86_64-pc-linux-gnu/dist/include/mozilla/dom/BrowsingContext.h:132:3:   required from here
/build/firefox-75.0/obj-x86_64-pc-linux-gnu/dist/include/mozilla/Tuple.h:114:8: internal compiler error: Aborted
  114 | struct TupleImpl<Index, HeadT, TailT...>
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
make[3]: *** [/build/firefox-75.0/config/rules.mk:745: Unified_cpp_xpcom_base2.o] Error 1
make[3]: *** Waiting for unfinished jobs....

@andir
Copy link
Member

andir commented Apr 22, 2020 via email

@worldofpeace
Copy link
Contributor

@andir RAM 23.1/62.8G and from the looks of df

df -h /tmp
Filesystem     Type  Size  Used Avail Use% Mounted on
zroot/root     zfs   162G  8.1G  154G   6% /

@calbrecht
Copy link
Member

calbrecht commented May 25, 2020

Fedora has a pipewire-0.3.patch now. I am currently trying to build building with my overlay. Also do i have the screensharing running since two months, on sway. I am interested in helping out here.

@calbrecht
Copy link
Member

Also, the patch for pipewire-0.3 is the first that seems to work relatively stable, together with latest xdg-desktop-portal-wlr and latest pipewire on sway.

@colemickens
Copy link
Member Author

@calbrecht is that from your experience in Fedora, or do you have a Firefox build from nixpkgs that works?

@calbrecht
Copy link
Member

@colemickens thats from my experience from running it on nixos master since i got it to run for the first time about two months ago. See the overlay :)

@berbiche
Copy link
Member

berbiche commented Aug 17, 2020

This is really awesome though only one of my monitors can be shared.
@colemickens does it work for you with multiple monitors?

@alexarice
Copy link
Contributor

@berbiche this is a current limitation of xdp-desktop-portal-wlr

@efouladi
Copy link

I've updated the PR and the OP. Please see the OP for usage instructions.

This is ready for review/consideration. Thank you reviewers and those following along.

If you'd like to test (and willing to trust my binary server for this):

export NIX_PATH="nixpkgs=https://github.com/colemickens/nixpkgs/archive/nixpkgs-firefox-pipewire.tar.gz"

nix-shell \
  --option 'extra-binary-caches' 'https://cache.nixos.org https://colemickens.cachix.org' \
  --option 'trusted-public-keys' 'cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= colemickens.cachix.org-1:bNrJ6FfMREB4bd4BOjEN85Niu8VcPdQe4F4KxVsb/I4=' \
  -p firefox --command "firefox --no-remote"

You can test on this page: https://mozilla.github.io/webrtc-landing/gum_test.html

Thanks for the great work :) I was wondering how I can use this in nixos configuration. If I import it and put it in nixpkgs.overlays I get the infinite recursion error

@alexarice
Copy link
Contributor

I am using this overlay:

firefox-wayland = self: super: {
  firefox = let
    src = self.fetchFromGitHub {
      owner = "colemickens";
      repo = "nixpkgs";
      rev = "nixpkgs-firefox-pipewire";
      sha256 = "1yswyxy24wjxqmjld56853vq4jq98c6wmqkybnpbg537d79xplbq";
    };
    in (import src { }).firefox;
};

@efouladi
Copy link

I am using this overlay:

firefox-wayland = self: super: {
  firefox = let
    src = self.fetchFromGitHub {
      owner = "colemickens";
      repo = "nixpkgs";
      rev = "nixpkgs-firefox-pipewire";
      sha256 = "1yswyxy24wjxqmjld56853vq4jq98c6wmqkybnpbg537d79xplbq";
    };
    in (import src { }).firefox;
};

Thanks. this works. The sha is wrong though. On a different note, the whole reason I wanted to use this is to utilize the cache but it doesn't seem to be working. NixOS still tries to compile it from the source

@alexarice
Copy link
Contributor

The sha was correct when I first tried this and it built from cache then, maybe it has been updated since?

@efouladi
Copy link

The sha was correct when I first tried this and it built from cache then, maybe it has been updated since?

yeah, that's probably it.

@hlolli
Copy link
Member

hlolli commented Sep 16, 2020

I am using this overlay:

firefox-wayland = self: super: {
  firefox = let
    src = self.fetchFromGitHub {
      owner = "colemickens";
      repo = "nixpkgs";
      rev = "nixpkgs-firefox-pipewire";
      sha256 = "1yswyxy24wjxqmjld56853vq4jq98c6wmqkybnpbg537d79xplbq";
    };
    in (import src { }).firefox;
};

I tried this firefox overlay on sway, probably unrelated, but I just get a black screen and a cursor when sharing my screen. Probably configuration right? At least, there's a moving cursor, which is an improvement from the total black screen from before.

@berbiche
Copy link
Member

@hlolli were you using #84233 (comment) configuration?

@hlolli
Copy link
Member

hlolli commented Sep 16, 2020

@hlolli were you using #84233 (comment) configuration?

my blunder, I just added that config, now my firefox resolution is much bigger, I get a secondary screen when I enable by webcam. On google hangouts, I select to share my screen, but it's effectively a no-op, and the screen share button is greyed. But anyway, we can take this discussion somewhere else, feel it's bit off topic.

Copy link
Contributor

@MatthewCroughan MatthewCroughan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

@worldofpeace
Copy link
Contributor

Just rebased, I'm on GNOME 3 so I'll try it out from cachix. Will likely merge this shortly.

Copy link
Contributor

@worldofpeace worldofpeace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It worked let's go.

@FlorianFranzen
Copy link
Contributor

@NixOS/backports: Any chance we could backport this to 20.09?

@worldofpeace
Copy link
Contributor

@NixOS/backports: Any chance we could backport this to 20.09?

I'd love that.

@colemickens
Copy link
Member Author

Is this still working for y'all? I even pulled a newer pipewire patch from Fedora and re-built and I still can't get it to activate. (It was working when this was sent though)

@berbiche
Copy link
Member

berbiche commented Oct 5, 2020

Still works on my end on revision 0b67d9e

@worldofpeace
Copy link
Contributor

I'm using GNOME and everything at https://mozilla.github.io/webrtc-landing/gum_test.html works

@worldofpeace
Copy link
Contributor

opened #99692

@ajs124 ajs124 mentioned this pull request Nov 17, 2020
10 tasks
@colemickens colemickens deleted the nixpkgs-firefox-pipewire branch December 30, 2022 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet