[WebGPU] A render effect whose WGSL fails to compile never reaches onError: isReady() is true and every draw fails on an invalid pipeline

Open
#19,224 2 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@Popov72 is already working on this.

Since Dec 2, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript

Research direction

Start in Engines/webgpuEngine.pure.ts at _createPipelineStageDescriptor and _preparePipelineContextAsync, where the modules are created and the context is marked ready without reading getCompilationInfo(). Compare with the compute path in Engines/WebGPU/Extensions/engine.computeShader.pure.ts around line 410, which routes errors to ComputeEffect.onError. Done means a render effect with bad WGSL calls onError, getCompilationError() returns the messages, and isReady() stays false.

Written by the indexing model from the issue text.

Description

Repro

  • Bug repro on playground (open with ?webgpu, read the console)
  • Expected result: an effect whose WGSL shader fails to compile calls onError with the compiler's messages, getCompilationError() returns them, and the effect never reports ready, the same as GLSL on WebGL2 and ComputeEffect on WebGPU.
  • Current result on 9.37.2:
    • onError is never called.
    • executeWhenCompiled fires, isReady() is true, and getCompilationError() is "".
    • The fragment module's getCompilationInfo() does report error: unresolved call target 'mixx'.
    • Drawing with the effect then fails on every frame with uncaptured GPUValidationErrors: Error while parsing WGSL: :23:31 error: unresolved call target 'mixx', then [Invalid ShaderModule "fragment"], [Invalid RenderPipeline "RenderPipeline_bgra8unorm_depth24plus-stencil8_samples4_textureState0"] and [Invalid CommandBuffer …], 98 errors in 48 draws.

The playground builds an EffectWrapper whose WGSL fragment calls a function that does not exist (mixx). It passes onError, logs the state once executeWhenCompiled fires, reads getPipelineContext().stages.fragmentStage.module.getCompilationInfo(), then draws the effect with an EffectRenderer after each frame.

Where

Line numbers are from the 9.37.2 tag. master has the same code.

  • Engines/webgpuEngine.pure.ts:2289-2315 _createPipelineStageDescriptor creates the vertex and fragment modules with device.createShaderModule and never reads their getCompilationInfo().
  • Engines/webgpuEngine.pure.ts:2412-2452 _preparePipelineContextAsync sets stages and calls onReady(). WebGPUPipelineContext.isReady is true as soon as stages is set, so the effect is ready whether or not the modules compiled.
  • Engines/WebGPU/Extensions/engine.computeShader.pure.ts:410 reads getCompilationInfo() for compute shaders and routes errors to ComputeEffect.onError, since forum thread https://forum.babylonjs.com/t/48508. Render effects have no equivalent.

Suggested fix

In the WebGPU render path, read getCompilationInfo() of both modules before the pipeline context reports ready. When any message has type === "error", route it through Effect._processCompilationErrors, as the compute path does, so that onError, getCompilationError() and the fallbacks work as they do on WebGL2.

Impact

A shader error on WebGPU is silent at the API level: the effect is ready and the app draws with it, and the only signal is the device's uncaptured errors. In a render pass that feeds the rest of the frame, this blacks out the whole picture with no error the app can catch or report.

Workaround

After executeWhenCompiled, read effect.getPipelineContext().stages.vertexStage.module and .fragmentStage.module and await getCompilationInfo() on each. Treat the effect as failed when any message has type === "error".

Desktop (please complete the following information):

  • OS: macOS 26.6.1, Mac mini (Apple M4), WebGPU adapter apple / metal-3
  • Browser: Chrome (WebGPU)
  • Version: Chrome 158. Babylon.js 9.37.2 (playground)

Smartphone (please complete the following information):

  • Not tested

Additional context

  • WebGL2 is not affected: GLSL compile errors already reach Effect.onError.
  • No existing issue, PR or forum thread found for render effects. PR #18955 ("Add on error on EffectWrapper") adds the onError option to EffectWrapper, which this bug bypasses on WebGPU.
Dominant language
TypeScript
Stars
26.6k
Forks
3.8k
Avg merge
1d 9h
Merged PRs (30d)
112

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from BabylonJS/Babylon.js

All issues in BabylonJS/Babylon.js

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.