7

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.

Praneet Rohida
  • 278
  • 1
  • 2
  • 10

4 Answers4

6

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.

SBD
  • 126
  • 1
  • 6
  • for me, this method works when I run my app from the command line (script: `electron .`). But it does nothing when I run the packaged app. Any idea why the difference? – David Burson Oct 28 '22 at 16:07
2

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.

OJ Kwon
  • 4,385
  • 1
  • 20
  • 24
1

According to the docs, the proper way of calling appendSwitch is:

app.commandLine.appendSwitch(switch[, value])

As mentioned in OJ Kwon's answer, apparently enable-features is explicitly disabled by Electron. If that wasn't true, you would be able to set it with the following syntax:

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

See Supported Chrome Command Line Switches for more examples.

GChuf
  • 1,135
  • 1
  • 17
  • 28
mathielo
  • 6,725
  • 7
  • 50
  • 63
0

In order to use app.commandLine.appendSwitch be sure to not use '--' your call should look like this

app.commandLine.appendSwitch('enable-features=GuestViewCrossProcessFrames');
DEDaniel
  • 191
  • 3
  • I haven't tested your method - perhaps it works, but I believe the more standard way to do this is to split the flag and value separately: app.commandLine.appendSwitch('enable-features', 'GuestViewCrossProcessFrames'); – RocketMan Aug 06 '20 at 12:25