max-active-webgl-contexts question

1,181 views
Skip to first unread message

Bob Blaine

unread,
May 14, 2021, 3:20:59 PM5/14/21
to Graphics-dev
Hello,

I'm working on an application that uses WebGL for graphics. The application often runs into the limit of available WebGL contexts and I have to deal with webglcontextlost events by supporting another rendering system, which is costly. 

At some point, I'd like to switch to rendering in a single offscreen context, which I feel is the correct way to resolve this, but I've also run into issues with that, especially around SwiftShader.

I've noticed that more recent versions of Chromium have a startup option 'max-active-webgl-contexts' that I think allows you to change that limit. I was wondering why there originally was a limit and if there are any tradeoffs or risks to setting that number higher (50, 100, 200). 

Thanks in advance for your response.

Ken Russell

unread,
May 14, 2021, 5:36:02 PM5/14/21
to Bob Blaine, Graphics-dev
Hi Bob,

We've found on multiple platforms that if we allow the underlying graphics driver to run out of memory, it behaves poorly - rather than cooperatively signaling out-of-memory errors, it often crashes. For this reason we limit both the number of active WebGL contexts as well as the maximum back buffer size of each context, in particular to pass stressful WebGL conformance tests which exercise both of these limits.

The max-active-webgl-contexts flag was added on request from a customer. Feel free to use it for your development, but we don't have plans to raise this limit, so if you intend to ship your application broadly you should try to get under the limit.

As you mentioned, you can work around this by using one WebGL-rendered canvas that's not displayed (it doesn't need to be an OffscreenCanvas, but can be), and drawing it into multiple canvases with 2D rendering contexts.

-Ken


Bob Blaine

unread,
May 17, 2021, 2:06:24 PM5/17/21
to Graphics-dev, Kenneth Russell, Graphics-dev, Bob Blaine
Thanks, Ken.

I will follow up with my questions about using OffscreenCanvas and SwiftShader in another post.

-Bob

Reply all
Reply to author
Forward
0 new messages