GL.counter is never reset, so context destroy/create cycle grows table size forever
Emscripten maintains a few JS tables to map from GLuint IDs (e.g. texture IDs) to the WebGL objects.
For example:
var GL = {
counter: 1,
buffers: [],
programs: [],
framebuffers: [],
renderbuffers: [],
textures: []
// ...
}These tables are indexed on the GLuint ID of the relevant object. The GLuint IDs are created by incrementing GL.counter whenever a new object is created. My problem is that I need to support the frequent destruction and recreation of GL contexts, but GL.counter is never reset. It only grows. This causes all of the tables inside the GL object to grow in size too.
I control all of the code inside my app, so I can say with 100% certainty when it is a safe time to reset the state of the GL object. Is there any way to do this right now?
If not, I am considering adding a function like
// psuedo-code
emscripten_webgl_reset_gl_state() {
GL = {
counter: 1,
buffers: [],
// ...
}
}Does this make sense?
Source: emscripten-core/emscripten