# Render of Peer Video fails after repeat video call session

**URL:** <https://devforum.zoom.us/t/render-of-peer-video-fails-after-repeat-video-call-session/72275>\
**Category:** Video SDK\
**Created:** [July 15, 2022, 4:21am UTC](https://devforum.zoom.us/t/render-of-peer-video-fails-after-repeat-video-call-session/72275 "2022-07-15T04:21:00Z")\
**Posts on this page:** 10\
**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:** [July 15, 2022, 4:21am UTC](https://devforum.zoom.us/t/render-of-peer-video-fails-after-repeat-video-call-session/72275/1 "2022-07-15T04:21:00Z")

</div>

Hi,

(We are using Ionic VueJS)

We are struggling how to make the renderVideo **stable.**

On first session (video call), it will work perfectly. But after repeated calls, we encounter this error and then one side of the call; Peer video render will be blank and black.

Any help or suggestion is appreciated

Regards,

Neil Oswald

```auto
=== RENDER VIDEO ===
c56504b9-3903-45cd-8e4e-0b6305eb1e86:1 Uncaught TypeError: Cannot read properties of undefined (reading 'width')
    at f.JsMediaSDK_VideoRender_interval (c56504b9-3903-45cd-8e4e-0b6305eb1e86:1:181982)
f.JsMediaSDK_VideoRender_interval @ c56504b9-3903-45cd-8e4e-0b6305eb1e86:1
setInterval (async)
f.Start_Draw @ c56504b9-3903-45cd-8e4e-0b6305eb1e86:1
(anonymous) @ c56504b9-3903-45cd-8e4e-0b6305eb1e86:1
c56504b9-3903-45cd-8e4e-0b6305eb1e86:1 Uncaught TypeError: Cannot read properties of undefined (reading 'width')
    at f.JsMediaSDK_VideoRender_interval (c56504b9-3903-45cd-8e4e-0b6305eb1e86:1:181982)
f.JsMediaSDK_VideoRender_interval @ c56504b9-3903-45cd-8e4e-0b6305eb1e86:1
setInterval (async)
f.Start_Draw @ c56504b9-3903-45cd-8e4e-0b6305eb1e86:1
(anonymous) @ c56504b9-3903-45cd-8e4e-0b6305eb1e86:1
c56504b9-3903-45cd-8e4e-0b6305eb1e86:1 Uncaught TypeError: Cannot read properties of undefined (reading 'width')
    at f.JsMediaSDK_VideoRender_interval (c56504b9-3903-45cd-8e4e-0b6305eb1e86:1:181982)
f.JsMediaSDK_VideoRender_interval @ c56504b9-3903-45cd-8e4e-0b6305eb1e86:1
setInterval (async)
f.Start_Draw @ c56504b9-3903-45cd-8e4e-0b6305eb1e86:1
(anonymous) @ c56504b9-3903-45cd-8e4e-0b6305eb1e86:1
c56504b9-3903-45cd-8e4e-0b6305eb1e86:1 Uncaught TypeError: Cannot read properties of undefined (reading 'width')

```

This is our render code:

```auto
zoomClient.on(“peer-video-state-change”, async (payload) => {
        const { action, userId } = payload;
        console.log(
          “=== PEER VIDEO STATE CHANGE (action,peer,self)===“,
          action,
          userId,
          zoomClient.getCurrentUserInfo().userId,
          JSON.stringify(payload)
        );
        // default
        const width = 640;
        const height = 360;
        if (userId != zoomClient.getCurrentUserInfo().userId) {
          if (action === “Start”) {
            // this.toggleVideo(true, this.videoCanvas, userId, 1080, 540);
            console.log(“=== START RENDER VIDEO ===“, userId);
            // set video on from other party to ON
            this.isPeerVideoOn = true;
            try {
              console.log(“=== STARTING VIDEO ===“);
              if (!zoomStream.isCapturingVideo()) {
                // await zoomStream.startVideo({ videoElement: this.partyVideo });
                await zoomStream.startVideo({ videoElement: this.selfVideo });
              }
            } catch (e) {
              await zoomStream.startVideo();
              console.log(“=== START VIDEO ERROR ===“, e);
            }
            try {
              console.log(“=== RENDER VIDEO ===“);
              zoomStream.renderVideo(
                this.videoCanvas,
                userId,
                360,
                180,
                0,
                0,
                VideoQuality.Video_360P
              );
            } catch (e) {
              console.log(“=== RENDER VIDEO ERROR ===“, e);
            }
          } else if (action === “Stop”) {
            // this.toggleVideo(false, this.videoCanvas, userId, 1080, 540);
            console.log(
              “=== STOP RENDER VIDEO ===“,
              userId
            );
            // set video on from other party to ON
            this.isPeerVideoOn = false;
            try {
              zoomStream.stopRenderVideo(this.videoCanvas, userId);
              // await zoomStream.clearVideoCanvas(this.videoCanvas, “blue”);
              // await zoomStream.stopVideo()
            } catch (e) {
              console.log(
                “=== STOP RENDER VIDEO ERRROR === “,
                JSON.stringify(e)
              );
            }
          }
        }
      });

```

---

<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:** [July 15, 2022, 6:03am UTC](https://devforum.zoom.us/t/render-of-peer-video-fails-after-repeat-video-call-session/72275/2 "2022-07-15T06:03:01Z")

</div>

Hey @neiloswald

Thanks for your feedback.

In the post you mentioned

> On first session (video call), it will work perfectly. But after repeated calls, we encounter this error and then one side of the call; Peer video render will be blank and black.

Did you reuse the HTMLCanvasElement? In the Video SDK, the canvas will be transferred to the `OffscreenCanvas`, which can be used in the worker thread but can no longer be used in the main thread. Could you please check whether a new canvas is created when restarting a session?

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:** [July 15, 2022, 6:16am UTC](https://devforum.zoom.us/t/render-of-peer-video-fails-after-repeat-video-call-session/72275/3 "2022-07-15T06:16:46Z")

</div>

Thanks @vic.yang for a quick reply.

We are (re) using same HTMLCanvasElement.

I am not aware how to utilize the OffscreenCanvas. Is this in your documentation or sample apps?

Let us know (do you have guide) what is the best practice or pattern, of the Video Call. Do we need to initialize the Zoom Client every session?

Our application is basic, two party call. We have one main canvas to display the peer (remote) video. And another canvas (smaller inset) to render the Self video.

Thanks,

Neil Oswald

---

<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:** [July 15, 2022, 6:45am UTC](https://devforum.zoom.us/t/render-of-peer-video-fails-after-repeat-video-call-session/72275/4 "2022-07-15T06:45:34Z")

</div>

Hey @neiloswald

`OffscreenCanvas` is used inside the Video SDK. Here I just explained why the canvas element cannot be reused.

We suggest creating a new canvas element for the new session. It can be done by

```javascript
const newCanvas = canvas.cloneNode(true) ;
canvas.parentNode.replaceChild(newCanvas, canvas);

```

Or if you are using a framework, rerender the canvas, and make sure it is a new instance.

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:** [July 15, 2022, 7:10am UTC](https://devforum.zoom.us/t/render-of-peer-video-fails-after-repeat-video-call-session/72275/5 "2022-07-15T07:10:20Z")

</div>

Thank you @vic.yang we will explore this idea.

I will give feedback later.

---

<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:** [July 20, 2022, 6:36pm UTC](https://devforum.zoom.us/t/render-of-peer-video-fails-after-repeat-video-call-session/72275/6 "2022-07-20T18:36:03Z")

</div>

Hi @vic.yang

Good day.

Upon our initial test using newCanvas, it seems to be working and stable. We will do further testing and give you feedback.

Some observations though:

1. We were using two separate canvases to render the Peer and the Self View. For both we use your trick of using new canvas by cloning. But we encountered error something like “OffscreenCanvas index error”. The question , is this a good idea to use separate Canvases for the Self and Peer View considering the OffscreenCanvas matters.

2. We tried alternative of using one canvas to render both the Peer and Self Video AND by the way the Self Video overlaps (inset in lower left corner) with the Peer Video. This works however the Self Video is flickering all the time. The question is it possible to Overlap two videos in one Canvas. If not do you have any suggestion how to fix the flickering.

3. This seems to be redundant, but would like to get your opinion if using NodeJS / Ionic VueJS will not cause any major issues with Zoom Video SDK.

Thank you and I appreciate your support.

Neil Oswald

---

<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:** [July 26, 2022, 2:50am UTC](https://devforum.zoom.us/t/render-of-peer-video-fails-after-repeat-video-call-session/72275/7 "2022-07-26T02:50:26Z")

</div>

Hey @neiloswald

1. We recommend using a single canvas to serve the videos. But it requires [Cross-Origin Isolation](https://marketplace.zoom.us/docs/sdk/overview/websdk-gallery-view#implementing-credentialless-headers) on the Chromium browsers. Or enable `enforceMultipleVideos` in the `init` method.
2. The coordinates of the video can be specified, you can avoid the overlapping of two videos on the same canvas by calculation.
3. The Video SDK Web is a stack-less library. Choose your preferred UI framework to achieve your application.

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:** [July 28, 2022, 6:07am UTC](https://devforum.zoom.us/t/render-of-peer-video-fails-after-repeat-video-call-session/72275/8 "2022-07-28T06:07:59Z")

</div>

Thank you @vic.yang , we appreciate your support.

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [July 29, 2022, 9:37pm UTC](https://devforum.zoom.us/t/render-of-peer-video-fails-after-repeat-video-call-session/72275/9 "2022-07-29T21:37:43Z")

</div>

@neiloswald,

Glad @vic.yang insight was helpful. Thank you for posting in the Developer Forum.

---

<div class="post-metadata">

**Author:** ![downloadvideocapcut](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/downloadvideocapcut/32/49098_2.png) [@downloadvideocapcut](https://devforum.zoom.us/u/downloadvideocapcut)\
**Post date:** [June 4, 2023, 5:15am UTC](https://devforum.zoom.us/t/render-of-peer-video-fails-after-repeat-video-call-session/72275/10 "2023-06-04T05:15:59Z")

</div>

Thank you so much for helping us a lot. I was looking for the solution and got it from here[.](https://downloadvideocapcut.com/) Keep sharing amazing helpful content.
