问题描述
我已经设置了一个 简单的 Electron 应用,它显示了一个普通的 html 文件,它始终需要超过两秒启动.关键绩效衡量指标是:
I have setup a trivial Electron app which shows a plain html file and it consistently takes more than two seconds to start up. The key performance measurements are:
- 170 毫秒:屏幕上出现一个空白窗口
- 2800 ms:窗口显示指定的 HTML
经过询问后,我发现问题是由Windows Defender引起的.禁用其实时保护可以获得可接受的启动速度:
After asking about it, I discovered that the problem is caused by Windows Defender. Disabling its real-time protection gets us an acceptable startup speed:
- 150 毫秒:屏幕上出现一个空白窗口
- 500 ms:窗口显示指定的 HTML
虽然这种加速完全解决了问题,但要求用户禁用 Windows Defender 以加快启动速度是行不通的.
While this speedup solves the problem completely, it is a no-go to ask users to disable Windows Defender in order to have faster startup.
我观察到一些流行的 Electron 应用程序(例如 Visual Studio Code)具有正常的启动时间,因此我认为有一种方法可以在不禁用 Windows Defender 的情况下实现这一目标.问题是:如何?
I have observed some popular Electron apps, like Visual Studio Code, have normal startup time so I assume there is a way to achieve that without disabling Windows Defender. The question is: how?
我唯一想到的是签署电子二进制文件,希望它能解决问题.但是由于签名证书要花钱,所以我宁愿在走这条路之前确定我需要它.如果有这方面经验的人能插话就太好了!
The only thing that comes to my mind is signing the electron binary, in the hope that it solves the problem. But since a signing certificate costs money I'd rather be sure I need it before going down this route. It would be great if someone with experience on this area could chime in!
我正在寻找一种不需要告诉我的用户修改他们的环境的解决方案.
I am looking for a solution that doesn't require telling my users to modify their environment.
推荐答案
最好的办法是将您的可执行文件作为示例提交给 MS Defender Team 以供审查:https://www.microsoft.com/en-us/wdsi/filesubmission,在评论中提及您的问题.他们几乎每天都在发布防御者更新,所以这应该没什么大不了的
Your best bet would be to submit your executable to MS Defender Team as sample for review at: https://www.microsoft.com/en-us/wdsi/filesubmission, mention in comment your issue. They are releasing defender updates almost daily basis so it should not be a big deal
您还可以帮助自己做的另一件事是将您的 exe 放在 Defender AV 的排除列表中(大多数 Microsoft 受信任的位置通常都在排除中),所以这应该没有问题.
One more thing you can help yourself with is to get your exe in the exclusion list of Defender AV (mostly Microsoft trusted locations are often in exclusions) so it should be no brainer.
当然,同时与 Microsoft 一起开一个案例来帮助您.
And of course open a case with Microsoft in parallel to help you there.
这篇关于Windows Defender 减慢 Electron 的启动速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!