久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

處理緩慢的電子啟動

Dealing with slow Electron startup(處理緩慢的電子啟動)
本文介紹了處理緩慢的電子啟動的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我花了幾個小時玩 Electron,我觀察到在屏幕上繪制一個簡單的 html 文件始終需要超過 2.5 秒.時間線大致如下:

I have spent some hours playing with Electron and I have observed that it consistently takes more than 2.5 seconds to draw a trivial html file to the screen. The timeline is roughly as follows:

  • 60 毫秒:app ready 事件被觸發(fā);我們使用 new BrowserWindow()
  • 創(chuàng)建一個窗口
  • 170 毫秒:屏幕上出現(xiàn)一個空白窗口
  • 2800 毫秒:窗口顯示指定的 HTML
  • 60 ms: app ready event is triggered; we create a window using new BrowserWindow()
  • 170 ms: a blank window appears on the screen
  • 2800 ms: the window shows the specified HTML

我已經(jīng)用我的代碼建立了一個 存儲庫,該代碼源自 Electron 的 快速開始 docs.

I have set up a repository with my code, which is derived from Electron's quick start docs.

關于我的機器,我在 2016 年的 ThinkPad T460 上運行 Windows 10,配備 SSD 和足夠的內(nèi)存.

Regarding my machine, I am running Windows 10 on a ThinkPad T460 from 2016 with a SSD and enough memory.

發(fā)送一個在啟動時顯示一個空白窗口的應用程序?qū)ξ襾碚f是不行的.我假設大多數(shù)開發(fā) Electron 應用程序的人都有類似的想法.因此我的第一個問題是:我做錯了什么嗎?或者這是一個普通 Electron 應用程序的預期加載時間?

Shipping an application that shows a blank window for so long upon startup is a no-go for me. I assume most people developing Electron apps think similarly. Hence my first question: am I doing something wrong? Or is this the expected loading time for a trivial Electron app?

假設這是正常行為,處理此問題的常用方法是什么?想到了一些想法:

Assuming this is normal behavior, what is the common way to deal with this problem? Some ideas come to mind:

  1. 要求 Electron 顯示啟動畫面:除非有特定的內(nèi)置功能,否則似乎不行,因為啟動畫面本身只會在 2.5 秒后顯示.
  2. 隱藏應用程序的窗口直到它被渲染(使用 ready-to-show 事件),所以不會顯示空白窗口.這并不理想,因為這意味著用戶不會得到任何關于應用程序?qū)嶋H加載的反饋.
  3. 創(chuàng)建一個包裝應用程序(使用本機代碼),該應用程序顯示啟動屏幕、啟動電子并在顯示電子窗口后隱藏自身.一開始就有點違背了使用 Electron 的目的,因為您最終會編寫本機代碼并意外增加復雜性.
  4. 按照 文檔.這看起來不太好.
  1. Asking Electron to show a splash screen: unless there is specific built-in functionality for this, it seems like a no-go, since the splash screen itself would be shown only after 2.5 seconds.
  2. Hide the app's window until it is rendered (using the ready-to-show event), so no blank window is shown. This isn't ideal, since it means that the user doesn't get any feedback whatsoever that the application is actually loading.
  3. Create a wrapper application (using native code) that displays a splash screen, launches electron and hides itself once the electron window is shown. Kind of defeats the purpose of using Electron in the first place, because you end up writing native code and adding accidental complexity.
  4. Setting the background color of the window to something resembling your app, as suggested by the docs. This just doesn't look very well.

鑒于這一定是一個普遍的問題,我希望社區(qū)已經(jīng)找到了標準的解決方案.如果有人能指出我正確的方向,我會很高興.

Given this must be a common problem, I hope standard solutions have been found by the community. I'd be glad if someone can point me in the right direction.

推薦答案

簡答

Windows Defender 導致速度變慢,因此這不是 Electron 問題.

Short answer

Windows Defender is causing the slowdown, so this is not an Electron problem.

事實證明,Windows Defender 實時保護導致啟動持續(xù)時間比所需時間長得多.關閉實時保護后,我們獲得了可以接受的性能:

It turns out that Windows Defender real-time protection causes startup to last much longer than needed. After turning real-time protection off, we achieved acceptable performance:

  • 55 毫秒:應用就緒
  • 150 毫秒:顯示空白窗口
  • 500 毫秒:加載并顯示 HTML

這意味著我提出的解決方案中的選項 1(顯示啟動屏幕)對于加載緩慢的應用應該非常有效.

This means that option 1 of my proposed solutions (showing a splash screen) should work quite well for slow-loading apps.

剩下的唯一事情就是弄清楚如何解決 Windows Defender 問題.為此,我提出了一個新問題.

The only thing left is to figure out how to solve the Windows Defender problem. For that purpose, I have asked a new question.

這篇關于處理緩慢的電子啟動的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創(chuàng)建子窗口時如何修復 BrowserWindow 不是構(gòu)造函數(shù)錯誤) - IT屋-程序員軟件開發(fā)技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執(zhí)行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內(nèi)使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網(wǎng)絡攝像頭?)
主站蜘蛛池模板: 国产日韩一区二区 | 日韩精品一区二区三区在线观看 | 一区二区三区中文字幕 | 日韩av在线免费 | 国产精品99 | 一区二区三区视频免费看 | 最新中文字幕在线 | 国产精品美女一区二区 | 国产一区二区免费 | 成人一区二区电影 | 亚洲一区二区在线播放 | 日本91av视频 | 日本a视频 | 欧美精品91爱爱 | 美女福利视频 | 九色国产 | 日韩中文字幕在线不卡 | 国产精品99久久久久久久久久久久 | 亚洲区一区二 | 一区二区精品视频 | 在线免费观看成年人视频 | 欧美日韩国产精品一区 | 国产精品久久久久久福利一牛影视 | 女同久久另类99精品国产 | 国产日韩欧美另类 | 日韩福利片 | 久久久久久成人 | 欧美日韩黄 | 97伦理最新伦理 | 99在线视频观看 | 91视频大全| 国内精品免费久久久久软件老师 | 97久久超碰 | caoporn地址 | 欧美不卡一区二区三区 | 精品国产乱码久久久久久1区2区 | 日韩午夜网站 | 国产精品久久久久久久午夜片 | 91中文字幕在线观看 | 欧美精品成人一区二区三区四区 | 黄色在线免费观看视频网站 |