提交 8e169b60 编写于 作者: B Benjamin Pasero

electron 3.0.x: use the --no-untrusted-code-mitigations flag

Since Electron 3 we use a V8 version that comes with untrusted code mitigations enabled by default (https://v8.dev/docs/untrusted-code-mitigations). This comes at a performance cost according to the blog. Since we do not execute untrusted code, we disable these mitigations.
上级 ac0ead21
......@@ -164,14 +164,25 @@ function configureCommandlineSwitches(cliArgs, nodeCachedDataDir) {
* @returns {string}
*/
function resolveJSFlags(cliArgs, ...jsFlags) {
// Add any existing JS flags we already got from the command line
if (cliArgs['js-flags']) {
jsFlags.push(cliArgs['js-flags']);
}
// Support max-memory flag
if (cliArgs['max-memory'] && !/max_old_space_size=(\d+)/g.exec(cliArgs['js-flags'])) {
jsFlags.push(`--max_old_space_size=${cliArgs['max-memory']}`);
}
// Since Electron 3 we use a V8 version that comes with untrusted code mitigations
// enabled by default (https://v8.dev/docs/untrusted-code-mitigations). This comes
// at a performance cost according to the blog. Since we do not execute untrusted
// code, we disable these mitigations.
// TODO@Ben revisit this for later Electron versions, search for more usages of
// --no-untrusted-code-mitigations
jsFlags.push('--no-untrusted-code-mitigations');
return jsFlags.length > 0 ? jsFlags.join(' ') : null;
}
......
......@@ -196,6 +196,11 @@ export class Client implements IChannelClient, IDisposable {
forkOpts.execArgv = ['--nolazy', '--inspect-brk=' + this.options.debugBrk];
}
if (!Array.isArray(forkOpts.execArgv)) {
forkOpts.execArgv = [];
}
forkOpts.execArgv.push('--no-untrusted-code-mitigations');
this.child = fork(this.modulePath, args, forkOpts);
const onMessageEmitter = new Emitter<Buffer>();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册