跳转到主内容

· 阅读时间:约 2 分钟

Electron is changing its primary S3 bucket, you may need to update your build scripts


What is happening?

A significant amount of Electron's build artifacts are uploaded to an S3 bucket called gh-contractor-zcbenz. As part of ongoing infrastructure/ownership migrations that started way back in 2020, we will be changing everything that used gh-contractor-zcbenz from its old home in S3 to a new storage system hosted at https://artifacts.electronjs.org. The path prefix that most of our assets use is changing slightly as well. Examples are included below:

Before: https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/v17.0.0/node.lib
After: https://artifacts.electronjs.org/headers/dist/v17.0.0/node.lib

The important things here are the Hostname changed and the /atom-shell prefix changed. Another example, this time for debug symbols:

Before: https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/symbols/path/to/symbol.pdb
After: https://artifacts.electronjs.org/symbols/path/to/symbol.pdb

Again, the hostname changed and the /atom-shell prefix was changed.

How might this impact you?

Anyone using standard build tooling such as electron-rebuild, electron-packager or @electron/get won't have to do anything. This should be the majority of people.

For anyone directly referencing the S3 bucket, you must update your reference to point at the hostname and update the path as well.

What about existing data?

Most data that existed on the gh-contractor-zcbenz bucket has been cloned into the new storage system. This means all debug symbols and all headers have been copied. If you relied on some data in that bucket that hasn't been copied over please raise an issue in electron/electron and let us know.

The current gh-contractor-zcbenz S3 bucket will not be actively deleted. However, we can't guarantee how long that bucket will be left alive. We strongly recommend updating to target the new bucket as soon as possible.

· 阅读时间:约 5 分钟

Electron 18.0.0 已发布! 它包括升级到 Chromium 100, V8 10.0, 和 Node.js 16.13.2。 请阅读下文了解更多详情!


Electron 团队很高兴发布了 Electron 18.0.0.0! 您可以通过 npm install electron@later 进行安装,或者从我们的 发布网站 下载它。 继续阅读有关此版本的详细信息,并请分享您的任何反馈!

值得注意的变化

Electron 发布时间变更

从 Electron 15 开始,Electron 将每 8 周发布一个新的主要稳定版本。 您可以在此处阅读 完整详细信息

此外,Electron 将会改变支持的版本,从最新的三个版本改为最新的四个版本,直到 2022 年 5 月。 关于 Electron 版本的更多详细信息,请看我们的 版本管理文档 2022 年 5 月以后,我们将回到支持最新的三个版本。

Stack 更改

主要特性

  • 增加 ses.setCodeCachePath() API,用于设置代码缓存目录。 #33286
  • 移除了基于旧的 BrowserWindowProxywindow.open 实现。 这也删除了 webPreferences 中的 nativeWindowOpen 选项。 #29405
  • WebContents 中增加了 'focus' 和 'blur' 事件。 #25873
  • 在 MacOS 上添加了替换菜单角色:showSubstitutions``toggleSmartQuotes``toggleSmartDashes``toggleTextReplacement #32024
  • app.requestSingleInstanceLock() 流中增加了 first-instance-ack 事件,以便用户就可以将一些数据从第二个实例传回给第一个实例。 #31460
  • setBackgroundColor 中增加了更多颜色的支持。 #33364

有关新功能和变更的完整列表,请参阅 18.0.0 发布通知

破坏性 & API 更改

以下是 Electron 18 中引入的突破性变化。 有关这些和未来变化的更多信息可在 计划的突破性变化 页面找到。

已移除: nativeWindowOpen

在 Electron 15之前, window.open 默认使用 BrowserWindowProxy。 这意味着 window.open('about:blank') 无法打开可同步编写脚本的子窗口,以及有其他不兼容之处。 自 Electron 15 起, nativeWindowOpen 将默认启用。

有关更多详细信息,请参阅 Electron 中的 window.open 文档。 删除此功能的 PR: #29405

终止对 14.x.y 的支持

根据项目的支持政策,Electron 14.x.y 已经达到了支持的终点。 我们鼓励开发者和应用程序升级到更新的 Electron版本。

从 Electron 15 开始,我们已经将支持的版本从最新的三个版本改为最新的四个版本,直到 2022 年 5 月的 Electron 19。 在 Electron 19 之后,我们将回归到支持最新的三个版本。 此版本支持变化是我们新的节奏变化的一部分。 请参阅 我们的博客文章 ,了解的完整详细信息。

E15 (9 月 21 号)E16 (11 月 21 号)E17 (2 月 22 号)E18 (3 月 22 号)E19 (5 月 22 号)
15.x.y16.x.y17.x.y18.x.y19.x.y
14.x.y15.x.y16.x.y17.x.y18.x.y
13.x.y14.x.y15.x.y16.x.y17.x.y
12.x.y13.x.y14.x.y15.x.y--

接下来

在短期内,你可以期待我们的团队继续专注于跟上构成 Electron 的主要组件的发展,包括 Chromium、Node 和 V8。 尽管我们很谨慎,不对发布日期作出承诺,但我们的计划是大约每两个月发布一次 Electron 的主要版本和这些组件的新版本。

您可以在此处找到 Electron的公开时间表

有关这些和未来变化的更多信息可在 计划的突破性变化 页面找到。

· 阅读时间:约 2 分钟

The Electron team is excited to announce that we will be participating in Google Summer of Code for the first time this year!


What is Google Summer of Code?

Google Summer of Code (GSoC) is a yearly mentoring program connecting open source software projects with potential contributors. Previously open only to students, anyone ages 18 and up can now register for GSoC.

For more information, check out the Summer of Code homepage.

我该如何参加?

Are you interested in collaborating with Electron? If you are a new or beginner open source contributor, we welcome you to apply!

In order to be selected as an Electron contributor for Google Summer of Code, you will need to submit an application. Applications will open on April 4th, 2022 and close on April 19th, 2022. You can follow updates for Google: Summer of Code application guidelines here.

Want to apply? First, check out the five project idea drafts that we have prepared. All of the listed ideas are currently open for proposals. We are also open to accepting new ideas that are not on the proposed project list.

Your application should include:

  • Your proposal, which is a written document that describes in detail what you plan to achieve over the course of the summer.
  • Your background as a developer. If you have a resume, please include a copy, otherwise tell us about your past experience with an emphasis on relevant technical experience.

A detailed guide of what to submit as part of your Electron application is here.

You can also read through the official GSoC student/contributor guide for important tips on preparing your proposal.

If you want to discuss project proposals or have questions, come hang out in our #gsoc-general Discord channel!

引用

· 阅读时间:约 4 分钟

Electron 17.0.0 已发布! 它包括升级到 Chromium 98, V8 9.8, 和 Node.js 16.13.0。 请阅读下文了解更多详情!


Electron 团队很高兴发布了 Electron 17.0.0.0! 您可以通过 npm install electron@later 进行安装,或者从我们的 发布网站 下载它。 继续阅读有关此版本的详细信息,并请分享您的任何反馈!

Notable Changes

Electron 发布时间变更

As of Electron 15, Electron will release a new major stable version every 8 weeks. 您可以在此处阅读 完整详细信息

Additionally, Electron has changed supported versions from latest three versions to latest four versions until May 2022. See our versioning document for more detailed information about versioning in Electron. After May 2022, we will return to supporting latest three versions.

Stack Changes

Highlighted Features

  • Added webContents.getMediaSourceId(), can be used with getUserMedia to get a stream for a WebContents. #31204
  • Deprecates webContents.getPrinters() and introduces webContents.getPrintersAsync(). #31023
  • desktopCapturer.getSources is now only available in the main process. #30720

See the 17.0.0 release notes for a full list of new features and changes.

重大更改

Below are breaking changes introduced in Electron 17. 有关这些和未来变化的更多信息可在 计划的突破性变化 页面找到。

desktopCapturer.getSources in the renderer

The desktopCapturer.getSources API is now only available in the main process. This has been changed in order to improve the default security of Electron apps.

API 更改

There were no API changes in Electron 17.

Removed/Deprecated Changes

  • Usage of the desktopCapturer.getSources API in the renderer has been removed. See here for details on how to replace this API in your app.

终止对 13.x.y 的支持

Electron 13.x.y has reached end-of-support as per the project's support policy. Developers and applications are encouraged to upgrade to a newer version of Electron.

As of Electron 15, we have changed supported versions from latest three versions to latest four versions until May 2022 with Electron 19. 在 Electron 19 之后,我们将回归到支持最新的三个版本。 此版本支持变化是我们新的节奏变化的一部分。 请参阅 我们的博客文章 ,了解的完整详细信息。

E15 (Sep'21)E16 (Nov'21)E17 (Feb'22)E18 (Mar'22)E19 (May'22)
15.x.y16.x.y17.x.y18.x.y19.x.y
14.x.y15.x.y16.x.y17.x.y18.x.y
13.x.y14.x.y15.x.y16.x.y17.x.y
12.x.y13.x.y14.x.y15.x.y--

What's Next

In the short term, you can expect the team to continue to focus on keeping up with the development of the major components that make up Electron, including Chromium, Node, and V8. Although we are careful not to make promises about release dates, our plan is to release new major versions of Electron with new versions of those components approximately every 2 months.

您可以在此处找到 Electron的公开时间表

有关这些和未来变化的更多信息可在 计划的突破性变化 页面找到。

· 阅读时间:约 2 分钟

Spectron 将于 2022 年 2 月 1 日弃用。


Beginning in February 2022, Spectron will be officially deprecated by the Electron team.

Why Deprecate Spectron?

While Spectron has consistently put out new releases for each new version of Electron, the project has had very little maintenance and improvements for well over a year, and currently has no full-time maintainers. With the remote module moving outside of Electron core and into an external module in Electron 14, Spectron will require a major rewrite to continue working reliably.

After reviewing several available options for Spectron's continued maintenance, the Electron team has decided to deprecate Spectron in 2022.

Deprecation Timeline

The following is our planned deprecation timeline:

  • November 2021 - January 2022: The Electron team will continue to accept pull requests from the community.
  • January 2022: A final version of announcement warning about Spectron's deprecation will be released.
  • February 1, 2022: Spectron's repo will be marked as "archived". No more pull requests will be accepted.

Following February 1st, 2022, Electron will continue to leave the Spectron repo up indefinitely, so that others are welcome to fork or use the existing code for their projects. We hope this will help provide a longer transition to any projects that may still depend on Spectron.

Alternatives to Spectron

如果您当前在项目中使用 Spectron,并希望迁移到替代测试解决方案,您可以在此处阅读我们的 自动化测试指南

我们目前有其他几种推荐替代Spectron的办法,包括Playwright和WebDriverIO。 Official tutorials for each option can be found in our Automated Testing documentation.

What's Next

We here on the Electron team appreciate you using Spectron and Electron. 我们理解,你们中的许多人都依赖 Spectron 来测试您的应用程序,我们希望让这种过渡尽可能轻松。 感谢您选择Electron!

· 阅读时间:约 4 分钟

Electron 16.0.0 已发布! 它包括升级到 Chromium 96, V8 9.6, 和 Node.js 16.9.1。 请阅读下文了解更多详情!


Electron 团队很高兴发布了 Electron 16.0.0.0! 您可以通过 npm install electron@later 进行安装,或者从我们的 发布网站 下载它。 继续阅读有关此版本的详细信息,并请分享您的任何反馈!

Notable Changes

Electron 发布时间变更

As of Electron 15, Electron will release a new major stable version every 8 weeks. 您可以在此处阅读 完整详细信息

Additionally, Electron has changed supported versions from latest three versions to latest four versions until May 2022. See our versioning document for more detailed information about versioning in Electron. After May 2022, we will return to supporting latest three versions.

Stack Changes

Highlighted Features

  • Now supports the WebHID API. #30213
  • Add data parameter to app.requestSingleInstanceLock to share data between instances. #30891
  • Pass securityOrigin to media permissions request handler. #31357
  • Add commandLine.removeSwitch. #30933

See the 16.0.0 release notes for a full list of new features and changes.

重大更改

Below are breaking changes introduced in Electron 16. 有关这些和未来变化的更多信息可在 计划的突破性变化 页面找到。

Building Native Modules

If your project uses node-gyp to build native modules, you may need to call it with --force-process-config depending on your project's setup and your Electron version. More information about this change can be found at #2497.

Behavior Changed: crashReporter implementation switched to Crashpad on Linux

The underlying implementation of the crashReporter API on Linux has changed from Breakpad to Crashpad, bringing it in line with Windows and Mac. As a result of this, child processes are now automatically monitored, and calling process.crashReporter.start in Node child processes is no longer needed (and is not advisable, as it will start a second instance of the Crashpad reporter).

There are also some subtle changes to how annotations will be reported on Linux, including that long values will no longer be split between annotations appended with __1, __2 and so on, and instead will be truncated at the (new, longer) annotation value limit.

API 更改

There were no API changes in Electron 16.

Removed/Deprecated Changes

  • Usage of the desktopCapturer.getSources API in the renderer has been deprecated and will be removed. This change improves the default security of Electron apps. See here for details on how to replace this API in your app.

End of Support for 12.x.y

Electron 12.x.y has reached end-of-support as per the project's support policy. Developers and applications are encouraged to upgrade to a newer version of Electron.

As of Electron 15, we have changed supported versions from latest three versions to latest four versions until May 2022 with Electron 19. 在 Electron 19 之后,我们将回归到支持最新的三个版本。 此版本支持变化是我们新的节奏变化的一部分。 请参阅 我们的博客文章 ,了解的完整详细信息。

E15 (Sep'21)E16 (Nov'21)E17 (Feb'22)E18 (Mar'22)E19 (May'22)
15.x.y16.x.y17.x.y18.x.y19.x.y
14.x.y15.x.y16.x.y17.x.y18.x.y
13.x.y14.x.y15.x.y16.x.y17.x.y
12.x.y13.x.y14.x.y15.x.y--

What's Next

In the short term, you can expect the team to continue to focus on keeping up with the development of the major components that make up Electron, including Chromium, Node, and V8. Although we are careful not to make promises about release dates, our plan is to release new major versions of Electron with new versions of those components approximately every 2 months.

您可以在此处找到 Electron的公开时间表

有关这些和未来变化的更多信息可在 计划的突破性变化 页面找到。

· 阅读时间:约 2 分钟

The Electron project will pause for the month of December 2021, then return to full speed in January 2022.

via GIPHY


What will be the same in December

  1. Zero-day and other major security-related releases will be published as necessary. Security incidents should be reported via SECURITY.md.
  2. Code of Conduct reports and moderation will continue.

What will be different in December

  1. No new Beta or Stable releases in December. No Nightly releases for the last two weeks of December.
  2. With few exceptions, no pull request reviews or merges.
  3. No issue tracker updates on any repositories.
  4. No Discord debugging help from maintainers.
  5. No social media content updates.

Why is this happening?

In short, while maintainers are happy and engaged with the project, THE WORLD IS TIRED. December is a quiet month for most companies, so we want to give our maintainers a chance to recharge. We encourage other projects to consider similar measures.

Should I be worried about the future of Electron?

否. We are able to take this step because the project is in good shape. Everyone is looking forward to 2022, and we expect good things to come!

· 阅读时间:约 6 分钟

Electron 15.0.0 已发布! 它包括升级到 Chromium 94, V8 9.4, 和 Node.js 16.5.0。 我们已经添加了多个针对 window.open 的 API 更新、bug 修复和常规改进。 请阅读下文了解更多详情!


Electron 团队很高兴发布了 Electron 15.0.0.0! 您可以通过 npm install electron@later 进行安装,或者从我们的 发布网站 下载它。 继续阅读有关此版本的详细信息,并请分享您的任何反馈!

Notable Changes

Electron 发布时间变更

从 Electron 15 开始,Electron 将每隔8周发布一个新的主要稳定版本。 您可以在此处阅读 完整详细信息

此外,Electron 将在 2022 年 5 月之前,将支持的版本从最新的三个版本更改为最新的四个版本。 查看我们的版本文档以了解更多关于 Electron 版本的详细信息。

Stack Changes

Highlight Features

  • nativeWindowOpen: true 不再是实验性的,现在是默认设置。
  • 新增了 safeStorage 字符串加密 API。 #30430
  • WebContents 新增 'frame-created' 事件,该事件在页面中创建帧时发出。 #30801
  • BrowserWindowwill-resize 事件添加了用以调整窗口大小的 edge 信息。 #29199

有关新功能和变更的完整列表,请参阅 15.0.0 发布通知

重大更改

以下是 Electron 15 中引入的突破性变化。 有关这些和未来变化的更多信息可在 计划的突破性变化 页面找到。

默认值更改:nativeWindowOpen 默认设为 true

在 Electron 15之前, window.open 默认使用 BrowserWindowProxy。 这意味着 window.open('about:blank') 无法打开可同步编写脚本的子窗口,以及有其他不兼容之处。 nativeWindowOpen: true 不再是实验性的,现在是默认设置。

有关更多详细信息,请参阅 Electron 中 window.open 的文档。

API 更改

  • WebContents 新增 'frame-created' 事件,该事件在页面中创建帧时发出。 #30801
  • 新增了 safeStorage 字符串加密 API。 #30430
  • dialog.showMessageBox 新增了 signal 选项。 #26102
  • 加入 Electron Fuse,用于在应用程序加载的 app.asar 文件上强制执行代码签名。 要求最新的 asar 模块(v3.1.0 或更高版本)。 #30900
  • 加入 fuses 以在打包好的应用里,禁用 NODE_OPTIONS--inspect 调试参数。 #30420
  • 新增 MenuItem.userAccelerator 属性以读取用户分配的 macOS 快捷键的覆盖。 #26682
  • 新增 app.runningUnderARM64Translation 属性以检测在 Rosetta 在 Apple Silicon 或 WOW 在 Windows 上运行 ARM 时的情况。 #29168
  • 添加新的 imageAnimationPolicy Web 首选项来控制图像的动画方式。 #29095
  • 增加支持通过 context bridge 发送 Blob。 #29247

Removed/Deprecated Changes

没有 API 被删除或废弃。

支持版

此外,Electron 将在 2022 年 5 月之前,将支持的版本从最新的三个版本更改为最新的四个版本。 在 Electron 19 之后,我们将回归到支持最新的三个版本。 此版本支持变化是我们新的节奏变化的一部分。 请参阅 我们的博客文章 ,了解的完整详细信息。

鼓励开发者和应用程序升级到 Electron 的较新版本。

E15 (Sep'21)E16 (Nov'21)E17 (Feb'22)E18 (Mar'22)E19 (May'22)
15.x.y16.x.y17.x.y18.x.y19.x.y
14.x.y15.x.y16.x.y17.x.y18.x.y
13.x.y14.x.y15.x.y16.x.y17.x.y
12.x.y13.x.y14.x.y15.x.y--

接下来

短期内, 您可以期待团队继续专注于跟上 Electron 主要组件的开发工作。 包括 Chromium, Node 和 V8。 尽管我们谨慎地避免对发布日期做出承诺,但我们的计划是大约每季度发布一次 Electron 的新主要版本以及这些组件的新版本。

您可以在此处找到 Electron的公开时间表

有关这些和未来变化的更多信息可在 计划的突破性变化 页面找到。

· 阅读时间:约 6 分钟

Electron 14.0.0 已发布! 它包括了到 Chromium 93 和 V8 9.3 的更新。 我们添加了多个 API 更新、错误修复和一般改进。 请阅读下文了解更多详情!


Electron 团队很高兴发布了 Electron 14.0.0.0! You can install it with npm via npm install electron@latest or download it from our releases website. Continue reading for details about this release and please share any feedback you have!

Notable Changes

Electron 发布时间变更

Beginning in September 2021 with Electron 15, Electron will release a new major stable version every 8 weeks. 您可以在此处阅读 完整详细信息。 Electron 15 will begin beta on September 1, 2021 and stable release will be on September 21, 2021. You can find Electron's public timeline here.

Additionally, Electron will be changing supported versions from latest three versions to latest four versions until May 2022. See see our versioning document for more detailed information about versioning in Electron.

Stack Changes

Highlight Features

  • Default Changed: nativeWindowOpen now defaults to true. (see docs)
  • Child windows no longer inherit BrowserWindow construction options from their parents. #28550
  • Added new session.storagePath API to get the path on disk for session-specific data. #28665
  • Added process.contextId used by @electron/remote. #28007
  • Added experimental cookie encryption support behind an Electron Fuse. #29492

See the 14.0.0 release notes for a full list of new features and changes.

重大更改

Below are breaking changes introduced in Electron 14. More information about these and future changes can be found on the Planned Breaking Changes page.

已移除: app.allowRendererProcessReuse

The app.allowRendererProcessReuse property has been removed as part of our plan to more closely align with Chromium's process model for security, performance and maintainability.

For more detailed information see #18397.

Removed: Browser Window Affinity

The affinity option when constructing a new BrowserWindow has been removed as part of our plan to more closely align with Chromium's process model for security, performance and maintainability.

For more detailed information see #18397.

API 更改: window.open()

The optional parameter frameName no longer sets the title of the window. This behavior now follows the specification described by the native documentation for the windowName parameter.

If you were using this parameter to set the title of a window, you can instead use the win.setTitle(title) method.

已移除: worldSafeExecuteJavaScript

worldSafeExecuteJavaScript has been removed with no alternative. Please ensure your code works with this property enabled. It has been enabled by default since Electron 12.

若您使用了 webFrame.executeJavaScriptwebFrame.executeJavaScriptInIsolatedWorld,这个改动会对您造成影响。 您需要保证 Context Bridge API 支持这些方法的返回值,因为这些方法使用相同的值传递语义。

默认更改: nativeWindowOpen 默认为 true

Prior to Electron 14, window.open was by default shimmed to use BrowserWindowProxy. This meant that window.open('about:blank') did not work to open synchronously scriptable child windows, among other incompatibilities. nativeWindowOpen is no longer experimental, and is now the default.

See the documentation for window.open in Electron for more details.

Removed: BrowserWindowConstructorOptions inheriting from parent windows

Prior to Electron 14, windows opened with window.open would inherit BrowserWindow constructor options such as transparent and resizable from their parent window. Beginning with Electron 14, this behavior has been removed and windows will not inherit any BrowserWindow constructor options from their parents.

Instead, explicitly set options for the new window with setWindowOpenHandler:

webContents.setWindowOpenHandler((details) => {
return {
action: 'allow',
overrideBrowserWindowOptions: {
// ...
}
}
})

已移除: additionalFeatures

The deprecated additionalFeatures property in the new-window and did-create-window events of WebContents has been removed. Since new-window uses positional arguments, the argument is still present, but will always be the empty array []. (Note: the new-window event itself is already deprecated and has been replaced by setWindowOpenHandler.) Bare keys in window features will now present as keys with the value true in the options object.

// Removed in Electron 14
// Triggered by window.open('...', '', 'my-key')
webContents.on('did-create-window', (window, details) => {
if (details.additionalFeatures.includes('my-key')) {
// ...
}
})

// Replace with
webContents.on('did-create-window', (window, details) => {
if (details.options['my-key']) {
// ...
}
})

Removed: remote module

Deprecated in Electron 12, the remote module has now been removed from Electron itself and extracted into a separate package, @electron/remote. The @electron/remote module bridges JavaScript objects from the main process to the renderer process. This lets you access main-process-only objects as if they were available in the renderer process. This is a direct replacement for the remote module. See the module's readme for migration instructions and reference.

API 更改

  • Added BrowserWindow.isFocusable() method to determine whether a window is focusable. #28642
  • Added WebFrameMain.visibilityState instance property. #28706
  • Added disposition, referrer and postBody to the details object passed to the window open handler registered with setWindowOpenHandler. #28518
  • Added process.contextId used by @electron/remote. #28007
  • Added experimental cookie encryption support behind an Electron Fuse. #29492
  • Added missing resourceType conversions for webRequest listener details: font, ping, cspReport, media, webSocket. #30050
  • Added new session.storagePath API to get the path on disk for session-specific data. #28665
  • Added support for Windows Control Overlay on macOS. #29986
  • Added support for directing Chromium logging to a file with --log-file=.../path/to/file.log. Also, it's now possible to enable logging from JavaScript by appending command-line switches during the first JS tick. #29963
  • Added support for the des-ede3 cipher in node crypto. #27897
  • Added a ContextBridgeMutability feature that allows context bridge objects to be mutated. #27348

Removed/Deprecated Changes

The following APIs have been removed or are now deprecated:

  • The remote module has been removed after being deprecated in Electron 12. #25734
  • Child windows no longer inherit BrowserWindow construction options from their parents. #28550
  • Removed deprecated additionalFeatures property from new-window and did-create-window WebContents events. #28548
  • Removed the deprecated app.allowRendererProcessReuse and BrowserWindow affinity options. #26874
  • The submitURL option for crashReporter.start is no longer a required argument when uploadToServer is false. #28105

End of Support for 11.x.y

Electron 11.x.y has reached end-of-support as per the project's support policy. Developers and applications are encouraged to upgrade to a newer version of Electron.

What's Next

In the short term, you can expect the team to continue to focus on keeping up with the development of the major components that make up Electron, including Chromium, Node, and V8. Although we are careful not to make promises about release dates, our plan is release new major versions of Electron with new versions of those components approximately quarterly.

For information on planned breaking changes in upcoming versions of Electron, see our Planned Breaking Changes.

· 阅读时间:约 8 分钟

在过去几周里,我们收到了关于新的 WebView2 和 Electron 之间差异的几个问题。

我们两个团队都致力于让 Web 技术在桌面上能发挥出最佳效用,同时互相讨论比较了二者之间的共性与不同之处。

Electron 和 WebView2 都处在一个快速不断发展的进程中。 我们将对 Electron 与 WebView2 之间现有的相似之处与不同的地方做简短的概述。


架构概述

Electron 和 WebView2 都是从 Chromium 源代码构建的,用于渲染网页内容。 严格地说,WebView2 是从 Edge 源构建的,Edge 构建于 Chromium 源的一个分支上。 Electron 不与 Chrome 共享任何 DLL。 WebView2 的二进制文件与 Edge 硬链接(Edge 90 的稳定版本),因此他们共享磁盘和一些工作集。 更多信息,请参阅 Evergreen distribution mode

Electron 应用程序总是以开发时确认的 Electron 版本,打包和发布。 WebView2 有两个分布选项。 你可以打包确切的 WebView2 库到你的应用程序,或你可以使用系统中已经存在的共享运行版本。 WebView2 为每种方法提供了工具,包括缺少共享运行时的引导安装程序。 WebView2 从 Windows 11 开始直接提供。

打包框架的应用程序负责更新框架,包括安全的次要版本。 对于使用共享 WebView2 运行时的应用,WebView2 具有自己的更新程序,类似于 Chrome 或 Edge,独立于您的应用程序。 要更新应用程序自己的代码或其它依赖仍然是开发人员自己负责,这与 Electron 一样。 无论是 Electron,还是 WebView2 都不受 Windows Update 管理。

Electron 和 WebView2 都继承了 Chromium 的多进程架构,即一个主进程与一个或多个渲染器进程相连。 这些进程与系统上运行的其他应用程序完全分离。 每个 Electron 应用程序都是一个单独的进程树,包含一个根浏览器进程、一些公共进程以及零个或多个渲染进程。 WebView2 应用间使用相同的 用户数据文件夹 (就像一套应用一样),共享非渲染进程。 WebView2 应用使用不同的 数据文件夹,不共享进程。

  • ElectronJS 进程模型:

    ElectronJS 进程模型图解

  • 基于 WebView2 的应用程序进程模型:

    WebView2 进程模型图解

了解关于 WebView2 进程模型 Electron 进程模型 的更多信息。

Electron 提供常见的桌面应用程序所需要的 API,如菜单、文件系统访问、通知等等。 WebView2 是一个组件,意味着需要被集成到应用程序框架中,如 WinForms、WPF、WinUI 或 Win32。 WebView2 不提供 Web 标准 JavaScript 之外的操作系统 API。

Node.js 被集成到 Electron 中。 Electron应用程序可以在渲染进程和主进程中使用,任何 Node.js API,模块,或 node 本地模块(node-native-addon)。 WebView2 不知道您的应用程序使用哪种语言或框架编写。 您的 JavaScript 代码必须通过应用程序主进程代理操作系统访问。

Electron 努力维持与 Web API 的兼容性,包括从 Fugu Project 被开发的 API。 我们有一个 Electron 的 Fugu API 兼容快照。 WebView2 维护着一个 与 Edge 差异 API (API differences from Edge) 相似的列表。

Electron 为 web 内容提供一个可配置的安全模型,从完全访问到完全沙箱。 WebView2 内容始终是沙盒。 Electron 为您选择安全模型提供 全面的安全文档 。 WebView2 也有提供 安全最佳实践

Electron 源码在 GitHub 上维护与获取。 应用程序可以自己修改,构建属于自己的 独特 Electron. WebView2 源码不能在 Github 上获取。

摘要:

ElectronWebView2
构建依赖ChromiumEdge
源码在 Github
共享 Edge/Chrome 动态库是 (从 Edge 90 版本)
应用程序之间的共享运行时可选
应用程序 API
Node.js
Sandbox可选始终
需要应用程序框架
支持平台Mac, Win, LinuxWin (Mac/Linux 计划中)
应用之间的进程共享从不可选
框架更新管理通过应用程序WebView2

性能讨论

在渲染 Web 内容时,我们认为 Electron,WebView2 和其他基于 Chromium 的渲染之间的性能差异很小。 我们为感兴趣研究性能间差异的人员,以 Electron、C++ + WebView2 和 C# + WebView2 创建了 脚手架

在渲染 Web 内容 之外 有一些差异,来自 Electron,WebView2,Edge,PWA,和 其它表示感兴趣工作的详细比较。

进程间通信 (IPC)

我们明确强调一个差异,因为我们认为这通常是 Electron 应用程序中的性能考虑因素。

在 Chromium 中,浏览器进程(browser process)作为渲染进程沙盒与系统其部分间的 IPC 中间人。 虽然 Electron 允许未沙盒化的渲染进程,但很多应用程序仍选择启用沙盒以增加安全性。 WebView2 始终启用沙盒,所以对于大多数 Electron 和 WebView2 应用程序,IPC 可能会影响整体性能。

尽管 Electron 和 WebView2 具有相似的进程模型,但底层 IPC 不同。 在 JavaScript 和 C++ 或 C# 之间进行通信需要 转换(marshalling),常见的是 JSON 字符串。 JSON 序列化/解析是一项代价高昂的操作,IPC 瓶颈可能会对性能产生负面影响。 从 Edge 93 开始,Webview2 将针对网络事件使用 CBOR(简洁的二进程序列化)

Electron 通过 MessagePorts API 支持任何两个进程之间的直接 IPC,利用 结构化克隆算法。 利用此手段的应用程序可以避免在进程之间发送对象时支付 JSON 序列化税。

摘要

Electron 和 WebView2 有一些差异,但在他们如何执行 Web 内容方面不会有太大差异。 最后,应用程序架构和 JavaScript 库/框架对内存和性能的影响比其他任何内容都要大,因为无论 Chromium 运行在何处, Chromium 都是 Chromium

特别感谢 WebView2 团队审阅了这篇文章,并确保我们拥有 WebView2 架构的最新视图。 他们欢迎对项目的任何反馈意见