diff --git a/src/hub.js b/src/hub.js index feb07c11faff1a700d1fe3262cbd32bf204f1729..fe3a52df26a5b9fed524eb9bb5be41de92b08f47 100644 --- a/src/hub.js +++ b/src/hub.js @@ -195,10 +195,16 @@ const onReady = async () => { if (NAF.connection.adapter && NAF.connection.adapter.localMediaStream) { NAF.connection.adapter.localMediaStream.getTracks().forEach(t => t.stop()); } - hubChannel.disconnect(); + if (hubChannel) { + hubChannel.disconnect(); + } const scene = document.querySelector("a-scene"); - scene.renderer.animate(null); // Stop animation loop, TODO A-Frame should do this - document.body.removeChild(scene); + if (scene) { + if (scene.renderer) { + scene.renderer.animate(null); // Stop animation loop, TODO A-Frame should do this + } + document.body.removeChild(scene); + } }; const enterScene = async (mediaStream, enterInVR, janusRoomId) => {