Sharing GL context (lots of different plots)
jlumsden-mts opened this issue · 5 comments
Hi there, first of all thanks for a great library, the performance is amazing.
We are running into an issue with creating lots of different WebGL plots on a single page in that we eventually run out of WebGL contexts (max 8 on mobile, 16 on desktop).
Have you considered a feature where multiple plots can be instantiated but share a single context?
This appears to be the approach taken for something like this:
https://twgljs.org/examples/itemlist.html
@jlumsden-mts Thanks! May I ask how many individual webglplot lines you draw on the screen?
I'd say 16 to 32 individual plots (8x4 layout) with one line each for a 4K screen or ultrawide is reasonable. We can't reach 16 at the moment as we have 2 contexts used in another component.
Even though the plot area may be relatively small it has been very useful for fast updates and panning on larger datasets to look at a particular range of time.
As these represent different variables and sources it doesn't make as much sense to have multiple lines on a single plot but it is something we should experiment with.
Ultimately if this is very difficult to achieve with the library then not a problem but I thought it was worth raising as an idea. Thanks for responding!
Okay I understand your issue. You have to plot everything in a single contex. You just need to do a linear mapping for each line you plot. I think I have already implemented linear mapping per line, let me check and make 2x2 demo.
The example is here. You have to play with line.offset
and line.scale
to put them in the desired location on the screen. I tested 16x16 on my QHD screen at 60 fps. The main performance limitation is the CPU regulating each line at every frame.
Thanks @danchitnis really appreciate your example, closing this out now