Using rgl
in knitr
, users can write documents that contain multiple WebGL scenes in separate displays. Each of those is created by creating a canvas, getting a WebGL context associated with it, and then doing a bunch of WebGL plotting.
Users can ask for an arbitrary number of displays in a single HTML page, and eventually they'll run out of contexts, and (in Firefox) the console will show
Exceeded 16 live WebGL contexts for this principal
and I'll get the WebGLcontextlost event. When you scroll the page, all the early displays are blank, only the later ones show up.
How do I ask to restore the ones that are currently showing in the window?
Edited to add: A variant on this question: how do I set a canvas to only attempt to draw itself when it has scrolled into view? In the typical case, only one or two contexts will be visible at a time, so it should be fine to draw both of them. But the code needs to be told when that happens.