Skip to content

WebGLRenderer: Improve geometry disposal. - #34529

Merged
Mugen87 merged 1 commit into
mrdoob:devfrom
Mugen87:dev2
Sep 10, 2026
Merged

WebGLRenderer: Improve geometry disposal.#34529
Mugen87 merged 1 commit into
mrdoob:devfrom
Mugen87:dev2

Conversation

@Mugen87

@Mugen87 Mugen87 commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Related PR: #20698

Description

We have recently introduced the usage of WeakRef and FinalizationRegistry in WebGPURenderer so we are able to remove existing dispose event listeners during renderer.dispose(). If we don't do that, it's not possible to fully free the resources of a renderer instance.

The same issue exists in WebGLRenderer and this PR adapts the first part of the solution to WebGLGeometries. Interestingly, @gkjohnson suggested this exact fix years ago in #20698. At that time, the browser support for WeakRef and FinalizationRegistry was still problematic but now it should be safe to use. In any event, the approach of #20698 was correct and we should have merged this PR a bit sooner.

@github-actions

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
Core 389.51
102.17
389.51
102.17
+0 B
+0 B
WebGL 378.45
88.68
378.65
88.76
+196 B
+82 B
WebGPU 711.13
195.69
711.13
195.69
+0 B
+0 B
WebGPU Nodes 709.12
195.38
709.12
195.38
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 523.08
125.84
523.27
125.92
+196 B
+85 B
WebGPU 765.12
205.27
765.12
205.27
+0 B
+0 B
WebGPU Nodes 711.21
191.93
711.21
191.93
+0 B
+0 B

@Mugen87
Mugen87 merged commit 5227170 into mrdoob:dev Sep 10, 2026
10 checks passed
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.

1 participant