An exception occurred when you turned on screen sharing

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:

  <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:

Looking forward to hearing from you.
Thank you.

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

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

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