Perf: Send 'ipcReady' before all requires (300ms improvement!)

This improves the time to the main window showing by 300ms on my
Macbook 12"!

Before: ~800ms
After: ~500ms
This commit is contained in:
Feross Aboukhadijeh
2016-05-11 22:34:51 +02:00
parent 840754fb59
commit 350bed53a3

View File

@@ -1,9 +1,21 @@
console.time('init')
var crashReporter = require('../crash-reporter')
crashReporter.init()
var electron = require('electron')
// Electron apps have two processes: a main process (node) runs first and starts
// a renderer process (essentially a Chrome window). We're in the renderer process,
// and this IPC channel receives from and sends messages to the main process
var ipcRenderer = electron.ipcRenderer
// Listen for messages from the main process
setupIpc()
var appConfig = require('application-config')('WebTorrent')
var concat = require('concat-stream')
var dragDrop = require('drag-drop')
var electron = require('electron')
var fs = require('fs-extra')
var mainLoop = require('main-loop')
var path = require('path')
@@ -14,7 +26,6 @@ var patch = require('virtual-dom/patch')
var App = require('./views/app')
var config = require('../config')
var crashReporter = require('../crash-reporter')
var errors = require('./lib/errors')
var sound = require('./lib/sound')
var State = require('./state')
@@ -26,11 +37,6 @@ setDispatch(dispatch)
appConfig.filePath = path.join(config.CONFIG_PATH, 'config.json')
// Electron apps have two processes: a main process (node) runs first and starts
// a renderer process (essentially a Chrome window). We're in the renderer process,
// and this IPC channel receives from and sends messages to the main process
var ipcRenderer = electron.ipcRenderer
// This dependency is the slowest-loading, so we lazy load it
var Cast = null
@@ -39,13 +45,6 @@ var state = global.state = State.getInitialState()
var vdomLoop
// Report crashes back to our server.
// Not global JS exceptions, not like Rollbar, handles segfaults/core dumps only
crashReporter.init()
// Listen for messages from the main process
setupIpc()
// All state lives in state.js. `state.saved` is read from and written to a file.
// All other state is ephemeral. First we load state.saved then initialize the app.
loadState(init)