From 4deef8b90ce453227508a1b9bdd818f53858676a Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Fri, 31 Mar 2017 12:17:34 -0700 Subject: [PATCH] [client-app] delay building new hot window to improve win perf Summary: This improves window open times by about 70ms We would spend a very long time in the backend browser process building a new hot window when we didn't need to do that until much later Test Plan: manual Reviewers: halla, mark, juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D4311 --- packages/client-app/src/browser/window-launcher.es6 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/client-app/src/browser/window-launcher.es6 b/packages/client-app/src/browser/window-launcher.es6 index a8247f15e..c2bf25400 100644 --- a/packages/client-app/src/browser/window-launcher.es6 +++ b/packages/client-app/src/browser/window-launcher.es6 @@ -48,7 +48,6 @@ export default class WindowLauncher { this.createHotWindow() } win = this.hotWindow; - this.createHotWindow(); const newLoadSettings = Object.assign({}, win.loadSettings(), opts) if (newLoadSettings.windowType === WindowLauncher.EMPTY_WINDOW) { @@ -70,6 +69,12 @@ export default class WindowLauncher { } win.setLoadSettings(newLoadSettings); + + setTimeout(() => { + // We need to regen a hot window, but do it in the next event + // loop to not hang the opening of the current window. + this.createHotWindow(); + }, 0) } if (!opts.hidden && !opts.initializeInBackground) {