How can I clean my renderer and render window

I am a developing a web app which has to generate lots of label widgets around a 3D model. I am only using a single fullScreenRenderer and a single render window yet I am still getting WARNING: Too many active WebGL contexts. Oldest context will be lost.. This happens after I call a certain number of label widgets, and despite creating a method which eliminates these label widgets from the view it’s still happening. Any ideas of what could be wrong here?

          document.getElementById('btnDel').addEventListener('click', () => {
            widgetManager.addWidget(labelWidget).reset()
            widgetManager.removeWidget(handle);
            svgCleanupCallbacks.get(handle);
            svgCleanupCallbacks.delete(handle);
            handleTextProps.delete(handle);
            handle = null;
})

Hi,
I don’t know what could cause WebGL contexts to be created but you can put a breakpoint at the only place in vtk.js where a WebGL context can be created: in Rendering/OpenGL/RenderWindow/index.js in get3DContext (line 301).

Sorry for the late response, already fixed the issue. Seems to be that accidentally I was actually generating and using new render windows for each interaction, causing the application to crash after breaking the WebGL context limit.

Nonetheless, my app still slows a lot after calling the labels multiple times, and even if I delete them from my renderWindow and they’re not showing,
it doesn’t seem to change unless I reload my browser window. Do you have any clue about what could be wrong here?