# Expected to accept HTMLCanvasElement, but actual it is HTMLCanvasElement

**URL:** <https://devforum.zoom.us/t/expected-to-accept-htmlcanvaselement-but-actual-it-is-htmlcanvaselement/99746>\
**Category:** Video SDK\
**Created:** [December 7, 2023, 4:12pm UTC](https://devforum.zoom.us/t/expected-to-accept-htmlcanvaselement-but-actual-it-is-htmlcanvaselement/99746 "2023-12-07T16:12:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fides-it](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/fides-it/32/51395_2.png) [@fides-it](https://devforum.zoom.us/u/fides-it)\
**Post date:** [December 7, 2023, 4:12pm UTC](https://devforum.zoom.us/t/expected-to-accept-htmlcanvaselement-but-actual-it-is-htmlcanvaselement/99746/1 "2023-12-07T16:12:11Z")

</div>

I get the obscure error:

`Expected to accept HTMLCanvasElement, but actual it is HTMLCanvasElement`

when calling `stream.stopRenderVideo(..)`

the `renderVideo` & `adjustRenderedVideoPosition` work fine with the same canvas element. Is this due to polyfills or sth like that?

---

<div class="post-metadata">

**Author:** ![rehema.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/rehema.zoom/32/40323_2.png) [@rehema.zoom](https://devforum.zoom.us/u/rehema.zoom)\
**Post date:** [December 7, 2023, 4:15pm UTC](https://devforum.zoom.us/t/expected-to-accept-htmlcanvaselement-but-actual-it-is-htmlcanvaselement/99746/2 "2023-12-07T16:15:37Z")

</div>

Hi @fides-it ,

Could you share the code snippet where you’re calling `stream.stopRenderVideo()` & the other two listed functions?

Thanks,  
Rehema

---

<div class="post-metadata">

**Author:** ![fides-it](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/fides-it/32/51395_2.png) [@fides-it](https://devforum.zoom.us/u/fides-it)\
**Post date:** [December 7, 2023, 4:27pm UTC](https://devforum.zoom.us/t/expected-to-accept-htmlcanvaselement-but-actual-it-is-htmlcanvaselement/99746/3 "2023-12-07T16:27:28Z")

</div>

Hi Rehema,

sure:

```auto
async renderParticipant({participant, canvas, width, height, x, y, quality} : RenderParticipant): AsyncSessionResult {
    logZoom(`renderParticipant ${participant.name}`)
    return mapResultOrError(this.stream.renderVideo(canvas, participant.userId, width, height, x, y, this.convertQuality(quality)));
  }

  async adjustRenderedVideoPosition({participant, canvas, width, height, x, y} : RenderParticipant): AsyncSessionResult {
    logZoom('adjustRenderedVideoPosition')
    const result = await mapResult(this.stream.adjustRenderedVideoPosition(canvas, participant.userId, width, height, x, y));
    if (result.failure) {
      result.log()
    }
    return result
  }

  async stopRenderParticipant(payload : StopRenderParticipant): AsyncSessionResult {
    logZoom(`stopRenderParticipant ${payload.participant.name}`)
    const result = await mapResult(this.stream.stopRenderVideo(payload.canvas, payload.participant.userId))
    if (result.failure) {
      result.log()
    }
    return result
  }

```

---

<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:** [December 8, 2023, 1:49am UTC](https://devforum.zoom.us/t/expected-to-accept-htmlcanvaselement-but-actual-it-is-htmlcanvaselement/99746/4 "2023-12-08T01:49:55Z")

</div>

Hey @fides-it

Yes, we will check in the Video SDK if the canvas is indeed the original HTMLCanvasElement to ensure that the API works correctly.

In your code snippet, is there any difference between `payload.canvas` and the canvas used in `renderVideo` or `adjustRenderedVideoPosition`?

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![fides-it](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/fides-it/32/51395_2.png) [@fides-it](https://devforum.zoom.us/u/fides-it)\
**Post date:** [December 8, 2023, 12:15pm UTC](https://devforum.zoom.us/t/expected-to-accept-htmlcanvaselement-but-actual-it-is-htmlcanvaselement/99746/5 "2023-12-08T12:15:36Z")

</div>

What I did is the following:

- keep a list of HtmlCanvasElement per user
- if a user needs to be rendered, get the canvas element from the list, or create a new one using document.createElement(‘canvas’), which is stored in the canvas-per-user list
- subsequent operations on the canvas (adjust/stop), always use the stored HtmlCanvasElement
