Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(capture): null-check hw buffer inputs, add libglvnd to the rpath
Etienne Lescota81cdba7d5ff
diff --git a/electron/native/pipewire-capture/src/encoder.rs b/electron/native/pipewire-capture/src/encoder.rsindex 0d66f5c90..680b27dde 100644--- a/electron/native/pipewire-capture/src/encoder.rs+++ b/electron/native/pipewire-capture/src/encoder.rs@@ -381,8 +381,20 @@ impl VideoEncoder {// encoder must consume from THAT pool, so take references to it instead of// creating a second, incompatible one. See `open_importing`.if let Some((device, frames_ctx)) = external {+ // The guard belongs on the INPUTS, before the refs are taken:+ // av_buffer_ref dereferences its argument (`*ret = *buf`), so a null+ // one faults inside ffmpeg instead of coming back as a null return+ // value the old check could inspect. And null IS reachable here --+ // `DmabufImporter::output_frames_ctx` is av_buffersink_get_hw_frames_ctx,+ // which returns NULL whenever the sink's input link carries no hw+ // frames context.+ if device.is_null() || frames_ctx.is_null() {+ return Err("av_buffer_ref on the shared VAAPI context returned null".to_owned());+ }self.hw_device = ff::av_buffer_ref(device);self.hw_frames = ff::av_buffer_ref(frames_ctx);+ // The results still get checked: av_buffer_ref allocates, and the+ // hw_frames_ctx ref below would dereference whatever it handed back.if self.hw_device.is_null() || self.hw_frames.is_null() {return Err("av_buffer_ref on the shared VAAPI context returned null".to_owned());}diff --git a/nix/pipewire-helper.nix b/nix/pipewire-helper.nixindex 953171c94..61268397a 100644--- a/nix/pipewire-helper.nix+++ b/nix/pipewire-helper.nix@@ -22,6 +22,7 @@pkg-config,patchelfUnstable,pipewire,+ libglvnd,}:let@@ -92,6 +93,17 @@ rustPlatform.buildRustPackage {# loader in compositor-view.nix: an soname reached by dlopen is invisible to the# linker and has to be added deliberately.#+ # libglvnd is here for the same reason and needs no build dependency either:+ # csrc/dmabuf_modifiers.c spells out the handful of EGL types it uses rather+ # than including <EGL/egl.h>, and reaches the entry points through+ # `dlopen("libEGL.so.1")` + dlsym. Without the RPATH entry that dlopen fails,+ # the modifier query returns nothing, and the format offer degrades to+ # LINEAR/INVALID -- so a tiled compositor buffer, the common case on+ # AMD/mutter, negotiates as shm instead of dmabuf and the zero-copy path is+ # lost with nothing in any log to say so. libglvnd is the dispatch library+ # only; the vendor ICD stays the host's job via /run/opengl-driver, exactly as+ # the Vulkan loader leaves it in compositor-view.nix.+ ## --force-rpath because build.rs passes -Wl,--disable-new-dtags on purpose: it# wants DT_RPATH rather than DT_RUNPATH, so that the entries apply to the# transitive ffmpeg libraries too. patchelf defaults to writing DT_RUNPATH,@@ -111,7 +123,12 @@ rustPlatform.buildRustPackage {# entry survives. dontPatchELF would also work and is worse: it disables the# shrink for every output, to fix one entry.postFixup = ''- patchelf --force-rpath --add-rpath "${lib.makeLibraryPath [ pipewire ]}" \+ patchelf --force-rpath --add-rpath "${+ lib.makeLibraryPath [+ pipewire+ libglvnd+ ]+ }" \"$out/bin/openscreen-pipewire-helper"'';