Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Crash reporting toggle renderer #4606

Merged
merged 9 commits into from
Oct 10, 2016
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,4 @@ enableAutofill=Enable Autofill
importBrowserData=Import Browser Data
importNow=Import now…
clearAll=Clear all
sendCrashReports=Send anonymous crash reports to Brave (requires browser restart)
9 changes: 7 additions & 2 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ let ready = false

// Setup the crash handling
const CrashHerald = require('./crash-herald')
CrashHerald.init()

const handleUncaughtError = (error) => {
var message, ref, stack
Expand Down Expand Up @@ -244,10 +243,16 @@ let flashInitialized = false

// Some settings must be set right away on startup, those settings should be handled here.
loadAppStatePromise.then((initialState) => {
const {HARDWARE_ACCELERATION_ENABLED, SMOOTH_SCROLL_ENABLED} = require('../js/constants/settings')
const {HARDWARE_ACCELERATION_ENABLED, SMOOTH_SCROLL_ENABLED, SEND_CRASH_REPORTS} = require('../js/constants/settings')
if (initialState.settings[HARDWARE_ACCELERATION_ENABLED] === false) {
app.disableHardwareAcceleration()
}
if (initialState.settings[SEND_CRASH_REPORTS] !== false) {
console.log('Crash reporting enabled')
CrashHerald.init()
} else {
console.log('Crash reporting disabled')
}
if (initialState.settings[SMOOTH_SCROLL_ENABLED] === false) {
app.commandLine.appendSwitch('disable-smooth-scrolling')
}
Expand Down
1 change: 1 addition & 0 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ AppStore
'advanced.default-zoom-level': number, // the default zoom level for sites that have no specific setting
'advanced.pdfjs-enabled': boolean, // Whether or not to render PDF documents in the browser
'advanced.smooth-scroll-enabled': boolean, // false if smooth scrolling should be explicitly disabled
'advanced.send-crash-reports': boolean, // true or undefined if crash reports should be sent
'shutdown.clear-history': boolean, // true to clear history on shutdown
'shutdown.clear-downloads': boolean, // true to clear downloads on shutdown
'shutdown.clear-cache': boolean, // true to clear cache on shutdown
Expand Down
4 changes: 3 additions & 1 deletion js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@ class AdvancedTab extends ImmutableComponent {
<SettingCheckbox dataL10nId='useHardwareAcceleration' prefKey={settings.HARDWARE_ACCELERATION_ENABLED} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox dataL10nId='usePDFJS' prefKey={settings.PDFJS_ENABLED} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox dataL10nId='useSmoothScroll' prefKey={settings.SMOOTH_SCROLL_ENABLED} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox dataL10nId='sendCrashReports' prefKey={settings.SEND_CRASH_REPORTS} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
</SettingsList>
</div>
}
Expand Down Expand Up @@ -1455,7 +1456,8 @@ class AboutPreferences extends React.Component {
})
aboutActions.changeSetting(key, value)
if (key === settings.DO_NOT_TRACK || key === settings.HARDWARE_ACCELERATION_ENABLED ||
key === settings.PDFJS_ENABLED || key === settings.SMOOTH_SCROLL_ENABLED) {
key === settings.PDFJS_ENABLED || key === settings.SMOOTH_SCROLL_ENABLED ||
key === settings.SEND_CRASH_REPORTS) {
ipc.send(messages.PREFS_RESTART, key, value)
}
if (key === settings.PAYMENTS_ENABLED) {
Expand Down
1 change: 1 addition & 0 deletions js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ module.exports = {
'advanced.default-zoom-level': null,
'advanced.pdfjs-enabled': true,
'advanced.smooth-scroll-enabled': false,
'advanced.send-crash-reports': true,
'shutdown.clear-history': false,
'shutdown.clear-downloads': false,
'shutdown.clear-cache': false,
Expand Down
1 change: 1 addition & 0 deletions js/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const settings = {
PDFJS_ENABLED: 'advanced.pdfjs-enabled',
DEFAULT_ZOOM_LEVEL: 'advanced.default-zoom-level',
SMOOTH_SCROLL_ENABLED: 'advanced.smooth-scroll-enabled',
SEND_CRASH_REPORTS: 'advanced.send-crash-reports',

ADBLOCK_CUSTOM_RULES: 'adblock.customRules'
}
Expand Down
24 changes: 19 additions & 5 deletions js/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ require('../less/notificationBar.less')
require('../less/addEditBookmark.less')
require('../node_modules/font-awesome/css/font-awesome.css')

if (process.platform === 'darwin') {
// Setup the crash handling for mac renderer processes
// https://github.com/electron/electron/blob/master/docs/api/crash-reporter.md#crashreporterstartoptions
const CrashHerald = require('../app/crash-herald')
CrashHerald.init()
// Enable or disable crash reporting based on platform
const setupCrashReporting = () => {
if (process.platform === 'darwin') {
// Setup the crash handling for mac renderer processes
// https://github.com/electron/electron/blob/master/docs/api/crash-reporter.md#crashreporterstartoptions
console.log('macOS renderer crash reporting initialized')
require('../app/crash-herald').init()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should probably go in app/common/crash-herald, but that doesn't block this review.

}
}

// Notify that renderer crash reporting is disabled
const disableCrashReporting = () => {
console.log('Disabling renderer crash reporting')
}

const React = require('react')
Expand Down Expand Up @@ -77,6 +85,12 @@ window.addEventListener('beforeunload', function () {

// get appStore from url
ipc.on(messages.INITIALIZE_WINDOW, (e, disposition, appState, frames, initWindowState) => {
// Configure renderer crash reporting
if (appState.settings[require('./constants/settings').SEND_CRASH_REPORTS] !== false) {
setupCrashReporting()
} else {
disableCrashReporting()
}
appStoreRenderer.state = Immutable.fromJS(appState)
ReactDOM.render(
<Window includePinnedSites={disposition !== 'new-popup'} frames={frames} initWindowState={initWindowState} />,
Expand Down