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

Webcam from qubes-video-companion is not seen by firefox in fedora 41 #9639

Open
palainp opened this issue Dec 11, 2024 · 15 comments
Open

Webcam from qubes-video-companion is not seen by firefox in fedora 41 #9639

palainp opened this issue Dec 11, 2024 · 15 comments
Labels
affects-4.2 This issue affects Qubes OS 4.2. C: Qubes Video Companion needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. T: bug Type: bug report. A problem or defect resulting in unintended behavior in something that exists.

Comments

@palainp
Copy link

palainp commented Dec 11, 2024

How to file a helpful issue

Qubes OS release

Qubes release 4.2.3 (R4.2)

Brief summary

The webcam provided by qubes-video-companion is correctly seen with chromium-browser and cheese in an AppVM with fedora 41 as template. The webcam is not seen by firefox 133.0 in that AppVM, not present in the devices list (it was with firefox 132.0.1 and template fedora 39).

Steps to reproduce

In AppVM based on template fedora 41, install qubes-video-companion, start it, and try to use the webcam with cheese (it works), and firefox (it does not work).

Expected behavior

The camera is recognized and usable.

Actual behavior

The camera is absent from the available devices.

@palainp palainp added P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. T: bug Type: bug report. A problem or defect resulting in unintended behavior in something that exists. labels Dec 11, 2024
@Minimalist73
Copy link

I have the same problem on Fedora 41.
It seems to work with the original Firefox tarball, so I would guess the problem is with the Fedora packaged version.

@andrewdavidwong andrewdavidwong added needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. affects-4.2 This issue affects Qubes OS 4.2. C: Qubes Video Companion labels Dec 11, 2024
@Minimalist73
Copy link

Follow up on this:

The fedora packaged firefox sets the media.webrtc.camera.allow-pipewire pref to true. Changing it to false makes the virtual camera work again.
It works with the official Firefox binary because the pref is set to false instead.
So this is an upstream issue, not sure if Qubes can do anything about it.

@marmarek
Copy link
Member

Theoretically it should work just fine with pipewire too, I guess the issue is somewhere there.

@palainp
Copy link
Author

palainp commented Dec 14, 2024

I've just found that recent blog post (https://jgrulich.cz/2024/12/13/when-your-webcam-doesnt-work-solving-firefox-and-pipewire-issues/) and will try to dig the issue with it in mind soon.

@palainp
Copy link
Author

palainp commented Dec 15, 2024

Update: If I run systemctl --user restart pipewire wireplumber after starting qubes-video-companion (it does not work if pipewire is restarted before), the virtual camera is working even with the default firefox configuration from fedora, but I don't really understand what is going on underneath.

@marmarek
Copy link
Member

This suggests camera hotplug support in pipewire broken. Do you see anything interesting in journalctl --user output?

@Minimalist73
Copy link

Only restarting wireplumber after starting qubes-video-companion works for me.
This is the log I get when I restart the service:

wireplumber[2531]: wireplumber: stopped by signal: Terminated
systemd[737]: Stopping wireplumber.service - Multimedia Service Session Manager...
wireplumber[2531]: wireplumber: disconnected from pipewire
wireplumber[2531]: pw.core: 0x5b7b9410ef30: leaked proxy 0x5b7b941bc310 id:4
wireplumber[2531]: pw.core: 0x5b7b9410ef30: leaked proxy 0x5b7b9403ae20 id:5
pipewire[757]: pw.node: (qubes-sink-35) graph xrun inactive (0 suppressed)
pipewire[757]: pw.node: (-35) xrun state:0x7524fd411008 pending:0/0 s:335626207781 a:335626318965 f:335626360673 waiting:111184 process:41708 status:triggered
systemd[737]: Stopped wireplumber.service - Multimedia Service Session Manager.
systemd[737]: Started wireplumber.service - Multimedia Service Session Manager.
wireplumber[3107]: default: Failed to get percentage from UPower: org.freedesktop.DBus.Error.NameHasNoOwner
wireplumber[3107]: spa.bluez5: BlueZ system service is not available
wireplumber[3107]: [0:05:35.716754962] [3107]  INFO Camera camera_manager.cpp:325 libcamera v0.3.2
pipewire[757]: mod.qubes-audio: Underrun: asked to read 4096 bytes, but only 0 available
pipewire[757]: mod.qubes-audio: Underrun: asked to read 4096 bytes, but only 2048 available

wireplumber status before restart:

[user@disp7763 ~]$ wpctl status
PipeWire 'pipewire-0' [1.2.7, user@disp7763, cookie:28353246]
 └─ Clients:
        33. WirePlumber                         [1.2.7, user@disp7763, pid:806]
        34. pipewire                            [1.2.7, user@disp7763, pid:802]
        44. WirePlumber [export]                [1.2.7, user@disp7763, pid:806]
        58. wpctl                               [1.2.7, user@disp7763, pid:1399]

Audio
 ├─ Devices:
 │  
 ├─ Sinks:
 │  *   35. Qubes Virtual Audio Sink            [vol: 1.00]
 │  
 ├─ Sources:
 │  *   36. Qubes Virtual Audio Source          [vol: 1.00]
 │  
 ├─ Filters:
 │  
 └─ Streams:

Video
 ├─ Devices:
 │      57. Qubes Video Companion               [v4l2]
 │  
 ├─ Sinks:
 │  
 ├─ Sources:
 │  
 ├─ Filters:
 │  
 └─ Streams:

Settings
 └─ Default Configured Devices:

wireplumber status after restart:

PipeWire 'pipewire-0' [1.2.7, user@disp7763, cookie:28353246]
 └─ Clients:
        33. WirePlumber [export]                [1.2.7, user@disp7763, pid:1407]
        34. pipewire                            [1.2.7, user@disp7763, pid:802]
        44. WirePlumber                         [1.2.7, user@disp7763, pid:1407]
        60. wpctl                               [1.2.7, user@disp7763, pid:1431]

Audio
 ├─ Devices:
 │  
 ├─ Sinks:
 │  *   35. Qubes Virtual Audio Sink            [vol: 1.00]
 │  
 ├─ Sources:
 │  *   36. Qubes Virtual Audio Source          [vol: 1.00]
 │  
 ├─ Filters:
 │  
 └─ Streams:

Video
 ├─ Devices:
 │      37. Qubes Video Companion               [v4l2]
 │  
 ├─ Sinks:
 │  
 ├─ Sources:
 │  *   58. Qubes Video Companion (V4L2)       
 │  
 ├─ Filters:
 │  
 └─ Streams:

Settings
 └─ Default Configured Devices:

Qubes Video Companion (V4L2) appears in the video sources after restart.

@marmarek
Copy link
Member

But it sees it in "Devices" before restart already. Interesting

@Minimalist73
Copy link

Related issue maybe?
https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3659

Main answer to this is to use pipewire directly instead of v4l2loopback or to patch v4l2loopback.
I tried using the OBS virtual camera as said in the linked issue, and I have the exact same behavior (source appears after restarting wireplumber).

@marmarek
Copy link
Member

This looks plausible. Video companion outputing via pipewire definitely is an option, but since many apps (like Firefox in its default configuration) won't see it then, so I don't think it's something we can switch to by default just yet. I see there is a v4l2loopback workaround patch, I guess we can try this way for now.

@Minimalist73
Copy link

I built v4l2loopback with the specified patch and tried it on a fedora in-qube kernel and the source node is created correctly, but for some reason I still have to restart wireplumber for firefox to detect the virtual camera.

@DemiMarie
Copy link

What about using both PipeWire and v4l2loopback? That will result in two video sources being shown in some applications, but it shouldn’t matter which one the user picks.

Native PipeWire support is definitely the best option.

@smcgu
Copy link

smcgu commented Dec 16, 2024

I wonder if this is more widespread. I'm able to replicate the problem with Debian 12. Unfortunately, the above solution does not resolve the problem in Debian 12.

PipeWire 'pipewire-0' [0.3.65, user@debian-qube, cookie:3371461947]
 └─ Clients:
        32. xdg-desktop-portal                  [0.3.65, user@debian-qube, pid:1034]
        33. pipewire                            [0.3.65, user@debian-qube, pid:1372]
        34. WirePlumber                         [0.3.65, user@debian-qube, pid:1373]
        35. WirePlumber [export]                [0.3.65, user@debian-qube, pid:1373]
        50. Firefox                             [0.3.65, user@debian-qube, pid:1420]
        51. wpctl                               [0.3.65, user@debian-qube, pid:1834]

Audio
 ├─ Devices:
 │  
 ├─ Sinks:
 │  *   36. Qubes Virtual Audio Sink            [vol: 1.00]
 │  
 ├─ Sink endpoints:
 │  
 ├─ Sources:
 │  *   37. Qubes Virtual Audio Source          [vol: 1.00]
 │  
 ├─ Source endpoints:
 │  
 └─ Streams:

Video
 ├─ Devices:
 │      43. Qubes Video Companion               [v4l2]
 │  
 ├─ Sinks:
 │  
 ├─ Sink endpoints:
 │  
 ├─ Sources:
 │  
 ├─ Source endpoints:
 │  
 └─ Streams:

Settings
 └─ Default Configured Node Names:

Status of the wireplumber.service:

$ systemctl --user status wireplumber.service 
● wireplumber.service - Multimedia Service Session Manager
     Loaded: loaded (/usr/lib/systemd/user/wireplumber.service; disabled; preset: enabled)
     Active: active (running) since Mon 2024-12-16 14:00:35 PST; 43s ago
   Main PID: 1963 (wireplumber)
      Tasks: 7 (limit: 7680)
     Memory: 5.3M
        CPU: 69ms
     CGroup: /user.slice/user-1000.slice/[email protected]/session.slice/wireplumber.service
             └─1963 /usr/bin/wireplumber

Dec 16 14:00:35 debian-qube systemd[671]: Started wireplumber.service - Multimedia Service Session Manager.
Dec 16 14:00:35 debian-qube wireplumber[1963]: [0:07:40.268197232] [1963]  INFO Camera camera_manager.cpp:299 libcamera v0.0.3
Dec 16 14:00:35 debian-qube wireplumber[1963]: <WpPortalPermissionStorePlugin:0x55cc417fcce0> Failed to call Lookup: GDBus.Error:org.freedesktop.por>
Dec 16 14:00:35 debian-qube wireplumber[1963]: GetManagedObjects() failed: org.freedesktop.DBus.Error.NameHasNoOwner

@smcgu
Copy link

smcgu commented Dec 16, 2024

I had some other errors with the wireplumber.service that cleared by installing the following packages: pipewire-libcamera libcamera-ipa libcamera-tools libcamera-v4l2 (I think only the first two were necessary but I installed the -tools and -v4l2 to limit reboots.)

The errors were "libcamera not found" and "WARN IPAManager ipa_manager.cpp:154 No IPA found in...".

@Minimalist73
Copy link

I built v4l2loopback with the specified patch and tried it on a fedora in-qube kernel and the source node is created correctly, but for some reason I still have to restart wireplumber for firefox to detect the virtual camera.

I fixed this by moving the v4l2loopback modprobe command into the main() receiver.py function so that it is created the moment the gstreamer pipeline starts.
Doing it with setup.sh was setting the caps to 85200003 while the screen selection was shown and was changing to 85200001 after the selection was done. Pipewire/wireplumber were still seeing the previous caps, that's why a restart was necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.2 This issue affects Qubes OS 4.2. C: Qubes Video Companion needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. T: bug Type: bug report. A problem or defect resulting in unintended behavior in something that exists.
Projects
None yet
Development

No branches or pull requests

6 participants