Skip to content

[WebGPU] Fix UI jank caused by compositor starvation in batched dispatch#19418

Open
ssam18 wants to merge 2 commits intoapache:mainfrom
ssam18:main
Open

[WebGPU] Fix UI jank caused by compositor starvation in batched dispatch#19418
ssam18 wants to merge 2 commits intoapache:mainfrom
ssam18:main

Conversation

@ssam18
Copy link
Copy Markdown

@ssam18 ssam18 commented Apr 18, 2026

Batching all dispatches into a single command buffer (introduced in #18871) blocks the browser compositor from interleaving its rendering work, causing visible frame drops and laggy scrolling during LLM inference. This adds a maxDispatchesPerFlush field (default 32) to WebGPUContext that flushes the encoder periodically, giving the compositor regular breathing room while preserving most of the batching throughput gains. Setting it to 0 restores the old per-dispatch behavior. Fixes #19342

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a maxDispatchesPerFlush property to the WebGPUContext to enable periodic command flushing during dispatches. A review comment points out a logic discrepancy where setting the value to 0 results in unlimited batching rather than the intended per-dispatch flushing, and provides a suggestion to correct the conditional check.

Comment thread web/src/webgpu.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] [Web] Batched WebGPU dispatch (#18871) causes UI jank from GPU compositor starvation

1 participant