diff --git a/src/backend/main.ts b/src/backend/main.ts index 85355b16e7..d13429fee6 100644 --- a/src/backend/main.ts +++ b/src/backend/main.ts @@ -344,7 +344,9 @@ if (!gotTheLock) { app.whenReady().then(async () => { initOnlineMonitor() - const systemInfo = await getSystemInfo() + getSystemInfo().then((systemInfo) => + logInfo(`\n\n${systemInfo}\n`, { prefix: LogPrefix.Backend }) + ) initImagesCache() @@ -355,7 +357,6 @@ if (!gotTheLock) { logInfo(['GOGDL location:', join(...Object.values(getGOGdlBin()))], { prefix: LogPrefix.Gog }) - logInfo(`\n\n${systemInfo}\n`, { prefix: LogPrefix.Backend }) // We can't use .config since apparently its not loaded fast enough. const { language, darkTrayIcon } = await GlobalConfig.get().getSettings() diff --git a/src/backend/utils.ts b/src/backend/utils.ts index 99b48c5f0f..7e1152ed34 100644 --- a/src/backend/utils.ts +++ b/src/backend/utils.ts @@ -247,7 +247,13 @@ async function handleExit(window: BrowserWindow) { app.exit() } +// This won't change while the app is running +// Caching significantly increases performance when launching games +let systemInfoCache = '' export const getSystemInfo = async () => { + if (systemInfoCache !== '') { + return systemInfoCache + } const heroicVersion = getHeroicVersion() const legendaryVersion = await getLegendaryVersion() @@ -276,7 +282,7 @@ export const getSystemInfo = async () => { ? (await execAsync('echo $XDG_SESSION_TYPE')).stdout.replaceAll('\n', '') : '' - return `Heroic Version: ${heroicVersion} + systemInfoCache = `Heroic Version: ${heroicVersion} Legendary Version: ${legendaryVersion} OS: ${distro} KERNEL: ${kernel} ARCH: ${arch} CPU: ${manufacturer} ${brand} @${speed} ${ @@ -285,6 +291,7 @@ CPU: ${manufacturer} ${brand} @${speed} ${ RAM: Total: ${getFileSize(total)} Available: ${getFileSize(available)} GRAPHICS: ${graphicsCards} ${isLinux ? `PROTOCOL: ${xEnv}` : ''}` + return systemInfoCache } type ErrorHandlerMessage = {