Skip to content

Commit f4abfe0

Browse files
authored
Renderer: Make dispose() more robust. (#31681)
1 parent 071bb8f commit f4abfe0

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/renderers/common/Renderer.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,25 +2171,29 @@ class Renderer {
21712171
*/
21722172
dispose() {
21732173

2174-
this.info.dispose();
2175-
this.backend.dispose();
2174+
if ( this._initialized === true ) {
21762175

2177-
this._animation.dispose();
2178-
this._objects.dispose();
2179-
this._pipelines.dispose();
2180-
this._nodes.dispose();
2181-
this._bindings.dispose();
2182-
this._renderLists.dispose();
2183-
this._renderContexts.dispose();
2184-
this._textures.dispose();
2176+
this.info.dispose();
2177+
this.backend.dispose();
21852178

2186-
if ( this._frameBufferTarget !== null ) this._frameBufferTarget.dispose();
2179+
this._animation.dispose();
2180+
this._objects.dispose();
2181+
this._pipelines.dispose();
2182+
this._nodes.dispose();
2183+
this._bindings.dispose();
2184+
this._renderLists.dispose();
2185+
this._renderContexts.dispose();
2186+
this._textures.dispose();
21872187

2188-
Object.values( this.backend.timestampQueryPool ).forEach( queryPool => {
2188+
if ( this._frameBufferTarget !== null ) this._frameBufferTarget.dispose();
21892189

2190-
if ( queryPool !== null ) queryPool.dispose();
2190+
Object.values( this.backend.timestampQueryPool ).forEach( queryPool => {
21912191

2192-
} );
2192+
if ( queryPool !== null ) queryPool.dispose();
2193+
2194+
} );
2195+
2196+
}
21932197

21942198
this.setRenderTarget( null );
21952199
this.setAnimationLoop( null );

0 commit comments

Comments
 (0)