Skip to content

WebGPURenderer: Prevent undefined GPUShaderStage. - #32539

Merged
Mugen87 merged 1 commit into
mrdoob:devfrom
verekia:bun-undefined-gpushaderstage
Dec 12, 2025
Merged

Mugen87 merged 1 commit into
mrdoob:devfrom
verekia:bun-undefined-gpushaderstage

Conversation

@verekia

@verekia verekia commented Dec 12, 2025 •

Copy link
Copy Markdown
Contributor

Fixed #32529

Description

Guards against an undefined GPUShaderStage that crashes Bun in r182.

@github-actions

Copy link
Copy Markdown

πŸ“¦ Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 355.12
84.44
355.12
84.44
+0 B
+0 B
WebGPU 616.52
171.11
616.54
171.12
+21 B
+6 B
WebGPU Nodes 615.12
170.85
615.14
170.85
+21 B
+4 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 487.45
119.37
487.45
119.37
+0 B
+0 B
WebGPU 687.43
186.7
687.45
186.71
+21 B
+6 B
WebGPU Nodes 637.27
173.92
637.29
173.93
+21 B
+5 B

@Mugen87 Mugen87 added this to the r183 milestone Dec 12, 2025
@Mugen87
Mugen87 merged commit 1d2a5f7 into mrdoob:dev Dec 12, 2025
@Mugen87 Mugen87 changed the title Prevent undefined GPUShaderStage WebGPURenderer: Prevent undefined GPUShaderStage. Dec 12, 2025
rndrntwrk added a commit to rndrntwrk/milaidy that referenced this pull request Apr 15, 2026
…tage crash

Three.js r182 ships a top-level module-init line in
src/renderers/webgpu/utils/WebGPUConstants.js:

  const GPUShaderStage = ( typeof self !== 'undefined' )
    ? self.GPUShaderStage
    : { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };

In any environment where `self` exists but WebGPU is not exposed
(Bun, headless Chromium, SwiftShader-backed ANGLE,
--disable-features=WebGPU), self.GPUShaderStage is undefined, the
const becomes undefined, and the very next module-init statement
in three.webgpu.js β€” `const gpuShaderStageLib = { 'vertex':
GPUShaderStage.VERTEX, 'fragment': GPUShaderStage.FRAGMENT,
'compute': GPUShaderStage.COMPUTE }` β€” throws

  Cannot read properties of undefined (reading 'VERTEX')

@pixiv/three-vrm-materials-mtoon@3.5 imports `three/webgpu` 7Γ—
at file top in lib/nodes/index.module.js, so anything that touches
the VRM MToon node-material chain pulls WebGPURenderer init into
the bundle eagerly even when we only render via WebGLRenderer at
runtime. The crash fires before React mounts.

Upstream fix: mrdoob/three.js#32539 β€” adds the missing
`&& self.GPUShaderStage` guard. Shipped in r183.
Repro confirmed in mrdoob/three.js#32794 (Vite + headless +
"Cannot read properties of undefined (reading 'VERTEX')"), closed
as duplicate of #32529.

Why our lockfile didn't auto-pick up the fix: three is pre-1.0,
so ^0.182.0 cannot resolve to 0.183.x. The fix has been published
to npm as 0.183.2 for weeks.

This bumps three to ^0.183.2, @types/three to ^0.183.1, and aligns
@pixiv/three-vrm to ^3.5.1 (matching the workspace root override
that was already forcing 3.5.1 to resolve in apps/app context, but
the literal pin still said ^3.4.5). apps/web already pins
^0.183.2 β€” this aligns the rest of the workspace.

Touched packages:
- apps/app/package.json β€” bump three, @types/three, @pixiv/three-vrm
- packages/app-core/package.json β€” bump three (peerDep + dep),
  @types/three, @pixiv/three-vrm peerDep
- bun.lock β€” regenerated; top-level three resolution moves from
  0.182.0 β†’ 0.183.2

Out of scope (deferred to follow-up PRs):
- The Vite manualChunks pattern in apps/app/vite.config.ts:239
  only matches /@pixiv/three-vrm/ literally, missing
  @pixiv/three-vrm-materials-mtoon, @pixiv/three-vrm-core, etc.
  Pure hygiene fix, separate PR.
- services/agent-show in the 555stream repo still pins
  three@^0.180.0 β€” pre-bug, currently working as the fallback when
  broadcast fails. No need to touch.

This unblocks PR #68 (the BroadcastShell ?broadcast view) so
capture-service's headless Chromium can actually boot CompanionSceneHost
instead of falling back to the legacy agent-show standalone with the
bundled blonde Alice VRM.
rndrntwrk added a commit to rndrntwrk/milaidy that referenced this pull request Apr 15, 2026
…tage crash (#69)

Three.js r182 ships a top-level module-init line in
src/renderers/webgpu/utils/WebGPUConstants.js:

  const GPUShaderStage = ( typeof self !== 'undefined' )
    ? self.GPUShaderStage
    : { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };

In any environment where `self` exists but WebGPU is not exposed
(Bun, headless Chromium, SwiftShader-backed ANGLE,
--disable-features=WebGPU), self.GPUShaderStage is undefined, the
const becomes undefined, and the very next module-init statement
in three.webgpu.js β€” `const gpuShaderStageLib = { 'vertex':
GPUShaderStage.VERTEX, 'fragment': GPUShaderStage.FRAGMENT,
'compute': GPUShaderStage.COMPUTE }` β€” throws

  Cannot read properties of undefined (reading 'VERTEX')

@pixiv/three-vrm-materials-mtoon@3.5 imports `three/webgpu` 7Γ—
at file top in lib/nodes/index.module.js, so anything that touches
the VRM MToon node-material chain pulls WebGPURenderer init into
the bundle eagerly even when we only render via WebGLRenderer at
runtime. The crash fires before React mounts.

Upstream fix: mrdoob/three.js#32539 β€” adds the missing
`&& self.GPUShaderStage` guard. Shipped in r183.
Repro confirmed in mrdoob/three.js#32794 (Vite + headless +
"Cannot read properties of undefined (reading 'VERTEX')"), closed
as duplicate of #32529.

Why our lockfile didn't auto-pick up the fix: three is pre-1.0,
so ^0.182.0 cannot resolve to 0.183.x. The fix has been published
to npm as 0.183.2 for weeks.

This bumps three to ^0.183.2, @types/three to ^0.183.1, and aligns
@pixiv/three-vrm to ^3.5.1 (matching the workspace root override
that was already forcing 3.5.1 to resolve in apps/app context, but
the literal pin still said ^3.4.5). apps/web already pins
^0.183.2 β€” this aligns the rest of the workspace.

Touched packages:
- apps/app/package.json β€” bump three, @types/three, @pixiv/three-vrm
- packages/app-core/package.json β€” bump three (peerDep + dep),
  @types/three, @pixiv/three-vrm peerDep
- bun.lock β€” regenerated; top-level three resolution moves from
  0.182.0 β†’ 0.183.2

Out of scope (deferred to follow-up PRs):
- The Vite manualChunks pattern in apps/app/vite.config.ts:239
  only matches /@pixiv/three-vrm/ literally, missing
  @pixiv/three-vrm-materials-mtoon, @pixiv/three-vrm-core, etc.
  Pure hygiene fix, separate PR.
- services/agent-show in the 555stream repo still pins
  three@^0.180.0 β€” pre-bug, currently working as the fallback when
  broadcast fails. No need to touch.

This unblocks PR #68 (the BroadcastShell ?broadcast view) so
capture-service's headless Chromium can actually boot CompanionSceneHost
instead of falling back to the legacy agent-show standalone with the
bundled blonde Alice VRM.
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.

WebGPURenderer: undefined GPUShaderStage crashes Bun in r182

2 participants