From 8d7424d19df282410b334b78e2b734f1164289c0 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sun, 27 Mar 2016 00:27:28 -0700 Subject: [PATCH 1/2] OS X: Prevent white flash on window open MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We got the window to run less JS but now it’s shown by the main process too soon! This fixes that with a setTimeout. Perhaps when this issue is fixed (https://github.com/atom/electron/issues/861) we can remove the timeout. --- main/ipc.js | 5 ++++- main/windows.js | 4 ---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/main/ipc.js b/main/ipc.js index 075c9ed1..bb4ed1b2 100644 --- a/main/ipc.js +++ b/main/ipc.js @@ -18,9 +18,12 @@ var powerSaveBlockID = 0 function init () { ipcMain.on('ipcReady', function (e) { - console.timeEnd('init') app.ipcReady = true app.emit('ipcReady') + setTimeout(function () { + windows.main.show() + console.timeEnd('init') + }, 50) }) ipcMain.on('showOpenTorrentFile', menu.showOpenTorrentFile) diff --git a/main/windows.js b/main/windows.js index 216b39e3..7d926c14 100644 --- a/main/windows.js +++ b/main/windows.js @@ -71,10 +71,6 @@ function createMainWindow () { menu.onToggleFullScreen() }) - win.webContents.on('did-finish-load', function () { - win.show() - }) - win.on('blur', menu.onWindowHide) win.on('focus', menu.onWindowShow) From 60161bea1a1d0868b9b1aa70f66e05ebe5d0291e Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sun, 27 Mar 2016 00:28:33 -0700 Subject: [PATCH 2/2] Delay lazy load of client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This works great on my slow Macbook 12”, so I assume it will work without lag on most other people’s computers. --- renderer/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/renderer/index.js b/renderer/index.js index 8accb85e..a1e710d5 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -60,7 +60,7 @@ function init () { window.setTimeout(function () { lazyLoadClient() lazyLoadCast() - }, 100) + }, 750) // The UI is built with virtual-dom, a minimalist library extracted from React // The concepts--one way data flow, a pure function that renders state to a @@ -76,9 +76,6 @@ function init () { // Save state on exit window.addEventListener('beforeunload', saveState) - // Listen for messages from the main process - setupIpc() - // OS integrations: // ...drag and drop a torrent or video file to play or seed dragDrop('body', (files) => dispatch('onOpen', files)) @@ -113,8 +110,12 @@ function init () { update() }) + // Listen for messages from the main process + setupIpc() + // Done! Ideally we want to get here <100ms after the user clicks the app playInterfaceSound('STARTUP') + console.timeEnd('init') }