Help: Webview Very Slow vs. Chrome Browser


#1

I’ve noticed that the page load times (via webview) are nearly half the speed as if I load the same url into Chrome directly. Can anyone provide insight into why this might be or what I might be able to investigate to resolve my speed issues?


#2

Normal website url or internal company url something with basic authentication.
Are you using any proxy to access websites.

If it is normal url please share i try to test it from my side


#3

It is an internal company website with basic authentication via https. In my index.html, I load a sidebar that links the three internal pages via:

        <li>
            <a href="#gpage" onclick="loadFile('./page1.html');">Finances</a>
        </li>
        <li>
            <a href="#gpage" onclick="loadFile('./page2.html');">Payroll</a>
        </li>
        <li>
            <a href="#gpage" onclick="loadFile('./page3.html');">Logout</a>
        </li>

Each of the three html pages (page1.html, page2.html, and page3.html) includes a very simple body:

<body>
    <webview id="foo" src="https://example.com/login" style="display:inline-flex"></webview>       
  </body>

Each of those three pages loads js as follows:

<!-- jQuery -->
<script src="js/jquery.js"></script>     
<script src="js/jquery.js"></script>

<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>

<!-- Menu Toggle Script -->
<script>
$("#menu-toggle").click(function(e) {
    e.preventDefault();
    $("#wrapper").toggleClass("toggled");
});
</script>
     
  <script>
// You can also require other files to run in this process
require('./renderer.js')
  onload = () => {
const webview = document.querySelector('webview')
const indicator = document.querySelector('.indicator')

const loadstart = () => {
  indicator.innerText = 'loading...'
}

const loadstop = () => {
  indicator.innerText = ''
}

webview.addEventListener('did-start-loading', loadstart)
webview.addEventListener('did-stop-loading', loadstop)
  }
  </script>

What could be going on?


#4

How you are authenticating/passing credentials.Are you using

const {app} = require('electron')
app.on('login', (event, webContents, request, authInfo, callback) => {
  event.preventDefault()
  callback('username', 'secret')
})

or

session.defaultSession.allowNTLMCredentialsForDomains('*');

I am using second one ntlm for me also it is slow compare to chrome.
I didn’t tested with first method.

I assume It will try to access url, once it is failed it will fallback and use username and password so it is causing the delay.

I am not sure this is a bug or not but if you feel this is a bug, please create issue in https://github.com/electron/electron/issues


#5

Interesting. I’m glad I’m not the only one.

Actually, I’m just using a webview without authentication (the credentials are entered via the webview, so nothing is stored locally and there is no API callback). I wonder if the rendering on chromium is an issue for specific versions of OSX (I’m using Sierra 10.12.3). Have you been able to replicate the slowness on another OS?