# An exception occurred when you turned on screen sharing

**URL:** <https://devforum.zoom.us/t/an-exception-occurred-when-you-turned-on-screen-sharing/124295>\
**Category:** Web\
**Tags:** video-sdk\
**Created:** [January 10, 2025, 8:09am UTC](https://devforum.zoom.us/t/an-exception-occurred-when-you-turned-on-screen-sharing/124295 "2025-01-10T08:09:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![freda199594](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/freda199594/32/66057_2.png) [@freda199594](https://devforum.zoom.us/u/freda199594)\
**Post date:** [January 10, 2025, 8:09am UTC](https://devforum.zoom.us/t/an-exception-occurred-when-you-turned-on-screen-sharing/124295/1 "2025-01-10T08:09:29Z")

</div>

Hello, I’m using the video SDK (1.12.14) and sometimes I get the error “Uncaught (in promise) DOMException: HTMLCanvasElement.width setter: Cannot set width of placeholder canvas transferred to OffscreenCanvas” when turning on screen sharing. Causes sharing to fail. Not every time. What’s going on? What should I do?

By the way, the latest version of the SDK is a bit of a problem with Safari support, so I can’t upgrade to the latest.

Part of the code:

```auto
  <div class="column chat-shareContainer" id="chat-shareVideoContainer"> 
   <video id="chat-share-video" width="1920" height="1080"></video> 
   <span class="chatFullScreen"><span class="fa fa-expand"></span></span> 
  </div> 
  <div class="column chat-shareContainer" id="chat-shareCanvasContainer"> 
   <canvas id="chat-share-canvas" width="1920" height="1080"></canvas> 
   <span class="chatFullScreen"><span class="fa fa-expand"></span></span> 
  </div>

if (mediaStream.isStartShareScreenWithVideoElement()) {
    mediaStream.startShareScreen(document.querySelector('#chat-share-video')).then(() = >{
        // screen share successfully started and rendered
       ...
    }).
    catch((error) = >{
        console.log( error)
    })
} else {
    mediaStream.startShareScreen(document.querySelector('#chat-share-canvas')).then(() = >{
        // screen share successfully started and rendered
       ...
    }).
    catch((error) = >{
        console.log( error)
    })
}

```

Screenshot:

 ![error](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/3/d/3da0a18b3eda1f62590b7780b1046b70a48f872b.png)

Looking forward to hearing from you.  
Thank you.

---

<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:** [January 13, 2025, 9:49am UTC](https://devforum.zoom.us/t/an-exception-occurred-when-you-turned-on-screen-sharing/124295/2 "2025-01-13T09:49:10Z")

</div>

Hey @freda199594

Thanks for your feedback.

Could you check if the rendering of remote sharing content and self-sharing content is using **different** canvas elements?

If the same canvas is used, it would cause the issue described above.

The reason for this is that the remote and self sharing sources are different, and we handle them using different approaches. However, once a canvas is transferred to an `OffscreenCanvas`, it cannot be transferred again.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![freda199594](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/freda199594/32/66057_2.png) [@freda199594](https://devforum.zoom.us/u/freda199594)\
**Post date:** [January 14, 2025, 12:37am UTC](https://devforum.zoom.us/t/an-exception-occurred-when-you-turned-on-screen-sharing/124295/3 "2025-01-14T00:37:17Z")

</div>

Okay, I’ll try it after adjustment.  
Thank you

---

<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:** [February 13, 2025, 10:37am UTC](https://devforum.zoom.us/t/an-exception-occurred-when-you-turned-on-screen-sharing/124295/4 "2025-02-13T10:37:31Z")

</div>

Closed on February 13, 2025, 10:37am UTC

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