mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
ELECTRON-655: implement dynamic chrome command line flags logic (#471)
- implement dynamic chrome command line flags logic - added more validation
This commit is contained in:
parent
d6dbdb866d
commit
c4726a9dc2
62
js/main.js
62
js/main.js
@ -20,7 +20,7 @@ const {
|
|||||||
updateUserConfigOnLaunch,
|
updateUserConfigOnLaunch,
|
||||||
getUserConfigField
|
getUserConfigField
|
||||||
} = require('./config.js');
|
} = require('./config.js');
|
||||||
const {setCheckboxValues} = require('./menus/menuTemplate.js');
|
const { setCheckboxValues } = require('./menus/menuTemplate.js');
|
||||||
const { isMac, isDevEnv } = require('./utils/misc.js');
|
const { isMac, isDevEnv } = require('./utils/misc.js');
|
||||||
const protocolHandler = require('./protocolHandler');
|
const protocolHandler = require('./protocolHandler');
|
||||||
const getCmdLineArg = require('./utils/getCmdLineArg.js');
|
const getCmdLineArg = require('./utils/getCmdLineArg.js');
|
||||||
@ -65,7 +65,7 @@ function initializeCrashReporter(podUrl) {
|
|||||||
|
|
||||||
getConfigField('crashReporter')
|
getConfigField('crashReporter')
|
||||||
.then((crashReporterConfig) => {
|
.then((crashReporterConfig) => {
|
||||||
crashReporter.start({companyName: crashReporterConfig.companyName, submitURL: crashReporterConfig.submitURL, uploadToServer: crashReporterConfig.uploadToServer, extra: {'process': 'main', podUrl: podUrl}});
|
crashReporter.start({ companyName: crashReporterConfig.companyName, submitURL: crashReporterConfig.submitURL, uploadToServer: crashReporterConfig.uploadToServer, extra: { 'process': 'main', podUrl: podUrl } });
|
||||||
log.send(logLevels.INFO, 'initialized crash reporter on the main process!');
|
log.send(logLevels.INFO, 'initialized crash reporter on the main process!');
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -135,9 +135,6 @@ function setChromeFlags() {
|
|||||||
app.commandLine.appendSwitch('auth-negotiate-delegate-whitelist', config.customFlags.authNegotiateDelegateWhitelist);
|
app.commandLine.appendSwitch('auth-negotiate-delegate-whitelist', config.customFlags.authNegotiateDelegateWhitelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ELECTRON-261: Windows 10 Screensharing issues. We set chrome flags
|
|
||||||
// to disable gpu which fixes the black screen issue observed on
|
|
||||||
// multiple monitors
|
|
||||||
if (config.customFlags.disableGpu) {
|
if (config.customFlags.disableGpu) {
|
||||||
log.send(logLevels.INFO, 'Setting disable gpu, gpu compositing and d3d11 flags to true');
|
log.send(logLevels.INFO, 'Setting disable gpu, gpu compositing and d3d11 flags to true');
|
||||||
app.commandLine.appendSwitch("disable-gpu", true);
|
app.commandLine.appendSwitch("disable-gpu", true);
|
||||||
@ -148,6 +145,53 @@ function setChromeFlags() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.commandLine.appendSwitch("disable-background-timer-throttling", true);
|
app.commandLine.appendSwitch("disable-background-timer-throttling", true);
|
||||||
|
|
||||||
|
if (isDevEnv) {
|
||||||
|
setChromeFlagsFromCommandLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function setChromeFlagsFromCommandLine() {
|
||||||
|
|
||||||
|
log.send(logLevels.INFO, 'Setting chrome flags from command line arguments!');
|
||||||
|
|
||||||
|
let chromeFlagsFromCmd = getCmdLineArg(process.argv, '--chrome-flags=', false);
|
||||||
|
if (!chromeFlagsFromCmd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let chromeFlagsArgs = chromeFlagsFromCmd.substr(15);
|
||||||
|
if (!chromeFlagsArgs) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let flags = chromeFlagsArgs.split(',');
|
||||||
|
if (!flags || !Array.isArray(flags)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let key in flags) {
|
||||||
|
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(flags, key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!flags[key]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let flagArray = flags[key].split(':');
|
||||||
|
|
||||||
|
if (flagArray && Array.isArray(flagArray) && flagArray.length > 0) {
|
||||||
|
let chromeFlagKey = flagArray[0];
|
||||||
|
let chromeFlagValue = flagArray[1];
|
||||||
|
log.send(logLevels.INFO, `Setting chrome flag ${chromeFlagKey} to ${chromeFlagValue}`);
|
||||||
|
app.commandLine.appendSwitch(chromeFlagKey, chromeFlagValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the chrome flags
|
// Set the chrome flags
|
||||||
@ -167,14 +211,14 @@ app.on('ready', () => {
|
|||||||
* Is triggered when all the windows are closed
|
* Is triggered when all the windows are closed
|
||||||
* In which case we quit the app
|
* In which case we quit the app
|
||||||
*/
|
*/
|
||||||
app.on('window-all-closed', function() {
|
app.on('window-all-closed', function () {
|
||||||
app.quit();
|
app.quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is triggered when the app is up & running
|
* Is triggered when the app is up & running
|
||||||
*/
|
*/
|
||||||
app.on('activate', function() {
|
app.on('activate', function () {
|
||||||
if (windowMgr.isMainWindow(null)) {
|
if (windowMgr.isMainWindow(null)) {
|
||||||
setupThenOpenMainWindow();
|
setupThenOpenMainWindow();
|
||||||
} else {
|
} else {
|
||||||
@ -192,7 +236,7 @@ app.setAsDefaultProtocolClient('symphony');
|
|||||||
* at this moment, support for windows
|
* at this moment, support for windows
|
||||||
* is in pipeline (https://github.com/electron/electron/pull/8052)
|
* is in pipeline (https://github.com/electron/electron/pull/8052)
|
||||||
*/
|
*/
|
||||||
app.on('open-url', function(event, url) {
|
app.on('open-url', function (event, url) {
|
||||||
handleProtocolAction(url);
|
handleProtocolAction(url);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -321,7 +365,7 @@ function getUrlAndCreateMainWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getConfigField('url')
|
getConfigField('url')
|
||||||
.then(createWin).catch(function(err) {
|
.then(createWin).catch(function (err) {
|
||||||
log.send(logLevels.ERROR, `unable to create main window -> ${err}`);
|
log.send(logLevels.ERROR, `unable to create main window -> ${err}`);
|
||||||
app.quit();
|
app.quit();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user