electron: [Bug]: The first call of `loadFile`/`loadURL` takes 2 seconds
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
16.0.6
What operating system are you using?
Windows
Operating System Version
21H1
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
The first call of BrowserWindow.loadFile
/BrowserWindow.loadURL
takes up 100 ms ideally, or at least up to 300 ms.
Actual Behavior
The first call of BrowserWindow.loadFile
/BrowserWindow.loadURL
takes 1.8-2.3 seconds.
See the more detailed results: https://github.com/electron/electron/issues/32375#issuecomment-1010608115
Testcase Gist URL
https://gist.github.com/AlttiRi/d51f33beef067b54689fecf4fe5d46fa
Use node exec-npm-start.js
, or node exec-electron-dot.js
for profiling.
UPD: The new version of the test gist: https://gist.github.com/AlttiRi/ddff57964472f3c4ccc3eb0dacf2073b
Additional Information
I use the hello world example project: https://github.com/electron/electron-quick-start#to-use
The first HTML rendering (loadFile
), or site opening (loadURL
) is too slow — it takes ~2 seconds.
console.time("load");
await mainWindow.loadFile("index.html");
// await mainWindow.loadURL("https://google.com"); // or
console.timeEnd("load");
It works the same way on my main OS, as well as on a clear virtual machine.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 3
- Comments: 36 (15 by maintainers)
In comparison:
Neutralino.js takes 700 ms total (from the program start to show the rendered HTML).
NW.js takes 450-500 ms total.
UPD:
While Electron takes:
With the old Electron 7.1.1:
With the new Electron 16.0.6:
So, total time is: 3+ seconds with Electron 16.0.6.
3 SECONDS for the opening of the hello world example? Really?
@herrbasan FWIW, the VS Code binary itself is signed.
I tried signing my own binary (not the installer) as well as all .dlls, but it didn’t fix the problem. I also tried to not load a file from the file system (which could trigger a virus scanner), but just a hardcoded HTML string from memory like this:
That didn’t fix the problem either, but at least there is some benefit with this approach: we show the window as early as possible and only start loading the URL when the window is already shown. Until then the windows is blank, but I think the earlier feedback is worth it.
Here is my question, how does VS Code solve the problem? It is not plagued with the slow startup times as other Electron based apps. From what I understand, you can’t really sign an electron app, you can only sign the installer. So I wonder if MS is just sneaky and has whitelisted VS Code in the Defender database?!
I suggest you test it yourself, it is not difficult to add a whitelist. Of course it’s okay to shutdown the antivirus software. 😀
@ckerr your Fiddle is missing an
await
, so you’re not actually timing the time it takes for it to load just the time theloadFile
call takesThis issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, “bump”), and we’ll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
As we see, This problem has been around for a long time(From 2015) Should we do something about it?
Someone said submiting executable file to MS Defender Team would solve this issue, I’m not sure. https://stackoverflow.com/a/68121212
This is a problem caused by antivirus software
Add to whitelist
How about this issue’s progress?