# Cannot get context for html canvas element (want to add text etc)

**URL:** <https://devforum.zoom.us/t/cannot-get-context-for-html-canvas-element-want-to-add-text-etc/59679>\
**Category:** Web\
**Created:** [November 2, 2021, 10:53am UTC](https://devforum.zoom.us/t/cannot-get-context-for-html-canvas-element-want-to-add-text-etc/59679 "2021-11-02T10:53:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![simkin](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/simkin/32/31663_2.png) [@simkin](https://devforum.zoom.us/u/simkin)\
**Post date:** [November 2, 2021, 10:53am UTC](https://devforum.zoom.us/t/cannot-get-context-for-html-canvas-element-want-to-add-text-etc/59679/1 "2021-11-02T10:53:38Z")

</div>

**Description**

Is there a way I can access the context for the canvas that  
the Zoom SDK uses to render videos?

I am rendering on a canvas with the ID “video-canvas”  
I want to do something like

```auto
var c = document.getElementById("video-canvas");
var ctx = c.getContext("2d");

```

so i can add names to the video strings or perhaps draw  
boxes for users with disabled cameras.  
However, when I try the above, I get following error:

**Browser Console Error**  
Uncaught (in promise) DOMException: Failed to execute ‘getContext’ on ‘HTMLCanvasElement’: Cannot get context from a canvas that has transferred its control to offscreen.

**Which Web Video SDK version?**  
1.1.5

**Video SDK Code Snippets**

```auto
                            var c = document.getElementById("video-canvas");
                            var ctx = c.getContext("2d");
                            ctx.font = "10px Arial";
                            ctx.fillText("Test", 10, 10);

```

**To Reproduce(If applicable)**  
Steps to reproduce the behavior:

**Screenshots**  
If applicable, add screenshots to help explain your problem.

**Device (please complete the following information):**

- Device: Mac mini
- OS: macOS 11
- Browser: Chrome
- Browser Version 95

**Additional context**  
Add any other context about the problem here.

---

<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:** [November 3, 2021, 1:50am UTC](https://devforum.zoom.us/t/cannot-get-context-for-html-canvas-element-want-to-add-text-etc/59679/2 "2021-11-03T01:50:03Z")

</div>

Hey @simkin

Thanks for your feedback.

Canvas element used by Video SDK can not be reused in main thread, because it may be transferred to [OffscreenCanvas](https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas). You can use html element like `div` to overlap the drawing area on canvas as a workaround.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![simkin](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/simkin/32/31663_2.png) [@simkin](https://devforum.zoom.us/u/simkin)\
**Post date:** [November 8, 2021, 5:45am UTC](https://devforum.zoom.us/t/cannot-get-context-for-html-canvas-element-want-to-add-text-etc/59679/3 "2021-11-08T05:45:02Z")

</div>

Thank you Vic!  
I’m overlaying the canvas with other elements now and it works.

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [November 8, 2021, 6:06pm UTC](https://devforum.zoom.us/t/cannot-get-context-for-html-canvas-element-want-to-add-text-etc/59679/4 "2021-11-08T18:06:02Z")

</div>

Thanks for the solution Vic!

Happy to hear you got it working @simkin ! 🙂

-Tommy

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [December 9, 2021, 4:06am UTC](https://devforum.zoom.us/t/cannot-get-context-for-html-canvas-element-want-to-add-text-etc/59679/5 "2021-12-09T04:06:58Z")

</div>

Closed on December 9, 2021, 4:06am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
