Open Bug 1676134 Opened 4 years ago Updated 1 year ago

Build PipeWire support on FreeBSD

Categories

(Core :: WebRTC, defect, P3)

Desktop
FreeBSD
defect

Tracking

()

Tracking Status
firefox-esr78 --- unaffected
firefox82 --- unaffected
firefox83 --- unaffected
firefox84 --- wontfix

People

(Reporter: val, Unassigned)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

PipeWire support has been added very recently to WebRTC, and I think this even broke the build on FreeBSD (specifically the lack of CXXFLAGS += CONFIG['TK_CFLAGS'] — it was trying to use gtk3 includes even without the new source files or WEBRTC_USE_PIPEWIRE).

Something like this should be done

--- i/third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build
+++ w/third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build
@@ -124,6 +124,7 @@ if CONFIG["OS_TARGET"] == "FreeBSD":
     DEFINES["WEBRTC_BSD"] = True
     DEFINES["WEBRTC_POSIX"] = True
     DEFINES["_FILE_OFFSET_BITS"] = "64"
+    DEFINES["WEBRTC_USE_PIPEWIRE"] = "1"
 
     OS_LIBS += [
         "X11",
@@ -155,6 +156,15 @@ if CONFIG["OS_TARGET"] == "FreeBSD":
         "/third_party/libwebrtc/webrtc/modules/desktop_capture/window_capturer_linux.cc"
     ]
 
+    CXXFLAGS += CONFIG['TK_CFLAGS']
+
+    UNIFIED_SOURCES += [
+        "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc",
+        "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc",
+        "/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc"
+    ]
+
+
 if CONFIG["OS_TARGET"] == "Linux":
 
     DEFINES["USE_NSS_CERTS"] = "1"
--- i/third_party/libwebrtc/webrtc/moz.build
+++ w/third_party/libwebrtc/webrtc/moz.build
@@ -176,6 +176,9 @@ if CONFIG["OS_TARGET"] == "FreeBSD":
         "/third_party/libwebrtc/webrtc/modules/desktop_capture/primitives_gn",
         "/third_party/libwebrtc/webrtc/modules/video_capture/video_capture_internal_impl_gn"
     ]
+    DIRS += [
+        "/third_party/pipewire/libpipewire"
+    ]
 
 if CONFIG["OS_TARGET"] == "Linux":

but that is generated from gn files. (How do I regenerate this?)

This should be part of the real patch:

--- i/third_party/libwebrtc/webrtc/modules/desktop_capture/BUILD.gn
+++ w/third_party/libwebrtc/webrtc/modules/desktop_capture/BUILD.gn
@@ -155,7 +155,7 @@ if (rtc_include_tests) {
   }
 }
 
-if (is_linux) {
+if (is_linux || is_bsd) {
   if (rtc_use_pipewire) {
     defines = [ "WEBRTC_USE_PIPEWIRE" ]
     pkg_config("gio") {

but this seems to only handle WEBRTC_USE_PIPEWIRE, I'm not sure where DIRS / UNIFIED_SOURCES / CXXFLAGS come from

Flags: needinfo?(jbeich)

(In reply to greg v [:myfreeweb] from comment #0)

broke the build on FreeBSD

I confirm:

In file included from Unified_cpp_p_capture_generic_gn0.cpp:56:
In file included from third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capturer.cc:17:
objdir/dist/system_wrappers/gtk/gtk.h:3:15: fatal error: 'gtk/gtk.h' file not found
#include_next <gtk/gtk.h>
              ^~~~~~~~~~~

How do I regenerate this?

See https://firefox-source-docs.mozilla.org/build/buildsystem/gn.html
In the past it required gn from devel/chromium-gn < 76 and python (2.7) symlink (via lang/python).

After bug 1672989 it fails even if I add is_bsd as you've suggested:

$ ./mach build-backend -b GnConfigGen
 0:00.11 objdir/_virtualenvs/init_py3/bin/python objdir/config.status --backend GnConfigGen
Reticulating splines...
 0:00.70 File already read. Skipping: gfx/angle/targets/angle_common/moz.build
Running "/usr/local/bin/gn gen objdir/dom/media/webrtc/third_party_build/../../../../third_party/libwebrtc/webrtc/gn-output --args=is_debug=false target_os="freebsd" host_cpu="x64" target_cpu="x64" --ide=json"
ERROR at //modules/desktop_capture/BUILD.gn:329:5: Replacing nonempty list.
    include_dirs = [ "/third_party/libwebrtc/third_party/pipewire" ]
    ^-----------
This overwrites a previously-defined nonempty list with another nonempty list.
See //modules/desktop_capture/BUILD.gn:320:20: for previous definition
    include_dirs = [ "/media/libyuv/libyuv/include" ]
                   ^--------------------------------
Did you mean to append/modify instead? If you really want to overwrite, do:
  foo = []
before reassigning.
See //modules/BUILD.gn:30:22: which caused the file to be included.
    public_deps += [ "desktop_capture" ]
                     ^----------------
Traceback (most recent call last):
  File "objdir/config.status", line 1028, in <module>
    config_status(**args)
  File "python/mozbuild/mozbuild/config_status.py", line 177, in config_status
    the_backend.consume(definitions)
  File "python/mozbuild/mozbuild/backend/base.py", line 132, in consume
    if not self.consume_object(obj) and not isinstance(self, PartialBackend):
  File "python/mozbuild/mozbuild/gn_processor.py", line 615, in consume_object
    generate_gn_config(
  File "python/mozbuild/mozbuild/gn_processor.py", line 588, in generate_gn_config
    subprocess.check_call(gen_args, cwd=srcdir, stderr=subprocess.STDOUT)
  File "/usr/local/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/local/bin/gn', 'gen', 'objdir/dom/media/webrtc/third_party_build/../../../../third_party/libwebrtc/webrtc/gn-output', '--args=is_debug=false target_os="freebsd" host_cpu="x64" target_cpu="x64"', '--ide=json']' returned non-zero exit status 1.
Type: task → defect
Flags: needinfo?(jbeich)
Keywords: regression
Regressed by: 1672989
Has Regression Range: --- → yes

Martin, did you patch moz.build manually instead of going through GnConfigGen + GnMozbuildWriter?

$ fgrep pipewire dom/media/webrtc/third_party_build/gn-configs/*linux.json || echo Exit $?
Exit 1

$ fgrep video_capture_linux dom/media/webrtc/third_party_build/gn-configs/*linux.json
dom/media/webrtc/third_party_build/gn-configs/arm64_False_arm64_linux.json:                "//modules/video_capture/linux/video_capture_linux.cc",
dom/media/webrtc/third_party_build/gn-configs/arm64_False_arm64_linux.json:                "//modules/video_capture/linux/video_capture_linux.h"
dom/media/webrtc/third_party_build/gn-configs/arm64_True_arm64_linux.json:                "//modules/video_capture/linux/video_capture_linux.cc",
[...]
Flags: needinfo?(stransky)

(In reply to Jan Beich from comment #2)

Martin, did you patch moz.build manually instead of going through GnConfigGen + GnMozbuildWriter?

Yes, you're right, I just edited the moz.build files, I didn't know about any other process here.

Flags: needinfo?(stransky)
Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
Depends on: 1677715

I'm partially to blame, during review I saw that Martin's patches changed both BUILD.gn files and the generated moz.build files, and didn't look closely enough at the moz.build files to realize they were not generated from the BUILD.gn file. I've filed Bug 1677715 to fix things up.

Fwiw careful with enabling pipewire inconditionally on all BSDs, there's no pipewire port yet on OpenBSD

Landry, not a problem as Firefox uses lazy bindings with bundled headers, see bug 1672945. And pipewire is not used on X11.
https://searchfox.org/mozilla-central/rev/7b40f0b246ad/third_party/libwebrtc/webrtc/modules/desktop_capture/screen_capturer_linux.cc#27-31

Looks cleaner than Linux version because I didn't exclude Tier2 architectures.

(In reply to Jan Beich from comment #6)

Landry, not a problem as Firefox uses lazy bindings with bundled headers, see bug 1672945. And pipewire is not used on X11.
https://searchfox.org/mozilla-central/rev/7b40f0b246ad/third_party/libwebrtc/webrtc/modules/desktop_capture/screen_capturer_linux.cc#27-31

PipeWire is used on X11 when Wayland session is active, i.e. Firefox is running on XWayland. It's because screensharing does not work on Wayland session without pipewire.

openbsd doesnt have wayland either anyway (yet? afaik nobody is working on it) - and screen sharing is broken with pledge/unveil since it relies on shm which isnt allowed by our sandboxing... so one needs to disable sandboxing at runtime to use screen sharing via X11.

Duplicate of this bug: 1840286
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: