From 24ec32028d17d0004775dcf56c03b86b2465f567 Mon Sep 17 00:00:00 2001 From: Charlie Ruan <53290280+CharlieFRuan@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:36:31 -0400 Subject: [PATCH] [WebGPU] Fix unexpected device lost error when intentional dispose --- web/src/runtime.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/src/runtime.ts b/web/src/runtime.ts index d71c98e7d1bc..e446c4dc4dfb 100644 --- a/web/src/runtime.ts +++ b/web/src/runtime.ts @@ -1122,7 +1122,7 @@ export class Instance implements Disposable { // ctx release goes back into lib. this.ctx.dispose(); this.lib.dispose(); - this.deviceLostIsError = true; + // Cannot set deviceLostIsError back to true here because GPUDevice.destroy() is asynchronous. } /** @@ -2122,6 +2122,7 @@ export class Instance implements Disposable { this.dispose(); } }); + this.deviceLostIsError = true; const webGPUContext = new WebGPUContext( this.memory, device