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:
Vishwas Shashidhar 2018-08-22 15:41:33 +05:30 committed by GitHub
parent d6dbdb866d
commit c4726a9dc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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