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

chromium: enable WebRTC screen sharing via PipeWire #26144

Closed
wants to merge 3 commits into from

Conversation

Logarithmus
Copy link
Contributor

@Logarithmus Logarithmus commented Nov 5, 2020

[ci skip]

Currently I'm investigating these stability issues with pipewire. It seems that pipewire is trying to use rtkit to make audio/video processing run in real time. Unfortunately, it fails to do so:

2020-11-16T03:49:59.73350 daemon.err: Nov 16 03:49:59 rtkit-daemon[3165]: Failed to make ourselves RT: Function not implemented
2020-11-16T03:49:59.73602 daemon.warn: Nov 16 03:49:59 rtkit-daemon[3165]: Warning: failed to read scheduler policy: Function not implemented
2020-11-16T03:49:59.73620 daemon.debug: Nov 16 03:49:59 rtkit-daemon[3165]: Supervising 0 threads of 0 processes of 1 users.
2020-11-16T03:49:59.73645 daemon.debug: Nov 16 03:49:59 rtkit-daemon[3165]: Supervising 0 threads of 0 processes of 1 users.
2020-11-16T03:49:59.74118 daemon.err: Nov 16 03:49:59 rtkit-daemon[3165]: Failed to make ourselves RT: Function not implemented

After a bit of searching, I've found these bugs:
https://bugzilla.redhat.com/show_bug.cgi?id=1229700
https://bugs.gentoo.org/show_bug.cgi?id=569546

I've built linux5.9 for x86_64 with CONFIG_RT_GROUP_SCHED disabled.
For some strange reason, nothing changed, the error persists. Luckily, screen sharing works without rtkit.
I guess that those rare issues with screen sharing, which were described above, may be caused by rtkit not working.

@Logarithmus Logarithmus changed the title chromium: enable chromium: enable WebRTC screen sharing via PipeWire Nov 5, 2020
@Logarithmus Logarithmus force-pushed the libpipewire02 branch 5 times, most recently from eb43afb to d494642 Compare November 11, 2020 03:02
@Logarithmus Logarithmus force-pushed the libpipewire02 branch 9 times, most recently from e91d2f9 to 6cadef1 Compare November 17, 2020 14:53
@Logarithmus Logarithmus marked this pull request as ready for review November 18, 2020 04:13
@Logarithmus
Copy link
Contributor Author

Logarithmus commented Nov 18, 2020

@ericonr @q66 @Duncaen, finally, this PR is ready for review.
Related PR by @absrd (xdg-desktop-portal-wlr): #23296

@Logarithmus Logarithmus changed the title chromium: enable WebRTC screen sharing via PipeWire chromium: update to 87.0.4280.66 & enable WebRTC screen sharing via PipeWire Nov 19, 2020
@Logarithmus Logarithmus changed the title chromium: update to 87.0.4280.66 & enable WebRTC screen sharing via PipeWire chromium: update to 87.0.4280.66 & enable WebRTC screen sharing via PipeWire by default Nov 19, 2020
@Logarithmus Logarithmus changed the title chromium: update to 87.0.4280.66 & enable WebRTC screen sharing via PipeWire by default chromium: enable WebRTC screen sharing via PipeWire Nov 19, 2020
@Logarithmus Logarithmus changed the title chromium: enable WebRTC screen sharing via PipeWire [ci skip] chromium: enable WebRTC screen sharing via PipeWire Nov 19, 2020
@Logarithmus Logarithmus changed the title [ci skip] chromium: enable WebRTC screen sharing via PipeWire [ci skip] chromium: update to 87.0.4280.66 & enable WebRTC screen sharing via PipeWire Nov 19, 2020
@Logarithmus Logarithmus force-pushed the libpipewire02 branch 2 times, most recently from 2d8d648 to 762ac69 Compare November 19, 2020 21:54
@Logarithmus Logarithmus changed the title [ci skip] chromium: update to 87.0.4280.66 & enable WebRTC screen sharing via PipeWire chromium: enable WebRTC screen sharing via PipeWire Nov 19, 2020
@Logarithmus
Copy link
Contributor Author

I hope this PR will ever be merged... I've spent so much time on it.
Enabling this compile option shouldn't be a problem, because there's a flag in chromium://flags to toggle PipeWire support.

Copy link
Contributor

@ifreund ifreund left a comment

Choose a reason for hiding this comment

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

libpipewire0.2 needs to appear in common/shlibs. Also, I'm getting the following error building chromium:

[16699/43513] CXX obj/third_party/webrtc/modules/audio_processing/vad/vad/voice_activity_detector.o
[16700/43513] STAMP obj/third_party/webrtc/modules/desktop_capture/desktop_capture_generic.inputdeps.stamp
[16701/43513] CXX obj/third_party/webrtc/modules/congestion_controller/goog_cc/estimators/bitrate_estimator.o
[16702/43513] CXX obj/third_party/webrtc/modules/desktop_capture/primitives/shared_desktop_frame.o
[16703/43513] CXX obj/third_party/webrtc/modules/desktop_capture/pipewire_stubs/pipewire_stubs.o
FAILED: obj/third_party/webrtc/modules/desktop_capture/pipewire_stubs/pipewire_stubs.o 
clang++ -MMD -MF obj/third_party/webrtc/modules/desktop_capture/pipewire_stubs/pipewire_stubs.o.d -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_OZONE=1 -DUSE_X11=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DCR_CLANG_REVISION=\"llvmorg-12-init-5035-gd0abc757-3\" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DWEBRTC_ENABLE_PROTOBUF=1 -DRTC_ENABLE_VP9 -DHAVE_SCTP -DENABLE_EXTERNAL_AUTH -DWEBRTC_USE_H264 -DHAVE_WEBRTC_VIDEO -DLOGGING_INSIDE_WEBRTC -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DWEBRTC_ENABLE_AVX2 -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -DWEBRTC_LINUX -DABSL_ALLOCATOR_NOTHROW=1 -DNO_MAIN_THREAD_WRAPPING -Igen/third_party/webrtc/modules/desktop_capture -I../.. -Igen -I../../third_party/perfetto/include -Igen/third_party/perfetto/build_config -Igen/third_party/perfetto -Igen/shim_headers/libevent_shim -I../../third_party/webrtc_overrides -I../../third_party/webrtc -Igen/third_party/webrtc -I../../third_party/abseil-cpp -I../../third_party/boringssl/src/include -I../../third_party/protobuf/src -Igen/protoc_out -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -funwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -mllvm -enable-dse-memoryssa=false -m64 -march=x86-64 -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -Xclang -fdebug-compilation-dir -Xclang . -no-canonical-prefixes -Wall -Wextra -Wimplicit-fallthrough -Wunreachable-code -Wthread-safety -Wextra-semi -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-psabi -Wno-ignored-pragma-optimize -Wno-implicit-int-float-conversion -Wno-final-dtor-non-final-class -Wno-builtin-assume-aligned-alignment -Wno-deprecated-copy -O2 -fno-ident -fdata-sections -ffunction-sections -fno-omit-frame-pointer -g0 -ftrivial-auto-var-init=pattern -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -std=c++14 -fno-trigraphs -Wno-trigraphs -fno-exceptions -fno-rtti -fvisibility-inlines-hidden     -c gen/third_party/webrtc/modules/desktop_capture/linux/pipewire_stubs.cc -o obj/third_party/webrtc/modules/desktop_capture/pipewire_stubs/pipewire_stubs.o
gen/third_party/webrtc/modules/desktop_capture/linux/pipewire_stubs.cc:18:10: fatal error: 'pipewire/pipewire.h' file not found
#include <pipewire/pipewire.h>
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
[16704/43513] CXX obj/third_party/webrtc/modules/congestion_controller/congestion_controller/receive_side_congestion_controller.o
[16705/43513] CXX obj/third_party/webrtc/modules/congestion_controller/goog_cc/alr_detector/alr_detector.o
[16706/43513] CXX obj/third_party/webrtc/modules/congestion_controller/goog_cc/estimators/acknowledged_bitrate_estimator_interface.o
[16707/43513] CXX obj/third_party/webrtc/modules/desktop_capture/desktop_capture_generic/desktop_capture_options.o
[16708/43513] CXX obj/third_party/webrtc/modules/desktop_capture/desktop_capture_generic/desktop_capturer.o
[16709/43513] CXX obj/third_party/webrtc/modules/desktop_capture/desktop_capture_generic/desktop_and_cursor_composer.o
[16710/43513] CXX obj/third_party/webrtc/modules/congestion_controller/goog_cc/goog_cc/goog_cc_network_control.o
[16711/43513] CXX obj/third_party/webrtc/modules/congestion_controller/rtp/control_handler/control_handler.o
[16712/43513] CXX obj/third_party/webrtc/modules/congestion_controller/rtp/transport_feedback/transport_feedback_adapter.o
ninja: build stopped: subcommand failed.
=> ERROR: chromium-87.0.4280.66_1: do_build: 'ninja -C out/Release ${makejobs} chrome chromedriver mksnapshot' exited with 1
=> ERROR:   in do_build() at srcpkgs/chromium/template:269

Didn't have time to look into what's causing it yet. I'm on x86_64 glibc for what it's worth.

@Logarithmus
Copy link
Contributor Author

@ifreund that's because for some strange reason chromium package doesn't depend on libpipewire0.2-devel, even though I've added it into the template's makedepends section. I had to build and install it manually. Possibly It's mandatory to add libpipewire0.2 into common/shlibs. Anyway, I've just added it and 'll re-package with this change and see where it goes.

@ericonr
Copy link
Member

ericonr commented Nov 21, 2020

Possibly It's mandatory to add libpipewire0.2 into common/shlibs

You may need to do this if you want the package to detect the libpipewire dependency, but it shouldn't make any difference for the header to be found.

@Logarithmus Logarithmus force-pushed the libpipewire02 branch 3 times, most recently from 72f4e7f to ef30986 Compare November 21, 2020 01:46
@Logarithmus
Copy link
Contributor Author

Logarithmus commented Nov 21, 2020

@ifreund OK, I've fixed libpipewire0.2's template, now headers should be visible. It was correct on my VPS and laptop, but not on GitHub.
@ericonr I've added libpipewire0.2 into common/shlibs. Unfortunately, chromium still doesn't depend on libpipewire0.2. That's because chromium's binary dlopens libpipewire, and thus libpipewire is missing in ldd /lib/chromium/chromium.
IMHO that's a bug in xbps. If this is intended behavior, then we should probably add notice about it to https://docs.voidlinux.org

@ericonr
Copy link
Member

ericonr commented Nov 21, 2020

That's because chromium's binary dlopens libpipewire, and libpipewire is missing in ldd /lib/chromium/chromium.
IMHO that's a bug in xbps.

That's all working as intended. Applications use dlopen exactly to allow for optional dependencies, and scanning a binary for what it does open will 1) be fragile and 2) remove the usefulness of dlopening in the first place.

@Logarithmus
Copy link
Contributor Author

Logarithmus commented Nov 21, 2020

That's because chromium's binary dlopens libpipewire, and libpipewire is missing in ldd /lib/chromium/chromium.
IMHO that's a bug in xbps.

That's all working as intended. Applications use dlopen exactly to allow for optional dependencies, and scanning a binary for what it does open will 1) be fragile and 2) remove the usefulness of dlopening in the first place.

OK, if I'll explicitly include libpipewire0.2 into depends section, in addition to makedepends, will it finally work?
IMHO the right solution to such problems is to implement the support for optional dependencies in xbps, like pacman does.
There's an issue about that void-linux/xbps#1, but unfortunately xbps isn't actively developed anymore (I guess that's related to Juan RP's departure).
UPD: Just seen your fairly recent PRs in xbps repo, OK, I was wrong about non-active development.
UPD 2: Seems that including libpipewire0.2 into depends section finally solve the issue! Pushed it

@ifreund
Copy link
Contributor

ifreund commented Nov 21, 2020

I still get the same error with the latest commit. I also don't see the include dir for pipewire in the clang++ command line flags, so it seems like pipewire's pkgconfig is not getting used for whatever reason.

@Logarithmus
Copy link
Contributor Author

@ifreund can I ask you to check if /usr/include/pipewire directory presents in libpipewire0.2-devel package? If it's called pipewire-0.2 instead, then please rebuild the package.

@ifreund
Copy link
Contributor

ifreund commented Nov 21, 2020

Looks like it's there, still get the same error building chromium though.

$ xls libpipewire0.2-devel
/usr/include/pipewire/array.h
/usr/include/pipewire/client.h
/usr/include/pipewire/command.h
/usr/include/pipewire/control.h
/usr/include/pipewire/core.h
/usr/include/pipewire/data-loop.h
/usr/include/pipewire/extensions/client-node.h
/usr/include/pipewire/extensions/protocol-native.h
/usr/include/pipewire/factory.h
/usr/include/pipewire/global.h
/usr/include/pipewire/interfaces.h
/usr/include/pipewire/introspect.h
/usr/include/pipewire/link.h
/usr/include/pipewire/log.h
/usr/include/pipewire/loop.h
/usr/include/pipewire/main-loop.h
/usr/include/pipewire/map.h
/usr/include/pipewire/mem.h
/usr/include/pipewire/module.h
/usr/include/pipewire/node.h
/usr/include/pipewire/pipewire.h
/usr/include/pipewire/port.h
/usr/include/pipewire/properties.h
/usr/include/pipewire/protocol.h
/usr/include/pipewire/proxy.h
/usr/include/pipewire/remote.h
/usr/include/pipewire/resource.h
/usr/include/pipewire/stream.h
/usr/include/pipewire/thread-loop.h
/usr/include/pipewire/type.h
/usr/include/pipewire/utils.h
/usr/include/pipewire/version.h
/usr/include/pipewire/work-queue.h
/usr/include/spa/buffer/buffer.h
/usr/include/spa/buffer/meta.h
/usr/include/spa/clock/clock.h
/usr/include/spa/graph/graph.h
/usr/include/spa/monitor/monitor.h
/usr/include/spa/node/command.h
/usr/include/spa/node/event.h
/usr/include/spa/node/io.h
/usr/include/spa/node/node.h
/usr/include/spa/param/audio/format-utils.h
/usr/include/spa/param/audio/format.h
/usr/include/spa/param/audio/raw-utils.h
/usr/include/spa/param/audio/raw.h
/usr/include/spa/param/buffers.h
/usr/include/spa/param/format-utils.h
/usr/include/spa/param/format.h
/usr/include/spa/param/io.h
/usr/include/spa/param/meta.h
/usr/include/spa/param/param.h
/usr/include/spa/param/props.h
/usr/include/spa/param/video/chroma.h
/usr/include/spa/param/video/color.h
/usr/include/spa/param/video/encoded.h
/usr/include/spa/param/video/format-utils.h
/usr/include/spa/param/video/format.h
/usr/include/spa/param/video/multiview.h
/usr/include/spa/param/video/raw-utils.h
/usr/include/spa/param/video/raw.h
/usr/include/spa/pod/builder.h
/usr/include/spa/pod/command.h
/usr/include/spa/pod/event.h
/usr/include/spa/pod/iter.h
/usr/include/spa/pod/parser.h
/usr/include/spa/pod/pod.h
/usr/include/spa/support/log-impl.h
/usr/include/spa/support/log.h
/usr/include/spa/support/loop.h
/usr/include/spa/support/plugin.h
/usr/include/spa/support/type-map-impl.h
/usr/include/spa/support/type-map.h
/usr/include/spa/utils/defs.h
/usr/include/spa/utils/dict.h
/usr/include/spa/utils/hook.h
/usr/include/spa/utils/list.h
/usr/include/spa/utils/ringbuffer.h
/usr/include/spa/utils/type.h
/usr/lib/pkgconfig/libpipewire-0.2.pc
/usr/lib/pkgconfig/libspa-0.1.pc
/usr/lib/libpipewire-0.2.so -> /usr/lib/libpipewire-0.2.so.1

@Logarithmus
Copy link
Contributor Author

Logarithmus commented Nov 21, 2020

Looks like it's there, still get the same error building chromium though.

$ xls libpipewire0.2-devel

I guess you have to rerun configure & build stages for chromium in order for it to see the headers.

@ifreund
Copy link
Contributor

ifreund commented Nov 21, 2020

I guess you have to rerun configure & build stages for chromium in order for it to see the headers.

Looks like you were right, after a git clean and several hours it finished building. I should have time to get xdpw/pipewire setup and give this a test later tonight or tomorrow.

@ifreund
Copy link
Contributor

ifreund commented Nov 22, 2020

Confirmed that this works with #23296 to screenshare on sway x86_64 glibc using the webrtc test page here: https://mozilla.github.io/webrtc-landing/gum_test.html

@Logarithmus
Copy link
Contributor Author

Finally, my changes have been merged (#27060)! Thanks to everyone who were involved.

@Logarithmus Logarithmus deleted the libpipewire02 branch December 13, 2020 21:43
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants