-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Improve dispose guide. #30524
Docs: Improve dispose guide. #30524
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
src/renderers/WebGLRenderer.js
Outdated
@@ -331,6 +331,7 @@ class WebGLRenderer { | |||
_this.shadowMap = shadowMap; | |||
_this.state = state; | |||
_this.info = info; | |||
_this.background = background; // allows using renderer.background.dispose() when deep cleaning the scene |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not voting doing that since the entire component becomes public and that is not wanted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I said before it is not our goal to make everything disposable. The backgrounds resources do not need a clean up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, added a new commit replacing exposed background with disposing method, not exposing the background itself anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I'm not in favor of disposeBackground()
. I would rather hide the internal objects from the statistics.
There is really no reason for users to care about a few internal geometries or materials. They do not harm the runtime behavior of your app in any means. I'm afraid you are taking this issue too precisely.
@@ -106,6 +106,7 @@ function WebGLCubeUVMaps( renderer ) { | |||
|
|||
cubeUVmaps.delete( texture ); | |||
cubemapUV.dispose(); | |||
pmremGenerator.dispose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you call dispose()
the generator it's internal resource must be created from scratch during the next usage. That is not a correct fix. We must find out why the generator adds up texture references and apply a fix inside PMREMGenerator
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for you to share a fiddle that demonstrate the leak in PMREMGenerator
with an isolated test case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://jsfiddle.net/catalin_enache/rfyc9jmo/44/
The fiddle is just about a plane and envMap or scene.environment.
I had to let deepCleanScene helper in the fiddle (I know is large, but after checking it does the right job it can be collapsed).
THe PMREMGenerator itself does not leak.
The fact that it cannot be disposed leaks.
The texture that leaks is in _pingPongRenderTarget and it adds up.
The 12 geometries leak but do not add up, however they should be disposed along with the texture.
Also added a small update which should recreated pmremGenerator next time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The texture that leaks is in _pingPongRenderTarget and it adds up.
I have simplified your fiddle a bit and there are no signs that PMREMGenerator
leaks:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking the time to look int it.
Interesting.
It seems that it leaks only when doing this inside the loop:
renderer.renderLists.dispose();
renderer.properties.dispose();
renderer.info.reset();
which is part of renderer.dispose() using exposed things on the renderer.
https://jsfiddle.net/catalin_enache/ndku0pbw/6/
So, the idea is to not touch those in the process of deep cleaning the scene to force going close to zero the geometries and textures.
Wait until Monday please, I want to do more tests in my app. |
6cb16ca
to
9c01215
Compare
054356a
to
7c67239
Compare
I reverted all proposed changes replacing them with a new mention in the doc about internal geometries/textures that cannot be disposed. |
9aa9a30
to
a1eb29a
Compare
…re that cannot be cleanup
a1eb29a
to
e9c72ff
Compare
Related issue: #30516
Description
Disposing pmremGenerator in WebGLCubeUVMaps
added backgroundDispose method WebGLRenderer.
Both are needed so that when deeply cleaning the scene
no texture and geometry remain hanging around, reported as being in use by renderer.info.memory
the geometry created by WebGLBackground can be disposed now like:
renderer.backgroundDispose()
EDIT:
I reverted all proposed changes replacing them with a new mention in the doc about internal geometries/textures that cannot be disposed.