5

I am porting an Electron app from a traditional renderer + webview architecture to one that uses BrowserView objects. The application uses some BrowserWindows to display a webview fullscreen in all available monitors. The renderer processes hold basically an index.html with a webview at 100% size.

I am little confused about the renderer process and the BrowserViews.

With the new approach, I just inject the preload script into the BrowserView constructor, and do not load any page on the BrowserWindow themselves:

browserViewOptions = {
    webPreferences: {
        preload: (__dirname + "/preload.js"),
        partition: "persist:ns",
        nodeIntegration: false,
        plugins: false
    }
};
  1. What renderer process is this? Is it the traditional render process where the webviews used to be? Or do the BrowserViews have their own renderer process?
    1. If it is the traditional way, is it shared in the case where I also load a page in the BrowserWindow?
  2. Does it matter that I am not loading a page into the BrowserWindow? I mean, if I don't load a page in the BrowserWindow (and just create the window to attach a BrowserView to it), is there another Chromium process with an empty page running?
    1. If yes, can this be prevented if I am only interested in the BrowserView?
  3. Are there "overdraw" issues if I keep stuff on the BrowserWindow and occasionally hide the BrowserViews to display them?
pushkin
  • 9,575
  • 15
  • 51
  • 95
rupps
  • 9,712
  • 4
  • 55
  • 95

1 Answers1

0

What renderer process is this?

Unlike the <webview>, the BrowserView does not use another renderer process. You can verify this by observing the number of processes that appear when running some basic code like this:

const mainWindow = new BrowserWindow();
const view = new BrowserView();
view.webContents.loadFile("index.html");
mainWindow.setBrowserView(view);

You won't get an extra renderer process.

Does it matter that I am not loading a page into the BrowserWindow?

A difference in what exactly? The number of renderer processes? No, it doesn't.

is there another Chromium process with an empty page running? If yes, can this be prevented if I am only interested in the BrowserView?

Are you asking if the empty BrowserWindow results in a redundant renderer process with "about:blank" in it? It doesn't result in an extra process, but yes I believe the window is implicitly navigated to about:blank. (I could be wrong about this though, because mainWindow.webContents.getURL() logs "". Explicitly navigating it to "about:blank" correctly logs "about:blank").

You don't really need to prevent anything.

However, I will add that if your entire window is going to load a single BrowserView with node integration turned off, as far as I can tell, you don't get any benefit from using a BrowserView and should just do the following instead:

const mainWindow = new BrowserWindow({
    webPreferences: {
        preload: (__dirname + "/preload.js"),
        partition: "persist:ns",
        nodeIntegration: false,
        plugins: false
    }
});

Are there "overdraw" issues if I keep stuff on the BrowserWindow and occasionally hide the BrowserViews to display them?

You may need to clarify what your question is, but the stuff loaded into the BrowserWindow will always be there and will appear when hiding the BrowserView.

pushkin
  • 9,575
  • 15
  • 51
  • 95