# PHtread Not Defined Error on Video Start or Render

**URL:** <https://devforum.zoom.us/t/phtread-not-defined-error-on-video-start-or-render/74216>\
**Category:** Video SDK\
**Created:** [August 15, 2022, 8:11am UTC](https://devforum.zoom.us/t/phtread-not-defined-error-on-video-start-or-render/74216 "2022-08-15T08:11:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![neiloswald](https://avatars.discourse-cdn.com/v4/letter/n/919ad9/32.png) [@neiloswald](https://devforum.zoom.us/u/neiloswald)\
**Post date:** [August 15, 2022, 8:11am UTC](https://devforum.zoom.us/t/phtread-not-defined-error-on-video-start-or-render/74216/1 "2022-08-15T08:11:31Z")

</div>

Hi @vic.yang ,

Good day!

I consistently encountered this error, usually only on the “first” time I connect (accepted) a session, and when I activate the startVideo and renderVideo, causing a the Peer video not to display.

This is usually gone on my second and succeeding session.

Please have a look and let me know my best direction.

Regards,

```auto
eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1 Uncaught ReferenceError: PThread is not defined
    at Sr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:123315)
    at yr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:130967)
    at xr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:132211)
    at eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:162896
Sr @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
yr @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
xr @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
(anonymous) @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1 Uncaught ReferenceError: PThread is not defined
    at Sr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:123315)
    at yr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:130967)
    at xr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:132211)
    at eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:162896
Sr @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
yr @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
xr @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
(anonymous) @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1 Uncaught ReferenceError: PThread is not defined
    at Sr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:123315)
    at yr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:130967)
    at xr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:132211)
    at eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:162896
Sr @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
yr @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
xr @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
(anonymous) @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1 Uncaught ReferenceError: PThread is not defined
    at Sr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:123315)
    at yr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:130967)
    at xr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:132211)
    at eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:162896
Sr @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
yr @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
xr @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
(anonymous) @ eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1
eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1 Uncaught ReferenceError: PThread is not defined
    at Sr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:123315)
    at yr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:130967)
    at xr (eb544e03-5ca1-4a4f-9aee-bcbdd1657752:1:132211)

```

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [August 15, 2022, 8:24am UTC](https://devforum.zoom.us/t/phtread-not-defined-error-on-video-start-or-render/74216/2 "2022-08-15T08:24:31Z")

</div>

Hey @neiloswald

Thanks for your feedback.

Could you please provide the OS, browser, and version info?

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![neiloswald](https://avatars.discourse-cdn.com/v4/letter/n/919ad9/32.png) [@neiloswald](https://devforum.zoom.us/u/neiloswald)\
**Post date:** [August 15, 2022, 8:43am UTC](https://devforum.zoom.us/t/phtread-not-defined-error-on-video-start-or-render/74216/3 "2022-08-15T08:43:26Z")

</div>

Hi @vic.yang

I am using **Zoom Video SDK v1.4.0**.

```auto
CHROME VERSION
104.0.5112.79
OS VERSION
Mac OS X: 12.5.0
cpu_arch
arm64

```

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [August 15, 2022, 8:56am UTC](https://devforum.zoom.us/t/phtread-not-defined-error-on-video-start-or-render/74216/4 "2022-08-15T08:56:05Z")

</div>

Hey @neiloswald

Could you share some code snippets that lead to the error? It’s very helpful in helping us to troubleshoot the issue.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![neiloswald](https://avatars.discourse-cdn.com/v4/letter/n/919ad9/32.png) [@neiloswald](https://devforum.zoom.us/u/neiloswald)\
**Post date:** [August 15, 2022, 9:01am UTC](https://devforum.zoom.us/t/phtread-not-defined-error-on-video-start-or-render/74216/5 "2022-08-15T09:01:15Z")

</div>

Thank you @vic.yang for attending my issue!

Here is my start / render video:

```auto
   myStartVideo: async function (
      canvasElem: HTMLCanvasElement,
      videoElem: HTMLVideoElement
    ) {
      console.log("=== PLATFORMS ===", getPlatforms());
      if (zoomClient.getCurrentUserInfo().bVideoOn == true) {
        console.log("=== DO NOTHING! Video Already On === ");
        return;
      }

      this.selfViewType = "canvas";

      console.log("=== myStartVideo ===", this.selfViewType as string);

      const cameras = zoomStream.getCameraList();
      console.log("=== CAMERAS ===", JSON.stringify(cameras));
      console.log(
        "=== ACTIVE CAMERA ===",
        JSON.stringify(zoomStream.getActiveCamera())
      );

      console.log(
        "=== BROWSER SUPPORTS OffscreenCanvas ===",
        this.isSupportOffscreenCanvas
      );
      console.log(
        "=== ZOOM STREAM SUPPORTS MultipleVideos ===",
        zoomStream.isSupportMultipleVideos()
      );

      const isUsingVideoElementToStartVideo =
        this.isSupportOffscreenCanvas && !zoomStream.isSupportMultipleVideos();
      const isRenderingSingleVideoOnCanvas =
        !this.isSupportOffscreenCanvas && !zoomStream.isSupportMultipleVideos();

      // if (typeof isVideoOn !== "boolean" || prevIsSelfVideoOn === isVideoOn) {
      // return;
      // }

      const canvas = isRenderingSingleVideoOnCanvas
        ? this.selfCanvas
        : this.videoCanvas;

      if (isUsingVideoElementToStartVideo) {
        console.log("=== START VIDEO (USING VIDEO ELEMENT) ===");
        // this also renders the video
        videoElem.style.display = "block";
        videoElem.style.width = this.selfViewWidth.toString();
        // videoElem.style.left = "50%";
        await zoomStream.startVideo({ videoElement: videoElem });
      } else {
        console.log("=== START VIDEO ===");
        await zoomStream.startVideo().catch((error) => {
          console.error("=== START VIDEO (error) ===", JSON.stringify(error));
        });
        // render the video in canvas
        if (isRenderingSingleVideoOnCanvas) {
          // render self view in separate canvas
          const h = Math.round((this.canvasHeight * 0.2) / 1.2);
          const w = Math.round((h * 16) / 9);

          console.log("=== SELF VIEW SIZE (w,h)===", w, h, canvas);
          zoomStream.renderVideo(
            canvas,
            zoomClient.getCurrentUserInfo().userId,
            this.selfViewWidth,
            this.selfViewHeight,
            0,
            0,
            VideoQuality.Video_360P
          );
        } else {
          // render self view in main canvas
          const h = Math.round((this.canvasHeight * 0.2) / 1.2);
          const w = Math.round((h * 16) / 9);

          console.log("=== SELF VIEW SIZE (w,h)===", w, h, canvas);
          zoomStream.renderVideo(
            canvas,
            zoomClient.getCurrentUserInfo().userId,
            this.selfViewWidth,
            this.selfViewHeight,
            0,
            0,
            VideoQuality.Video_360P
          );
        }
      }

```

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [August 15, 2022, 10:17am UTC](https://devforum.zoom.us/t/phtread-not-defined-error-on-video-start-or-render/74216/6 "2022-08-15T10:17:27Z")

</div>

Hey @neiloswald

It seems the logic of the code is fine. Under what condition did you have the error? What is the result of `window.crossOriginIsolated` on the console?

By the way. Would you like to refer to our sample app? It’s a best practice of using the Video SDK Web.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![neiloswald](https://avatars.discourse-cdn.com/v4/letter/n/919ad9/32.png) [@neiloswald](https://devforum.zoom.us/u/neiloswald)\
**Post date:** [August 15, 2022, 1:14pm UTC](https://devforum.zoom.us/t/phtread-not-defined-error-on-video-start-or-render/74216/7 "2022-08-15T13:14:44Z")

</div>

HI @vic.yang ,

window.crossOriginIsolated is false running on my local(?) .

```auto
=== COMMAND CHANNEL === {"senderId":"33555456","senderName":"木下 早苗","text":"COMMAND_READY","timestamp":1660569081875,"msgid":"5549F5D2-940B-9804-E246-943C17C9EA8C"}
call.ts?99b2:505 === COMMAND CHANNEL (now) === READY
index.js?e1de:192 === DISPATCH myToggleVideo === canvas
call.ts?99b2:1200 === PLATFORMS === ['desktop']
call.ts?99b2:1206 === CROSS ORIGIN ISOLATED === false
call.ts?99b2:1210 === myStartVideo === canvas
call.ts?99b2:1213 === CAMERAS === [{"deviceId":"f734ec2fd1c5027f30ec46842b44cd79112f0b62194a2ea8a2624258fe96a18f","label":"FaceTime HD Camera"}]
call.ts?99b2:1214 === ACTIVE CAMERA === "default"
call.ts?99b2:1219 === BROWSER SUPPORTS OffscreenCanvas === true
call.ts?99b2:1223 === ZOOM STREAM SUPPORTS MultipleVideos === true
call.ts?99b2:1249 === START VIDEO ===
call.ts?99b2:1274 === SELF VIEW SIZE (w,h)=== 107 60 <canvas id=​"video-canvas" class=​"video-canvas" width=​"640" height=​"360">​

```

Yes, we tried checking your sample.app and adopted important points.

Please share the Sample App, in case you are referring to a different app.

Thanks.

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [August 16, 2022, 2:22am UTC](https://devforum.zoom.us/t/phtread-not-defined-error-on-video-start-or-render/74216/8 "2022-08-16T02:22:47Z")

</div>

Hey @neiloswald

Sorry for forgetting to add the Sample App link in the post. Here is the link: [videosdk-web-sample/purejs-demo at master · zoom/videosdk-web-sample · GitHub](https://github.com/zoom/videosdk-web-sample/tree/master/purejs-demo)

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![neiloswald](https://avatars.discourse-cdn.com/v4/letter/n/919ad9/32.png) [@neiloswald](https://devforum.zoom.us/u/neiloswald)\
**Post date:** [August 18, 2022, 10:59am UTC](https://devforum.zoom.us/t/phtread-not-defined-error-on-video-start-or-render/74216/9 "2022-08-18T10:59:27Z")

</div>

Hi @vic.yang,

We are actually utilizing this sample app. Thank you.

We will give further feedback, if we encountered major issues.

Regards,
