electronmon icon indicating copy to clipboard operation
electronmon copied to clipboard

BrowserView doesn't get reloaded

Open Awendel opened this issue 2 years ago • 2 comments

When having a BrowserView nested inside BrowserWindow and a renderer file changes for the BrowserView, the change is detected in the console, but the BrowserView doesn't get refreshed, so one is currently forced to manually restart.

Awendel avatar Oct 06 '21 09:10 Awendel

Hmm, I am not seeing that in my apps that use BrowserView. Are you able to provide a small example application that reproduces this issue?

catdad avatar Oct 06 '21 11:10 catdad

Sorry, was very busy and didn't have time to create a test. I did go through your code though, found & fixed the issue.

the affected script is hook.js

The current code

function reload() {
  const windows = electron.BrowserWindow.getAllWindows()> 
  if (windows && windows.length) {
    for (const win of windows) {
      win.webContents.reloadIgnoringCache()
    }
  }
}

My Code that actually reloads all BrowserViews associated with the Window:

function reload() {
  const windows = electron.BrowserWindow.getAllWindows();

  if (windows && windows.length) {
    for (const win of windows) {
      win.webContents.reloadIgnoringCache()  
   
      const views = win.getBrowserViews()
      views.forEach(function(view){
        view.webContents.reloadIgnoringCache()
      })

    }
  }
}

Could just be added as a quick Pull request to fix it upstream, sadly will have to get back right away to work and won't be able to do it myself, but the fix is there.

Awendel avatar Oct 26 '21 10:10 Awendel