Hello, I am making a sketch browser for myself using p5 instance mode.
The sketches seem to continue running after removing them from the DOM. which results in my CPU getting pinned…
relevant code is here:
const loadSketch = ({ sketch, name }, params) => {
console.log('loading sketch', name, params)
if (canvas.childNodes[0]) canvas.removeChild(canvas.childNodes[0])
new p5(p => sketch(p, params), 'canvas')
}
the sketches are just basic stuff of animating a bunch of circles on the screen. when i hit this function, it removes the old canvas from the dom and replaces it with the new one. it seems p5 still runs in the BG