FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Properly dispose renderer to stop the animation loop by vincentfretin · Pull Request #5112 · aframevr/aframe · GitHub

Properly dispose renderer to stop the animation loop - #5112

Merged
dmarcos merged 1 commit into
aframevr:masterfrom
vincentfretin:properly-dispose-renderer
Sep 10, 2022
Merged

Properly dispose renderer to stop the animation loop#5112
dmarcos merged 1 commit into
aframevr:masterfrom
vincentfretin:properly-dispose-renderer

Conversation

Copy link
Copy Markdown
Contributor

Description:
In aframe 1.3.0 and master (three r141), when you are removing the a-scene from the DOM, it disposes the WebXRManager/WebVRManager (renderer.xr) on detachedCallback but not the renderer itself (WebGLRenderer), so it doesn't stop properly the animation loop and it continues executing some tick methods.
You can test with document.body.removeChild(AFRAME.scenes[0])
Before the PR:

After the PR:

This is known issue since a long time, see #3146 (comment) and https://stackoverflow.com/questions/54930875/aframejs-how-to-completely-destroy-a-scene and I also documented it in https://aframe.wiki/en/memory

Changes proposed:

Properly disposing the renderer in detachedCallback seems right because in attachedCallback that is calling this.setupRenderer() we're creating a new WebGLRenderer always.
But note that detaching or reattaching the scene is not a supported use case, it gives currently an error before and after this PR anyway on the /examples/boilerplate/3d-model/ example where I tested that and I'm no gonna investigate that.

scene=AFRAME.scenes[0]
document.body.removeChild(scene)
document.body.appendChild(scene)
core:a-entity:warn Tried to remove `Object3D` of type:  mesh which was not defined.
2
browser.js:111 core:a-node:error Failure loading node:   TypeError: Cannot read properties of undefined (reading 'constructor')
    at extendProperties (component.js:736:1)
    at NewComponent.callUpdateHandler (component.js:416:1)
    at NewComponent.updateProperties (component.js:300:1)
    at HTMLElement.value (a-entity.js:490:1)
    at HTMLElement.value (a-entity.js:456:1)
    at entityLoadCallback (a-entity.js:249:1)
    at emitLoaded (a-node.js:127:1)
browser.js:111 components:gltf-model:warn Unexpected token '<', "<!DOCTYPE "... is not valid JSON 

dmarcos commented Sep 10, 2022

Copy link
Copy Markdown
Member

Thanks!

dmarcos merged commit fb67365 into aframevr:master Sep 10, 2022
vincentfretin deleted the properly-dispose-renderer branch September 11, 2022 07:46
vincentfretin mentioned this pull request Sep 11, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL