Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

video-processor pipeline WebGL2 throws TypeError: can't access property "VERTEX_SHADER", gl is null #62

Open
5 tasks
thlee1122 opened this issue Jun 12, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@thlee1122
Copy link

I found a bug with WebGL2.
We recently upgraded the twilio-video-processor to the latest version, 2.0.0.
With the above-updated version, the WebGL2 pipeline video background blur functionality throws a TypeError: can't access property "VERTEX_SHADER", gl is null.

Below is the screenshot of the error:

image

Software versions:

  • Browser(s): Chrome (Version 114.0.5735.106)
  • Operating System: MacOS Ventura 13.4
  • twilio-video-processors.js: 2.0.0
  • twilio-video: 2.27.0
  • Third-party libraries (e.g., Angular, React, etc.): React
@thlee1122 thlee1122 added the bug Something isn't working label Jun 12, 2023
@alex93293
Copy link

I managed to find the root cause for this.

The default pipeline for the video processors is set to WebGL2, but the default processor options in twilio-video is set to { inputFrameBufferType: 'offscreencanvas', outputFrameBufferContextType: '2d' }, which are options for Canvas2D.

There are 2 ways to fix this:

  1. Pass WebGL2 options to track.addProcessor
track.addProcessor(processor, { inputFrameBufferType: "video", outputFrameBufferContextType: "webgl2" });
  1. Use Canvas2D pipeline*
processor = new VirtualBackgroundProcessor({
  pipeline: Pipeline.Canvas2D,
  ...options
});

I only managed to find this out by reading through the example.

*Canvas2D might not have full functionality with Safari - the Gaussian Blur didn't work for Safari 16.5.1 MacOS (haven't tested others)

@thlee1122
Copy link
Author

@alex93293 Thank you for this! This looks like a work around. Is the Twilio video processor team going to release an actual fix for this issue?

@lgenzelis
Copy link

Also worked for me! Does anyone knows which one should we be using? (webgl2 or canvas2d) I mean, since the defaults are different for @twilio/video-processors and twilio-video.

As a sidenote, I'm sticking with canvas2d for now, since webgl2 completely ignores the fitType option (and having a ImageFit.Contain is must for me).

@sajitkhadka
Copy link

sajitkhadka commented Jul 20, 2023

I had the same issue when I upgraded to v2.0.0.
The following seemed to work for me but it was painfully slow. so I ended up using Canvas2D pipeline option instead.
track.addProcessor(processor, { inputFrameBufferType: "video", outputFrameBufferContextType: "webgl2" });

Edit: It seems for higher resolution it is slow. width: 1280, height: 720,
if I change width:640, height:480. it seems to be okay.

@luisrivas
Copy link
Collaborator

Thanks for reporting this issue. We just released the v3.x of the video processors, where the Canvas2D and WebGL2 pipelines have been replaced by a hybrid pipeline. Please update to the most recent version. If you continue to experience any problems after upgrading, please let us know, and we will be happy help you further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants