Skip to content

Sampler: Don't set _texture to null.#31874

Merged
sunag merged 1 commit into
mrdoob:devfrom
Mugen87:dev4
Sep 10, 2025
Merged

Sampler: Don't set _texture to null.#31874
sunag merged 1 commit into
mrdoob:devfrom
Mugen87:dev4

Conversation

@Mugen87

@Mugen87 Mugen87 commented Sep 10, 2025

Copy link
Copy Markdown
Collaborator

Fixed #31747.

Description

#31497 introduced the private _texture property in Sampler to fix #31480. This property is set to null if a texture dispose happens.

However, a lot of code in context of bind groups breaks if the texture property of a sampler binding is null. #31747 is one example how runtime errors occur, in this instance during the init of a bind group. However, the same error occurs when the WebGPU backend tries to create bind group layouts. All this code assumes binding.texture never points to null. Even if a texture is disposed, the (cached) binding must point to it for the case the texture is reused again.

The cached bindings I'm talking about are the bindings from the render object:

const bindings = renderObject.getBindings();

@Mugen87 Mugen87 requested a review from sunag September 10, 2025 13:34
@github-actions

github-actions Bot commented Sep 10, 2025

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.24
79.14
338.24
79.14
+0 B
+0 B
WebGPU 580.27
160.28
580.3
160.29
+33 B
+8 B
WebGPU Nodes 578.88
160.04
578.91
160.05
+33 B
+7 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 469.88
113.85
469.88
113.85
+0 B
+0 B
WebGPU 649.98
175.93
650.01
175.94
+33 B
+8 B
WebGPU Nodes 604.09
165.11
604.12
165.11
+33 B
+8 B

@Mugen87 Mugen87 marked this pull request as draft September 10, 2025 13:44
@Mugen87 Mugen87 marked this pull request as ready for review September 10, 2025 16:20
@sunag sunag added this to the r181 milestone Sep 10, 2025
@sunag sunag merged commit 4ff594b into mrdoob:dev Sep 10, 2025
9 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.

WeakMap error on updateTexture StorageTexture: Cannot be disposed of and reused or resized

2 participants