From 35d6be9f9bae4011f7e82b17bcb2d198e93ef10d Mon Sep 17 00:00:00 2001 From: Samaresh Kumar Singh Date: Fri, 17 Apr 2026 20:47:51 -0500 Subject: [PATCH 1/2] [WebGPU] Fix UI jank from compositor starvation by periodic command flush --- web/src/webgpu.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/src/webgpu.ts b/web/src/webgpu.ts index 199fa14235ee..0c8e67d8d86a 100644 --- a/web/src/webgpu.ts +++ b/web/src/webgpu.ts @@ -423,6 +423,7 @@ export class WebGPUContext { private uniformBufferPool: Array = []; private uniformBufferPoolSizes: Array = []; private pendingDispatchCount = 0; + maxDispatchesPerFlush = 32; // flags for debugging // stats of the runtime. // peak allocation @@ -799,6 +800,11 @@ export class WebGPUContext { compute.dispatchWorkgroups(workDim[0], workDim[1], workDim[2]); compute.end(); + if (this.maxDispatchesPerFlush > 0 && + this.pendingDispatchCount >= this.maxDispatchesPerFlush) { + this.flushCommands(); + } + // In debug mode, flush immediately so we can observe each submission. if (this.debugLogFinish) { this.flushCommands(); From d0a8e08de6bc7789812575bb1e618811e3e06925 Mon Sep 17 00:00:00 2001 From: Samaresh Kumar Singh Date: Fri, 17 Apr 2026 20:53:47 -0500 Subject: [PATCH 2/2] [WebGPU] Fix maxDispatchesPerFlush=0 to mean per-dispatch flush --- web/src/webgpu.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/webgpu.ts b/web/src/webgpu.ts index 0c8e67d8d86a..43fb7a3ed6e7 100644 --- a/web/src/webgpu.ts +++ b/web/src/webgpu.ts @@ -800,7 +800,7 @@ export class WebGPUContext { compute.dispatchWorkgroups(workDim[0], workDim[1], workDim[2]); compute.end(); - if (this.maxDispatchesPerFlush > 0 && + if (this.maxDispatchesPerFlush <= 0 || this.pendingDispatchCount >= this.maxDispatchesPerFlush) { this.flushCommands(); }