Skip to content

WebGPURenderer: Ensure valid state in compileAsync(). - #34506

Open
Mugen87 wants to merge 1 commit into
mrdoob:devfrom
Mugen87:dev4
Open

WebGPURenderer: Ensure valid state in compileAsync().#34506
Mugen87 wants to merge 1 commit into
mrdoob:devfrom
Mugen87:dev4

Conversation

@Mugen87

@Mugen87 Mugen87 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Related issue: #32984

Description

As pointed out in #34481 (comment), compileAsync() does not guarantee to operate under the correct renderer state.

compileAsync() never set up the renderer state a normal render has, e.g. the internal framebuffer target, so properties like currentSamples were evaluated wrongly during pre-compilation. This can lead to runtime errors or unusable pre-compilations. The state can't simply be set once because compileAsync() yields control back to the event loop and frames rendered in the meantime are not allowed to work under this state.

The idea of this PR is to track the renderer state compileAsync() relies on. Every time the method continues it sets this state, when the method yields control to the event loop it restores it. The new methods _beginPreCompile() and _finishPreCompile() are doing this. They must be called at different locations in pairs so the state is valid.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
Core 389.18
102.13
389.18
102.13
+0 B
+0 B
WebGL 372.69
87.97
372.69
87.97
+0 B
+0 B
WebGPU 709.07
195.28
709.71
195.5
+635 B
+224 B
WebGPU Nodes 707.06
194.96
707.69
195.19
+635 B
+230 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 516.1
124.92
516.1
124.92
+0 B
+0 B
WebGPU 762.77
204.86
763.41
205.07
+635 B
+215 B
WebGPU Nodes 711.43
192.13
712.07
192.34
+635 B
+213 B

@Mugen87 Mugen87 added this to the r187 milestone Sep 8, 2026
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.

1 participant