(not really pipewire itself but an interaction with wireplumber/libcamera/the kernel, but pipewire is what triggers the problem)

As seen in https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2669 and https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4115

The camera’s /dev/video file is kept open (without streaming), sadly causing the camera to be powered on what looks to be most devices. For some reason, this completely nullifies the soc power management on modern laptops and can result in increases from 3W to 8W at idle!

On Intel laptops it’s a bit easier to debug because you can see the Cstates in powertop not going low but it also wrecks AMD ones. Some laptops can reach lower cstates, but the camera module wastes a few W anyway.

I can’t believe this shipped in Ubuntu, Fedora etc without anyone noticing, and for so long. This bug is quite literally wasting GWh of power and destroys the user experience of distros in laptops.

If you have a laptop with a switch that detaches the camera from the usb bus you are probably out of the water, just plug it when you use it and the problem is sidestepped. Removing uvcvideo and modprobing it on demand can also work. Disabling the camera in Lenovo’s UEFI is what I did for a year until I finally found the issue on the tracker. Some laptops also seem to not be affected, but for me it happens to every machine I’ve tested.

Thanks to this comment for another workaround that tells wireplumber to ignore cameras. ~/.config/wireplumber/wireplumber.conf.d/10-disable-camera.conf

wireplumber.profiles = { main = { monitor.libcamera = disabled } }

Software that only captures cameras using pipewire is rare and this hasn’t given me any problem. This should probably be shipped by distros while the problem is sorted out.

Note that most laptops will have other problems stopping them from reaching deep cstates, borked pcie sd card readers, ancient ethernet nics that don’t support pcie sleep properly, outdated nvme firwmare… those are separate issues that most of the time can also be tackled with some dose of tlp, but it’s all for nothing if the usb camera is keeping the soc awake!

    • n2burns@lemmy.ca
      link
      fedilink
      arrow-up
      32
      ·
      3 months ago

      It also might not come on even for affected users. OP’s comment in the reddit post:

      From gathering info on their issue tracker, the act of opening the video file but not grab frames is some weird usecase that is acting in weird ways. Additionally, the indicator light is turned on by the uvcvideo driver in a lot of hardware (yes, an attacker can theoretically watch you without you noticing). A possible fix for this is would be in the kernel itself, which should basically ignore the fd being open and only truly act when frames are grabbed.

  • tiramichu@lemm.ee
    link
    fedilink
    arrow-up
    62
    arrow-down
    2
    ·
    edit-2
    3 months ago

    The number one thing I noticed after installing Linux on my old macbook was that the battery life was immediately halved.

    I totally expected that to happen, though, because my previous experience had always been that power management on Linux was kinda terrible.

    Time to try this out and see!

  • Mike1576218@lemmy.ml
    link
    fedilink
    arrow-up
    22
    ·
    3 months ago

    While I also noticed my webcam showing up with 3W in powertop and disabling the uvcvideo module removed that entry, it doesn’t affect the reported battery discharge rate at all.

    I can see the files being opened with lsof and not so with the workaround. But again the discharge rate doesn’t change at all …

    To me it seems the power consumption is misreported.

    • nyan@sh.itjust.works
      link
      fedilink
      arrow-up
      6
      arrow-down
      1
      ·
      3 months ago

      Well, you’re not affected by this specific bug, anyway. Whether you’re virtuous in other aspects of your life is beyond the knowledge of anyone here. 😜

  • CalcProgrammer1@lemmy.ml
    link
    fedilink
    arrow-up
    14
    ·
    3 months ago

    Maybe this explains why my webcam indicator is on when no applications are using it. It’s been confusing me for a while now. I’ve double checked anything that I expect to access it is not, and it doesn’t seem to be locked because opening it works, but it sometimes boots up woth the light on. I am using Arch with pipewire so I’ll check and see if this is what’s going on.

  • cygnus@lemmy.ca
    link
    fedilink
    arrow-up
    14
    ·
    3 months ago

    Hmm the process doesn’t seem to be running at all on my X1 Carbon Gen 9 running EndeavourOS.

  • Blaster M@lemmy.world
    link
    fedilink
    English
    arrow-up
    13
    ·
    3 months ago

    Meanwhile in Fedora KDE, I have the opposite problem… The system straight up ignores my monitor sleep settings, and something as quick as grabbing a water and coming back to everything in sleep mode on a desktop is kinda a problem when I am relying on the system not going sleep due to a running task.

    • ffhein@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      3 months ago

      Interesting… I’ve never had this issue in Fedora KDE, which I run on my PC, but exactly the same thing happens on my wife’s PC and the HTPC which both run Xubuntu. Tried setting screen saver, power save options and eventually even uninstalling the screensaver completely. At least in my case it’s caused by Xorg DPMS if I remember correctly. Fixed it a while ago but then it came back on one of the computers at some point. Check out https://wiki.archlinux.org/title/Display_Power_Management_Signaling if it could be the same for you.

    • Lem453@lemmy.ca
      link
      fedilink
      arrow-up
      2
      ·
      3 months ago

      Sleep mode seems to be working well for me on fedora atomic with kde (aurora).

      Deep sleep works well and can stay sleeping for days.

      Normally sleep rules are working well. The do not sleep toggle in the power menu also works to prevent it from sleeping.

      Only thing that doesn’t work is flatpak apps can’t prevent the system from sleeping, so watching a video, using Handbrake to encode etc will all just allow it to sleep if there is no physical input.

      I have a 2018 dell xps

    • boomzilla@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      Have you looked into the “Activity” settings within system settings already? When you click on the default activity there you should see the option “Automatically shutting down or sleeping”. I’m sure you already tinkered with the energy system-settings.

      • boomzilla@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        3 months ago

        Easy fix if nothing works. Find the specific pipewire-version that causes the webcam bug, compile and install it, possibly render your sound settings partially defunct on the way and hook up a webcam. Thank me later.

    • netvor@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      3 months ago

      Depends on your distribution. I guess most of them use pipewire nowadays, and the bug has not been fixed yet so… if you are using a common GNU/Linux distro, the bug is likely on your system.

      Does it affect you, well, from what I understood, as long as your system registers the camera and pipewire is running, your camera is going to waste energy regardless of whether it’s actively streaming video or not.

      From what I’ve understood there are several workarounds, each bad but in a different way:

      • Disabling pipewire is not a good universal solution since it would effectively disable all audio on your system.
      • Disabling the kernel driver for your camera would be a more precise workaround but it’s not simple: apart from knowing how to do – and undo – that, you would need to find out which driver it is, and that depends on your actual hardware. And of course, with the driver disabled you would not be able to use the camera, so depending on your situation this might only be viable if you were willing to go back and disable/enable the driver as you need.
      • Physically disconnecting the camera - with desktop computer with the camera connected using a cable; you could just unplug it and plug it back in when you need it. With laptops, this is generally not possible; some laptops do have switches which effectively do the same thing but from technical standpoint that switch is a liability and costs something so most main-stream laptops won’t have it.

      In either case, it’s also worth noting that whatever app you are using the camera with is likely to keep a “list of cameras” and some sort of memory of your last selection. In theory, disabling or enabling a camera should work fine, but it’s not uncommon that apps will have bugs when managing the list; for example an app might not “see” the camera being back on, etc. so if you are going to use any of the above you might need to get used to restarting an app from time to time.

      Assuming that eventually this bug is going to be fixed, the question of when it will be available for your system, again, depends on the distribution you are using. Many distributions have own public bug trackers so you could try and look it up and watch their ticket (in some cases, some distributions might even have fixes available sooner than the bug is fixed upstream, but I would not count on that), or you can try and talk to the community (look for an IRC/matrix channel, discord server, etc.)

    • Ransack@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      5
      arrow-down
      22
      ·
      3 months ago

      Has your battery life been about half of what it used to be after installing pipe wire?

      [Yes] [No]

        • Ransack@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          1
          arrow-down
          6
          ·
          3 months ago

          Hey not a problem dino, I get it your post is quite helpful.

          Now jog my memory, how did you help the person asking if they’re affected by this bug or not?

          The 13 others that have a problem with my question also chose to not offer anything useful for ops question.

          • dino@discuss.tchncs.de
            link
            fedilink
            English
            arrow-up
            4
            arrow-down
            1
            ·
            3 months ago

            First problem is, how would you know if your battery life has been halved? Are you keeping track of how long your battery lasts on a daily basis?

          • netvor@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            3 months ago

            Pipewire is not an app, it’s a system service. It’s not like people are going to say, “i’m gonna install pipewire” and then go install pipewire and also happen to have stats from before and after that installation.

            Most people who have pipewire have it either by having it already installed as part of the initial installation or part of some larger update, but in either case, they probably aren’t particularly aware of it, especially as long as things are functional.

            To answer the question whether it affects one’s system requires a different strategy than and likely a little bit of research.

            • Ransack@lemmy.dbzer0.com
              link
              fedilink
              arrow-up
              1
              ·
              3 months ago

              Thank you for the reply. You are correct, I understand it’s a system service and something that people wouldn’t really notice if it’s been updated or maybe their distro has recently migrated over from pulse audio. Hell maybe even unknowingly following some random guide while trying to do something or fix something. All that we know from OP is that they are asking how to tell if they are affected.

              My question was as basic and as generic as it could be. Has your battery life been quite poor as of late? As in have you had to plug in your system more throughout the day?

              Regardless of technical experience or aptitude most people would notice a change in the norm of using something they use daily. If they don’t, there wouldn’t be any questions and it would be the normal day to day.

              Now my thought process was to see what they said, yes or no for the battery life. And then to get more info to put together something they could follow and either confirm impact from the bug or not.

        • Ransack@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          1
          ·
          3 months ago

          Nice okay, alright so just wondering what distro you running with and what hardware do you have?

          We can break it down from there to see if you are being affected or not.

  • timestatic@feddit.org
    link
    fedilink
    arrow-up
    8
    ·
    3 months ago

    I hope this will help lenghten the battery life of my laptop. I use it for school and when I put it in Idle it still drains in like 8 hours or something really bad. I’ll try it out later and edit the comment to see what happened

  • KaRunChiy@kbin.run
    link
    fedilink
    arrow-up
    6
    ·
    3 months ago

    Meanwhile, I turned idle sleep off manually for both the webcam and audio chipset because they would either crash or flip out or pop when in use

  • TheFrogThatFlies@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    3 months ago

    I found this gitlab issue two days ago after I noticed that the video camera was always on in powertop. The workaround appeared to work for me and the reduction in power consumption was noticeable, but Cheese wasn’t able to find a camera afterwards. Didn’t test other software.

    Now, if I could just find a way of reducing the screen consumption…

  • Norah - She/They@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 months ago

    Does this affect desktops as well? At least it doesn’t affect my legion go. Side note, linux (specifically bazzite) runs better on this than Windows ever could.

      • Norah - She/They@lemmy.blahaj.zone
        link
        fedilink
        English
        arrow-up
        2
        ·
        3 months ago

        I got it with that in mind as an alternate to a Steam Deck. I like the higher-res display a lot. All the reviews I read rated it highly on hardware and terrible for software because of Windows. It told me I needed internet to finish setting up, so I didn’t even bother seeing for myself, just shut it down and formatted the drive!

        I can’t believe Lenovo are handing customers to Valve just to back Windows. Like, I’m not an elitist about this usually but Linux just trounces on handhelds. Bazzite is as polished as an OEM experience should be, they could jump on this. They’ve already said they want to make a gen two at some point in future.