From 22922dec96349176daf1108378a54890d36cb133 Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Mon, 27 Jun 2016 16:31:01 -0700 Subject: [PATCH] CrashReporter should not run on UI thread on Win/Linux --- src/crash-reporter-start.coffee | 13 +++++++++++++ src/initialize-test-window.coffee | 7 ++++--- src/main-process/main.coffee | 8 +++----- static/index.js | 13 ++++--------- 4 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 src/crash-reporter-start.coffee diff --git a/src/crash-reporter-start.coffee b/src/crash-reporter-start.coffee new file mode 100644 index 000000000..37c381473 --- /dev/null +++ b/src/crash-reporter-start.coffee @@ -0,0 +1,13 @@ +module.exports = (extra) -> + # Breakpad on Mac OS X must be running on UI and non-UI processes + # Crashpad on Windows and Linux should only be running on non-UI process + return if process.type is 'renderer' and process.platform isnt 'darwin' + + {crashReporter} = require 'electron' + + crashReporter.start({ + productName: 'Atom', + companyName: 'GitHub', + submitURL: 'http://54.249.141.255:1127/post' + extra: extra + }) diff --git a/src/initialize-test-window.coffee b/src/initialize-test-window.coffee index c82d020d0..d5423a5a5 100644 --- a/src/initialize-test-window.coffee +++ b/src/initialize-test-window.coffee @@ -4,9 +4,10 @@ cloneObject = (object) -> clone module.exports = ({blobStore}) -> - {crashReporter, remote} = require 'electron' - # Start the crash reporter before anything else. - crashReporter.start(productName: 'Atom', companyName: 'GitHub', submitURL: 'http://54.249.141.255:1127/post') + startCrashReporter = require('./crash-reporter-start') + {remote} = require 'electron' + + startCrashReporter() # Before anything else exitWithStatusCode = (status) -> remote.app.emit('will-quit') diff --git a/src/main-process/main.coffee b/src/main-process/main.coffee index c7ff4882b..5368710aa 100644 --- a/src/main-process/main.coffee +++ b/src/main-process/main.coffee @@ -4,12 +4,13 @@ process.on 'uncaughtException', (error={}) -> console.log(error.message) if error.message? console.log(error.stack) if error.stack? -{crashReporter, app} = require 'electron' +{app} = require 'electron' fs = require 'fs-plus' path = require 'path' temp = require 'temp' yargs = require 'yargs' previousConsoleLog = console.log +startCrashReporter = require('../crash-reporter-start') console.log = require 'nslog' start = -> @@ -38,7 +39,7 @@ start = -> app.on 'open-file', addPathToOpen app.on 'open-url', addUrlToOpen - app.on 'will-finish-launching', setupCrashReporter + app.on 'will-finish-launching', startCrashReporter if args.userDataDir? app.setPath('userData', args.userDataDir) @@ -66,9 +67,6 @@ handleStartupEventWithSquirrel = -> squirrelCommand = process.argv[1] SquirrelUpdate.handleStartupEvent(app, squirrelCommand) -setupCrashReporter = -> - crashReporter.start(productName: 'Atom', companyName: 'GitHub', submitURL: 'http://54.249.141.255:1127/post') - setupAtomHome = ({setPortable}) -> return if process.env.ATOM_HOME diff --git a/static/index.js b/static/index.js index c33eda67a..7f59fad71 100644 --- a/static/index.js +++ b/static/index.js @@ -70,15 +70,10 @@ ModuleCache.register(loadSettings) ModuleCache.add(loadSettings.resourcePath) - // Start the crash reporter before anything else. - require('electron').crashReporter.start({ - productName: 'Atom', - companyName: 'GitHub', - submitURL: 'http://54.249.141.255:1127/post', - // By explicitly passing the app version here, we could save the call - // of "require('remote').require('app').getVersion()". - extra: {_version: loadSettings.appVersion} - }) + // By explicitly passing the app version here, we could save the call + // of "require('remote').require('app').getVersion()". + var startCrashReporter = require('../src/crash-reporter-start') + startCrashReporter({_version: loadSettings.appVersion}) setupVmCompatibility() setupCsonCache(CompileCache.getCacheDirectory())