From cc8aafb5fac8c1e0b23026e68222d814b3a00e41 Mon Sep 17 00:00:00 2001 From: AAGaming Date: Sat, 3 Aug 2024 14:03:25 -0400 Subject: [PATCH] hopefully fix bootloops --- backend/decky_loader/main.py | 2 +- frontend/src/index.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/decky_loader/main.py b/backend/decky_loader/main.py index 8fbbaf86..4649ccd3 100644 --- a/backend/decky_loader/main.py +++ b/backend/decky_loader/main.py @@ -207,7 +207,7 @@ async def inject_javascript(self, tab: Tab, first: bool=False, request: Request| await tab.close_websocket() self.js_ctx_tab = None await restart_webhelper() - await sleep(5) + await sleep(1) # To give CEF enough time to close down the websocket return # We'll catch the next tab in the main loop await tab.evaluate_js("try{if (window.deckyHasLoaded){setTimeout(() => SteamClient.Browser.RestartJSContext(), 100)}else{window.deckyHasLoaded = true;(async()=>{try{await import('http://localhost:1337/frontend/index.js?v=%s')}catch(e){console.error(e)};})();}}catch(e){console.error(e)}" % (get_loader_version(), ), False, False, False) except: diff --git a/frontend/src/index.ts b/frontend/src/index.ts index 7910c740..993fc579 100644 --- a/frontend/src/index.ts +++ b/frontend/src/index.ts @@ -6,10 +6,19 @@ interface Window { (async () => { // Wait for main webpack chunks to definitely be loaded - console.debug('[Decky:Boot] Waiting for main Webpack chunks...'); + console.time('[Decky:Boot] Waiting for main Webpack chunks...'); while (!window.webpackChunksteamui || window.webpackChunksteamui.length < 8) { await new Promise((r) => setTimeout(r, 10)); // Can't use DFL sleep here. } + console.timeEnd('[Decky:Boot] Waiting for main Webpack chunks...') + + // Wait for the React root to be mounted + console.time('[Decky:Boot] Waiting for React root mount...'); + let root; + while (!(root = document.getElementById("root")) || !(root as any)[Object.keys(root).find((k) => k.startsWith('__reactContainer$')) as string]) { + await new Promise((r) => setTimeout(r, 10)); // Can't use DFL sleep here. + } + console.timeEnd('[Decky:Boot] Waiting for React root mount...'); if (!window.SP_REACT) { console.debug('[Decky:Boot] Setting up Webpack & React globals...');