Unable to Set Background Color of an HTMLCanvasElement

Description

I created an HTMLCanvasElement to render multiple videos on the canvas. I want to set the background color of the canvas element to be transparent, so I set the style backgroundColor to 'transparent', but it is not working on some browsers.

I tried to use the 2D context as suggested in (javascript - How to fill the whole canvas with specific color? - Stack Overflow) to set the canvas background, but it didn’t work. It threw the following error:

DOMException: Failed to execute 'getContext' on 'HTMLCanvasElement': Cannot get context from a canvas that has transferred its control to offscreen.

This also mentioned in this thread:

How can I fix this? Is there any way in VideoSDK that I can use to resolve this issue?

Video SDK version

1.11.10

Evident

In the image above, I tried to set the background color to ‘red’, but it didn’t work.

Devices:

  • MacMini M1:
    + Browser: Brave - Version 1.67.123 Chromium: 126.0.6478.126
  • Macbook Pro 13 inch:
    + Chrome

Hey @lmtruong1512

Thanks for your feedback.

The parts of the canvas where no video is rendered are transparent. Could you check if there is a black background set somewhere else?

Thanks
Vic

Hi Vic,

Thanks for your reply.

This issue only occurs on some devices, while others display the transparency as expected. I have checked and confirmed that no black background is set anywhere. I also tried hiding all other layers, but the canvas background remains black.

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