Repository navigation
WebGPURenderer: Prevent undefined GPUShaderStage. - #32539
Merged
Merged
Conversation
π¦ Bundle sizeFull ESM build, minified and gzipped.
π³ Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
Mugen87
approved these changes
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed #32529
Description
Guards against an
undefinedGPUShaderStagethat crashes Bun in r182.