WebCamTexture nullpointerexception

I am trying to build an app which uses webcam.

I am applying the webCamTexture on a raw image.

I am trying to run this on webGL.

I have done all the fact checks and applied all the safety checks.

public RawImage rawimage;

void Start () {
        WebCamDevice backCameraDevice;
        Debug.Log("code started");
        WebCamDevice[] devices = WebCamTexture.devices;
        for (int i = 0; i < devices.Length; i++)

if (WebCamTexture.devices.Length == 0)
Debug.Log(“No devices cameras found”);

backCameraDevice = WebCamTexture.devices[0];

WebCamTexture webcamTexture = new WebCamTexture(;
webcamTexture.requestedWidth = 150;
webcamTexture.requestedHeight = 150;

rawimage.texture = webcamTexture;

rawimage.material.mainTexture = webcamTexture;

I am getting a null pointer exception when I try to run this.
Any help would be great. Please let me know how can I provide more information if needed

change the

WebCamDevice devices = WebCamTexture.devices;


WebCamDevice device = WebCamTexture.devices;