Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a chromium command line flag in Electron?

I am working on an Electron app and need to enable the following Chromium flag GuestViewCrossProcessFrames to make scaling work with webview.

I tried calling the following line in my main.js but it doesn't seem to work. Also tried enabling plugins for the BrowserWindow as well as webview.

app.commandLine.appendSwitch('--enable-features=GuestViewCrossProcessFrames');

Can someone help me setting up this flag? Thank you.

like image 430
Praneet Rohida Avatar asked Jan 28 '23 17:01

Praneet Rohida


2 Answers

you can set by calling

const { app } = require('electron');
app.commandLine.appendSwitch('enable-features', 'GuestViewCrossProcessFrames');
app.on('ready', () => {
// place your code.
}

note: you need to call it before ready event emitted.

like image 88
SBD Avatar answered Jan 30 '23 07:01

SBD


It is not clear to me why Electron does this though specific flag you specified is explicitly disabled in electron

https://github.com/electron/electron/blob/bcbcb4c6436e84e7f1f2387c2d7581bbdadb5732/brightray/browser/browser_main_parts.cc#L185-L187

So you can't enable it dynamically.

like image 42
OJ Kwon Avatar answered Jan 30 '23 06:01

OJ Kwon