# TypeError: Cannot read property 'canvas' of null

**URL:** <https://devforum.zoom.us/t/typeerror-cannot-read-property-canvas-of-null/57185>\
**Category:** Web\
**Created:** [September 9, 2021, 2:28pm UTC](https://devforum.zoom.us/t/typeerror-cannot-read-property-canvas-of-null/57185 "2021-09-09T14:28:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mitesh.gandhi](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/mitesh.gandhi/32/3954_2.png) [@mitesh.gandhi](https://devforum.zoom.us/u/mitesh.gandhi)\
**Post date:** [September 9, 2021, 2:28pm UTC](https://devforum.zoom.us/t/typeerror-cannot-read-property-canvas-of-null/57185/1 "2021-09-09T14:28:00Z")

</div>

**Description**  
When a participant tries to share the screen by executing the below code, it throws error :“Cannot read property ‘canvas’ of null”.

```auto
  async shareScreen() {
     const canvas = document.getElementById('videoCanvas');
     await stream.startShareScreen(canvas);
  }

```

I have a “‘active-share-change’” listener that listens to the user who starts sharing the screen by calling startShareScreen.

```auto
client.on('active-share-change', async (payload) =>{
  const canvas = document.getElementById('videoCanvas');
   if(payload.state==='Active') {
       await stream.startShareView(canvas, payload.userId);
    } else if(payload.state==='Inactive'){
       await stream.stopShareView();
    }
}

```

**Note** : I am reusing this canvas for the video.

**Error**  
TypeError: Cannot read property ‘canvas’ of null

**Which Web Video SDK version?**  
SDK version : 1.1.4

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

- OS: Ubuntu 18.04.4 LTS
- Browser: Chrome
- Browser Version : Version 93.0.4577.63 (Official Build) (64-bit)

**Additional context**  
Please let me know if I need to do any setup or have to follow any steps to use the screen sharing api in our web based application.

---

<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:** [September 10, 2021, 2:27am UTC](https://devforum.zoom.us/t/typeerror-cannot-read-property-canvas-of-null/57185/2 "2021-09-10T02:27:21Z")

</div>

Hey @mitesh.gandhi

Thanks for your feedback.  
I saw you mentioned you were reusing the canvas for the video and screen share. Maybe that’s the problem. If the browser supports OffscreenCanvas, the canvas will be transferred to OffscreenCanvas, after that accessing the canvas will cause errors.

If your application needs to present video and screen sharing, 3 canvases are required. One for multiple videos, the other for receiving sharing, and the last for self sharing (If WebCodecs enabled, use video element instead of canvas element for self sharing).

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![mitesh.gandhi](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/mitesh.gandhi/32/3954_2.png) [@mitesh.gandhi](https://devforum.zoom.us/u/mitesh.gandhi)\
**Post date:** [September 10, 2021, 8:33pm UTC](https://devforum.zoom.us/t/typeerror-cannot-read-property-canvas-of-null/57185/3 "2021-09-10T20:33:55Z")

</div>

Hey @vic.yang

Thanks for the help, creating different canvases resolved my issue.

---

<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:** [September 15, 2021, 8:33pm UTC](https://devforum.zoom.us/t/typeerror-cannot-read-property-canvas-of-null/57185/4 "2021-09-15T20:33:10Z")

</div>

Happy to hear that resolved your issue! 🙂

Thanks,  
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:** [October 16, 2021, 6:33am UTC](https://devforum.zoom.us/t/typeerror-cannot-read-property-canvas-of-null/57185/5 "2021-10-16T06:33:16Z")

</div>

Closed on October 16, 2021, 6:33am UTC

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