From 75a3d44715802616be0442367ad8492c6f78f123 Mon Sep 17 00:00:00 2001
From: Brian Peiris <brianpeiris@gmail.com>
Date: Thu, 24 May 2018 14:34:30 -0700
Subject: [PATCH] reduce bot resource usage

---
 src/hub.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/hub.js b/src/hub.js
index 8bd8e2a29..827bab773 100644
--- a/src/hub.js
+++ b/src/hub.js
@@ -324,11 +324,12 @@ const onReady = async () => {
         });
         const audio = document.getElementById("bot-recording");
         mediaStream.addTrack(audio.captureStream().getAudioTracks()[0]);
-        // wait for runner script to interact with the page so that we can play audio.
+        // Wait for runner script to interact with the page so that we can play audio.
         await new Promise(resolve => {
           window.interacted = resolve;
         });
         audio.play();
+
       }
 
       if (mediaStream) {
@@ -389,6 +390,12 @@ const onReady = async () => {
       // Wait a tick plus some margin so that the environments actually render.
       setTimeout(() => scene.renderer.animate(null), 100);
     }
+    else {
+      const noop = () => {};
+      // Replace renderer with a noop renderer to reduce bot resource usage.
+      scene.renderer = { animate: noop, render: noop };
+      document.body.style.display = "none";
+    }
   });
   environmentRoot.appendChild(initialEnvironmentEl);
 
-- 
GitLab