Here are several culprits that people have run into when the browser (or even the whole machine) dead-locks or “hangs” right after calling
-
Unbounded or Very Deep Control-Flow in Your Shader
• A loop { … } without a proper break/return
• Extremely nested if/for/while chains
→ The shader compiler (e.g. Naga in Chromium, SPIRV-Cross in Firefox) can spin in static analysis or optimization forever.
-
Invalid or Malformed SPIR-V/WGSL
• Bad decorations (missing @group, @binding, or mismatched entry-point name)
• Wrong version header or exceeded SPIR-V limits
→ Some driver/compiler paths hit assertion failures or infinite‐retry loops.
-
Excessively Large Shader Sources
• Hundreds of KB of WGSL or SPIR-V
• Thousands of macros or unrolled loops
→ Eats all CPU/RAM during compile, freezing the main thread (createShaderModule is often sync in current implementations).
-
Driver or Browser Bugs
• Known GPU driver bugs triggered by certain constructs (e.g. subgroup ops, atomic chains)
• Early WebGPU builds in Chrome/Edge/Firefox still have rough edges
→ Try updating the browser/driver or testing in another browser.
-
GPU Timeout (TDR)
• A “compile” step that actually lands on the GPU and never returns
• Windows may mark the GPU non‐responsive, then reset it—making the UI stutter or hang.
-
Debug/Validation Layers Overhead
• If device.pushErrorScope("validation") or getCompilationInfo() is used, you’re forcing extra synchronous work
→ Can easily blow out the frame‐budget and clog the JS event loop.
-
Mixing WGSL and SPIR-V in One Module
• Passing SPIR-V binary with WGSL API or vice versa
→ The code‐path is undefined and can hang the browser process.
-
Race with Device Initialization
• If the first createShaderModule also triggers internal device/adapter setup
• You end up blocking while, e.g., the GPU adapter is still being polled.
-
Memory Exhaustion
• Passing huge arrays or constants into the shader source (e.g. big data blobs embedded)
→ The compiler tries to allocate giant buffers and locks up.
-
Late Pipeline Creation Actually Fails Silently
• Although you call createShaderModule, the real compilation happens at createRenderPipeline() or when you do module.getCompilationInfo()
• The freeze you see is actually in one of those calls, not createShaderModule itself.