Camera won't initialize in WebCamTexture in Windows 11

Hello,

My webcam won’t work in Unity Player on Windows 11 when building to Windows / Mac OSx / Linux.

Set up: I have two webcams that work on Windows 10 in my Unity application for a WebCamTexture, a Logitech 1080 and a Logitech C615. On a fresh install of Windows 11 on a different machine, I am able to view both of these cameras using Microsoft’s native Camera app. I am able to view the 1080 in Logitech Capture. In Windows Privacy Settings, I have enabled my Unity program to have Camera access. I have removed McAfee that came with the computer and did not replace with anything, so Windows Defender was activated.

My symptoms are similar to https://discussions.unity.com/t/803283 (the light on my camera fades in, then goes abruptly off, then begins again, repeating every 1 second). While I am not explicitly using UWP, I wonder whether this is my issue behind the scenes: https://issuetracker.unity3d.com/issues/uwp-player-fails-to-play-webcamtexture-when-using-specific-webcam

Currently, I am testing in the compiled developmental build and no errors are being reported. I’m working on getting a development environment going on that machine (it was only supposed to be for demos), but I’m hoping there is something simple I’m missing since this does not seem to be a hot issue in the Windows forums. If there is something basic I’m missing (update beyond 2019.3.24 LTS, follow X tutorial, …) please help me out

Thanks! (edit, camera name)

Some additional tests. Disabled Windows Defender, no dice (didn't restart in between). Started Logitech Capture, camera was working, and then the WebCamTexture did not render when I opened my game (which is what happens when the resource is busy) so I know that is the resource in question (i.e. it isn't some other camera).

I'll note that this thread: https://discussions.unity.com/t/783130 indicates that Camera is a Universal Windows App and since my cameras work in that it is likely not a UWP problem. If anyone knows anything that will tell a webcam to shutdown, such that it then tries booting up again immediately, I'd love any pointers...

Hey,

Thanks for providing detailed info about the problem. Unfortunately I can't really say for certain what the issue is but multiple webcams have been problematic in the past; camera streaming is quite complex.

I suggest disabling one of the webcams within Device Manager. This will completely prevent Unity from "seeing" that device and will always use the other one. That might be enough to work around the problem. Also, could you see if it repros on a newer Unity release, e.g. latest 2022 LTS?

Regardless, please file a new bug so the issue can be investigated. I can't say if it'll get fixed or not, but we need to look into it at least.

+1 Im in the same situation, let me know if you find out anything.

We are trying to build using UWP right now instead of a regular windows build.

We also tried to disable all security features and looked into the Logitech companion app of the webcam to check for any security feature that could be enabled.

We are in 2021.3.16f1 what about you ?

Happy to see we are not alone in this pain

Just to be clear :

We are using Windows 10 and a Dell Ultra-Sharp Webcam and are facing the same issue of the camera trying to start in a loop and a black video feed.

We have no errors in the build logs.

Thanks

We ended up fixing the issue by making sure V-Sync is NOT set to dont sync. Its working for us with both sync on every v-blank or every second v-blank.

Maybe this could fix it for your you also

2 Likes

We are in 2021.3.24f1

FWIW, I am still building in Windows, not UWP. In Build Settings >> Player Settings >> Quality >> VSync Count we were building with "Every V Blank". Just tried "Every Second V Blank" as well as "Don't Sync" - no changes noted, but thanks, it was worth a shot.


I only have one camera connected, but to verify I don't have some virtual camera I'm unaware of, I used Logitech Capture to lock the camera, and then the app behaved as expected if there are no cameras available

In progress, creating minimum project and will post

I didn't mention b/c I felt like it sounded crazy, but the very first time, and then like the 20th time, the camera completely worked... but the other ~48 times it has had those exact symptoms. Relevant momentarily. Perhaps.

Well, in the process of creating a minimum repeatable bug using a new project, ... WebCamTexture worked.

I double checked my firewall, not the issue. Copied over all relevant code, not the issue. Started looking at build settings. Identical, until I looked at quality. The only difference? My project was, for whatever reason (I didn't know that setting was there until today, I probably started the project though using like a 2020 or 2019 version), set to Very Low for Quality under Build Settings >> Player Settings >> Quality >> Quality (all four were), whereas the new project was defaulted to Ultra (from left to right, Ultra, Very Low, High, Ultra)

When working in the minimum project, setting it from Ultra to Very Low caused it to take exactly one picture and permanently freeze, then going into the symptoms I have seen before. I am loading some substantial libraries (Mirror, PlayFab) in my real project so it probably never had a chance to grab the first frame. I only tested once, perhaps other tests would be no image like louistbmtl

When I recompiled with Ultra, it works using the process described up top (build on Windows 10, test on Windows 11). I had three successful tests in a row.

I suspect this is a two-part issue, one to do with upgrading editor versions and one to do with interactions between WebCamTexture and Quality.

I'm uploading a project, but min viable to duplicate:
1) New 2D Core project.
2) Add a Raw Image (this will add a Canvas)
3) Add a script to Raw Image containing

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class BugDemo : MonoBehaviour
{

    public RawImage rawimage;

    void Start()
    {       
        WebCamTexture webcamTexture = new WebCamTexture(1920, 1080, 30);
        rawimage.texture = webcamTexture;
        rawimage.material.mainTexture = webcamTexture;
        webcamTexture.Play();
    }

    void Update(){}
}

Don't forget to add the RawImage in the inspector. Probably don't need to specify any parameters in WebCamTexture either to duplicate, but I had them.

Then, build with Very Low quality, it won't work, build with Ultra quality, it works as expected.

Thanks everyone for your help! Bug report submitted. As soon as I see the bug populate on the bug tracker I'll add that below.

Thank you @Alphaeuz for the detailed info!

Could you also post a link to the bug ticket? I'll make sure this thread is linked to the ticket.

@timke

Here it is: https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-40113

Circling back, they were unable to duplicate, which doesn't surprise me. They thought it was camera specific, I wonder whether it is a very specific patch version of Windows... I remember Windows XP service pack 2 had an undocumented severe restriction on FireWire not in SP 1 or later versions of XP.

Regardless, the workaround worked, wouldn't have found it w/o louistbmtl pointing me to that page.

Hi. I hope this thread is still active, because I have the same issue. But I think it may not be Unity's fault, since crash log file and memory dump say something interesting. Have a look at these:

9192467--1281209--upload_2023-8-3_23-27-6.png

9192467--1281212--upload_2023-8-3_23-27-27.png

9192467--1281206--upload_2023-8-3_23-24-38.png

@MoLavaie

This is a completely different issue; the OP involved WebCamTexture failing to initialize or simply not working while this is a hard crash.

I'm guessing VSFilter.dll is the DirectShow subtitle filter, in which case I'm not surprised it crashes. My hunch is you manually installed DirectX 9 which also installed this component*.* If this is the case, you'll need to either uninstall DirectX9 or alternatively unregister VSFilter.dll.

See this post for instructions on unregistering DLLs.

Oh yeah you're right.
Thank you @timke , you're a life savor. It's fixed now.

Btw, I guess it would mean players who run into the same bug have to unregister the dll file, right? Is there anything I can do about it on my side?

[quote]
Btw, I guess it would mean players who run into the same bug have to unregister the dll file, right?
[/quote]

That's a fair question, and I'm honestly not sure. I would hope we would've gotten a bug or something concerning this if it was a problem. The WindowsStandalonePlayer is much simpler than the Editor and might not execute the same code paths that caused this problem.

Well, if you're up for it, perhaps you can test this out! Try building the WindowsPlayer for your project and then reinstall or re-register the VSFilter.dll and see what happens. If it does crash then please file a bug so the dev team can investigate and possibly fix it.