From c2fd70ba90ff4fd2fd285588949ce331db8f6aed Mon Sep 17 00:00:00 2001 From: Popov72 Date: Tue, 4 Jul 2023 10:45:13 +0200 Subject: [PATCH] Fix crash when disposing effect or engine while shader compiled in parallel --- packages/dev/core/src/Engines/WebGL/webGLPipelineContext.ts | 4 ++++ packages/dev/core/src/Engines/thinEngine.ts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/packages/dev/core/src/Engines/WebGL/webGLPipelineContext.ts b/packages/dev/core/src/Engines/WebGL/webGLPipelineContext.ts index e9626288767..88b27932dca 100644 --- a/packages/dev/core/src/Engines/WebGL/webGLPipelineContext.ts +++ b/packages/dev/core/src/Engines/WebGL/webGLPipelineContext.ts @@ -23,6 +23,9 @@ export class WebGLPipelineContext implements IPipelineContext { public programLinkError: Nullable = null; public programValidationError: Nullable = null; + /** @internal */ + public _isDisposed = false; + public get isAsync() { return this.isParallelCompiled; } @@ -90,6 +93,7 @@ export class WebGLPipelineContext implements IPipelineContext { **/ public dispose() { this._uniforms = {}; + this._isDisposed = true; } /** diff --git a/packages/dev/core/src/Engines/thinEngine.ts b/packages/dev/core/src/Engines/thinEngine.ts index 2ace45b261d..5f1835995a2 100644 --- a/packages/dev/core/src/Engines/thinEngine.ts +++ b/packages/dev/core/src/Engines/thinEngine.ts @@ -3134,6 +3134,9 @@ export class ThinEngine { */ public _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean { const webGLPipelineContext = pipelineContext as WebGLPipelineContext; + if (this._isDisposed || webGLPipelineContext._isDisposed) { + return false; + } if (this._gl.getProgramParameter(webGLPipelineContext.program!, this._caps.parallelShaderCompile!.COMPLETION_STATUS_KHR)) { this._finalizePipelineContext(webGLPipelineContext); return true;