VideoContext icon indicating copy to clipboard operation
VideoContext copied to clipboard

transparent player, why is alpha set false, with no override

Open icyield opened this issue 6 years ago • 5 comments

I would like to play an alpha video on a background, but the VideoContext webglContextAttributes alpha Can't be overriden because it is copied last.

Why is this done? If I change it to true works as expected, giving transparent player.

=====================================

`_classCallCheck(this, VideoContext);

            this._canvas = canvas;
            this._endOnLastSourceEnd = endOnLastSourceEnd;

            this._gl = canvas.getContext("experimental-webgl", Object.assign({ preserveDrawingBuffer: true }, // can be overriden
            webglContextAttributes, { alpha: false // Can't be overriden because it is copied last
            }));`

icyield avatar Apr 17 '19 12:04 icyield

I assume it's set to false to help with performance.

However, I can't think of a reason why it shouldn't be overridable.

@gsouquet do you guys have any opinions on this?

PTaylour avatar Apr 18 '19 17:04 PTaylour

I remember seeing a comment from Matthew in the code

if (webglContextAttributes.alpha === true){
  console.error("webglContextAttributes.alpha must be false for correct opeation");
}

I assume it has to do with performance as you said but possible with fidelity of the output. With new APIs like MediaRecorder you could end up with a different output than what you have previewed in your browser.

This would need to be investigated a bit more. I think the default has to be alpha: false for sure. But I can't see major problems that would arise with letting developers override that

germain-gg avatar Apr 23 '19 07:04 germain-gg

Actually looking at #154 , it seems like having an alpha set to true could be a risk.

If we decide to make the canvas desynchronised we won't have the ability to stack elements over the VC canvas.

We could probably allow the user to make that override, but the question becomes, how do we now communicate that behaviour to the developers to avoid frustration and hours of debugging?

Check https://developers.google.com/web/updates/2019/05/desynchronized#alpha_channels

How do you think we should move this forward?

germain-gg avatar Nov 06 '19 13:11 germain-gg

The fact that alpha canvas might have some issues that make it more difficult to use is not really a reason to not allow users to override.

If this is really an issue then some code to catch an allowAlphaOverride in the context could be used. But you can't stop "frustration and hours of debugging" by not allowing something that a user requires.

var videoContextOptions = { endOnLastSourceEnd: true, webglContextAttributes: { preserveDrawingBuffer: true, allowAlphaOverride:true, alpha: true } };

icyield avatar Nov 07 '19 10:11 icyield

@icyield I believe I didn't explain myself correctly. We could probably allow an alpha override. However if we are going to allow that I believe we should think about how we can communicate the limitations this brings with the desynchronised rendering.

Maybe through documentation or maybe make the library check if anything is stacked above the canvas. Not sure

germain-gg avatar Nov 07 '19 11:11 germain-gg