Don't leak

This commit is contained in:
Andras Schmelczer 2026-06-10 21:38:08 +01:00
parent 4a6a25a081
commit 54cbaf3a12
2 changed files with 10 additions and 1 deletions

View file

@ -1,5 +1,6 @@
import { ReadonlyVec2 } from 'gl-matrix'; import { ReadonlyVec2 } from 'gl-matrix';
import { DefaultFrameBuffer } from '../../graphics-library/frame-buffer/default-frame-buffer'; import { DefaultFrameBuffer } from '../../graphics-library/frame-buffer/default-frame-buffer';
import { tryEnableExtension } from '../../graphics-library/helper/enable-extension';
import { ParallelCompiler } from '../../graphics-library/parallel-compiler'; import { ParallelCompiler } from '../../graphics-library/parallel-compiler';
import { FragmentShaderOnlyProgram } from '../../graphics-library/program/fragment-shader-only-program'; import { FragmentShaderOnlyProgram } from '../../graphics-library/program/fragment-shader-only-program';
import { getUniversalRenderingContext } from '../../graphics-library/universal-rendering-context'; import { getUniversalRenderingContext } from '../../graphics-library/universal-rendering-context';
@ -48,5 +49,12 @@ export const renderNoise = async (
frameBuffer.destroy(); frameBuffer.destroy();
program.destroy(); program.destroy();
return canvas; const result = document.createElement('canvas');
result.width = canvas.width;
result.height = canvas.height;
result.getContext('2d')!.drawImage(canvas, 0, 0);
tryEnableExtension(gl, 'WEBGL_lose_context')?.loseContext();
return result;
}; };

View file

@ -194,6 +194,7 @@ export class RendererImplementation implements Renderer {
private setTextures(v: { [textureName: string]: TexImageSource | TextureWithOptions }) { private setTextures(v: { [textureName: string]: TexImageSource | TextureWithOptions }) {
this.textures.forEach((t) => t.destroy()); this.textures.forEach((t) => t.destroy());
this.textures = []; this.textures = [];
this.uniformsProvider.textures = {};
let id = 3; let id = 3;
for (const key in v) { for (const key in v) {