Skip to content

Conversation

@mrdoob
Copy link
Owner

@mrdoob mrdoob commented Nov 28, 2025

Description

Enforces consistent object shapes (Hidden Classes) for materialProperties, textureProperties, and renderTargetProperties to enable monomorphic property access in V8, resulting in a ~3.4x performance improvement in property lookups.

Additionally:

  • WebGLTextures.js: Replaced delete keyword usage with undefined assignment for renderTargetProperties to prevent hidden class transitions.
  • WebGLBindingStates.js: Refactored bindingStates, programMap, and stateMap to use Map instead of plain objects, eliminating delete usage in hot paths.
  • WebGLShadowMap.js: Refactored _materialCache to use Map instead of plain objects, eliminating delete usage.

@mrdoob mrdoob added this to the r182 milestone Nov 28, 2025
@github-actions
Copy link

github-actions bot commented Nov 28, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 350.27
83.05
351.39
83.34
+1.12 kB
+285 B
WebGPU 613.66
170.42
613.66
170.42
+0 B
+0 B
WebGPU Nodes 612.26
170.14
612.26
170.14
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 482.26
117.84
483.38
118.12
+1.12 kB
+281 B
WebGPU 684.8
186.19
684.8
186.19
+0 B
+0 B
WebGPU Nodes 634.64
173.38
634.64
173.38
+0 B
+0 B

@mrdoob mrdoob changed the title WebGLRenderer: Fix V8 deoptimizations in materialProperties WebGLRenderer: Fix V8 deoptimizations by enforcing consistent object shapes Nov 28, 2025
@mrdoob mrdoob changed the title WebGLRenderer: Fix V8 deoptimizations by enforcing consistent object shapes WebGLRenderer: Fix V8 deoptimizations Nov 28, 2025
@mrdoob mrdoob modified the milestones: r182, r183 Nov 28, 2025
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.

2 participants