From 7a1c4086a065b6b8908c6861014a1930780c3f74 Mon Sep 17 00:00:00 2001
From: DD Liu <liudi@media.mit.edu>
Date: Fri, 12 Oct 2018 21:46:09 -0400
Subject: [PATCH] Fix on Mac Chrome

---
 src/containers/gui.jsx | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/containers/gui.jsx b/src/containers/gui.jsx
index a1e02f815..e4748805c 100644
--- a/src/containers/gui.jsx
+++ b/src/containers/gui.jsx
@@ -47,23 +47,27 @@ class GUI extends React.Component {
         this.audioEngine = new AudioEngine();
         this.props.vm.attachAudioEngine(this.audioEngine);
         this.props.vm.initialized = true;
-        const fontPromises = [];
-        if (document.fonts &&
-            typeof document.fonts.values === 'function' &&
-            typeof document.fonts.values()[Symbol.iterator] === 'function') {
-            for (const fontFace of document.fonts.values()) {
-                fontPromises.push(fontFace.loaded);
-                fontFace.load();
+
+        const getFontPromises = () => {
+            const fontPromises = [];
+            if (document.fonts &&
+                typeof document.fonts.values === 'function' &&
+                typeof document.fonts.values()[Symbol.iterator] === 'function') {
+                for (const fontFace of document.fonts.values()) {
+                    fontPromises.push(fontFace.loaded);
+                    fontFace.load();
+                }
             }
-        }
+            return fontPromises;
+        };
 
         if (document.readyState === 'complete') {
-            Promise.all(fontPromises).then(this.loadProject);
+            Promise.all(getFontPromises()).then(this.loadProject);
         } else {
             document.onreadystatechange = () => {
                 if (document.readyState !== 'complete') return;
                 document.onreadystatechange = null;
-                Promise.all(fontPromises).then(this.loadProject);
+                Promise.all(getFontPromises()).then(this.loadProject);
             };
         }
     }
-- 
GitLab