Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(linux-harness): wait for the camera feeder and Cap before reloading v4l2loopback
Richie McIlroycaeae3189134
diff --git a/scripts/linux-desktop-harness/x11-camera.sh b/scripts/linux-desktop-harness/x11-camera.shindex c04f19127..36f024b81 100755--- a/scripts/linux-desktop-harness/x11-camera.sh+++ b/scripts/linux-desktop-harness/x11-camera.sh@@ -20,8 +20,17 @@ case $format inmjpeg) encode=(-pix_fmt yuvj422p -c:v mjpeg -q:v 4) ;;*) echo "x11-camera: unknown CAMERA_FORMAT $format" >&2; exit 2 ;;esac-# A fresh device per run, so the format of an earlier run cannot stick.-sudo modprobe -r v4l2loopback 2>/dev/null+# A fresh device per run, so the format of an earlier run cannot stick. The+# previous run waited for its feeder and Cap to exit, but the module can stay+# busy for a moment after; never reuse a device that would not unload.+for _ in $(seq 20); do+ lsmod | grep -q '^v4l2loopback ' || break+ sudo modprobe -r v4l2loopback 2>/dev/null || sleep 0.5+done+if lsmod | grep -q '^v4l2loopback '; then+ echo "x11-camera: v4l2loopback is still in use and cannot be reloaded" >&2+ exit 2+fisudo modprobe v4l2loopback video_nr=42 card_label="Cap Test Camera" exclusive_caps=1 || exit 2# udev applies its own mode to the new node after modprobe returns; let it# finish first so it cannot reset the chmod below.@@ -34,7 +43,13 @@ unset WAYLAND_DISPLAYexport DISPLAY=:73 XDG_SESSION_TYPE=x11Xvfb "$DISPLAY" -screen 0 1920x1080x24 >/dev/null 2>&1 &xvfb=$!-trap 'kill $feeder $xvfb 2>/dev/null' EXIT+pid=""+# Wait for every child, so the next run finds the camera device closed.+cleanup() {+ kill $feeder $xvfb $pid 2>/dev/null+ wait $feeder $xvfb $pid 2>/dev/null+}+trap cleanup EXITsleep 2echo "feeder ($format): $(kill -0 $feeder 2>/dev/null && echo running || echo exited) $(head -c 300 "$out/feeder.log")" >>"$out/actions.log"