-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Use case
Because browsers limit the number of active WebGL contexts, it's not a good idea for any app to create more than one of them, let alone an undefined number of them. Because the current renderer is wasteful with WebGL resources, any app that embeds any HTML elements inside a view can quickly exhaust the available web GL contexts, which can make this useful feature of flutter on web hard to use in practice.
Proposal
Don't create more than one WebGL context in the first place so that users don't bump up against these limits by creating additional layers. Here's an example of a javascript framework that virtualizes webGL contexts to accomplish this:
All of the WebGL rendering can be done with a single context, and then the buffers can be drawn to 2d canvas elements for each surface. While some browsers do limit the amount of canvas memory that apps can use, it's a lot harder to run out of 2d canvas memory than it is to burn through 8 WebGL contexts. This strategy would ensure that a single flutter app only ever uses a single webgl context and be a big improvement to engine reliability for scenarios where people need to mix and match flutter rendered layers with HTML layers.