From bba50c842717631c3f7fdc8644c16bc577019583 Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Fri, 15 Jan 2021 12:30:58 -0500 Subject: [PATCH] Log app startup time --- main.js | 8 ++++++++ preload.js | 2 ++ ts/background.ts | 2 +- ts/window.d.ts | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 595b166f45..259e46099e 100644 --- a/main.js +++ b/main.js @@ -866,6 +866,14 @@ function showPermissionsPopupWindow(forCalling, forCamera) { // Some APIs can only be used after this event occurs. let ready = false; app.on('ready', async () => { + const startTime = Date.now(); + + // We use this event only a single time to log the startup time of the app + // from when it's first ready until the loading screen disappears. + ipc.once('signal-app-loaded', () => { + console.log('App has finished loading in:', Date.now() - startTime); + }); + const userDataPath = await getRealPath(app.getPath('userData')); const installPath = await getRealPath(app.getAppPath()); diff --git a/preload.js b/preload.js index 1b5b14e6c9..6b308ccffd 100644 --- a/preload.js +++ b/preload.js @@ -97,6 +97,8 @@ try { window.setBadgeCount = count => ipc.send('set-badge-count', count); + window.logAppLoadedEvent = () => ipc.send('signal-app-loaded'); + // We never do these in our code, so we'll prevent it everywhere window.open = () => null; // eslint-disable-next-line no-eval, no-multi-assign diff --git a/ts/background.ts b/ts/background.ts index 2776eb7c3f..ef70b3652b 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -2118,7 +2118,6 @@ type WhatIsThis = import('./window.d').WhatIsThis; ]); window.log.info('onEmpty: All outstanding database requests complete'); initialLoadComplete = true; - window.readyForUpdates(); // Start listeners here, after we get through our queue. @@ -2140,6 +2139,7 @@ type WhatIsThis = import('./window.d').WhatIsThis; clearInterval(interval!); interval = null; view.onEmpty(); + window.logAppLoadedEvent(); } }, 500); diff --git a/ts/window.d.ts b/ts/window.d.ts index 342abde5d9..de4732dd4b 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -493,6 +493,7 @@ declare global { hasSignalAccount: (number: string) => boolean; getServerTrustRoot: () => WhatIsThis; readyForUpdates: () => void; + logAppLoadedEvent: () => void; // Flags isGroupCallingEnabled: () => boolean;