Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug WebCamTexture absurd CPU usage & visual bug on Linux

Discussion in 'Editor & General Support' started by Goulvennev, Aug 14, 2022.

  1. Goulvennev

    Goulvennev

    Joined:
    Aug 13, 2022
    Posts:
    2
    Hi everyone,

    In a recent project on Unity 2021.3.8f1 , I try to use `WebCamTexture`, and everything looks fine on macOS & IOs & Android. See the code below :

    Code (CSharp):
    1.     private void SetUpCamera()
    2.     {
    3.         WebCamDevice[] devices = WebCamTexture.devices;
    4.         Debug.Log(devices);
    5.         if(devices.Length == 0)
    6.         {
    7.             isCamAvailable = false;
    8.             return;
    9.         }
    10.         for(int i = 0; i < devices.Length; i++)
    11.         {
    12.             Debug.Log(devices[i].name + " - Front facing:" + devices[i].isFrontFacing);
    13.             devicesList.text = devicesList.text + "\n" + devices[i].name + " - Front facing:" + devices[i].isFrontFacing;
    14.             if (devices[i].isFrontFacing == true)
    15.             {
    16.                 camTexture = new WebCamTexture(devices[i].name, 500, 500);
    17.                 break;
    18.             }
    19.         }
    20.         camTexture.Play();
    21.         rawImageBackground.texture = camTexture;
    22.         isCamAvailable = true;
    23.     }
    24.  
    But on Arch Linux (5.18.16-arch1-1) with a Ryzen 9 5900X & a GTX 960 & 16Gb DDR4, I got an absurd CPU usage when the webcam (Logitech C920) is running. Even reaching 100% on a single core at one point :


    The webcam is running, but with a huge visual bug making it stretched and unusable :


    Thanks for any help or even lead on that subject :)
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,969
    Maybe file a bug report
     
  3. Goulvennev

    Goulvennev

    Joined:
    Aug 13, 2022
    Posts:
    2
    I just want to be sure that's not an error in my code / a bad performance practice :) Before filing a bug report.