Skip to main content

2022 年维护者峰会回顾

· 12 min read

¥Maintainer Summit 2022 Recap

上个月,Electron 的维护小组在加拿大温哥华开会,讨论该项目 2023 年及以后的发展方向。在会议室里,核心维护人员和受邀的合作者讨论了四天的新计划、维护痛点以及项目的总体健康状况。

¥Last month, Electron’s maintainer group met up in Vancouver, Canada to discuss the direction of the project for 2023 and beyond. Over four days in a conference room, core maintainers and invited collaborators discussed new initiatives, maintenance pain points, and general project health.

Group Photo! Taken by @groundwater.

展望未来,团队仍将全力以赴地定期快速发布 Chromium 升级,修复错误,并使 Electron 更加安全、高效,造福所有人。我们还有一些正在进行的激动人心的项目,很乐意与社区分享!

¥Going forward, the team will still be fully dedicated to releasing regular and rapid Chromium upgrades, fixing bugs, and making Electron more secure and performant for everyone. We also have a few exciting projects in the works we would love to share with the community!

变革性的新 API

¥Transformative new APIs

Electron 项目中需要达成共识的主要 API 提案将经过征求意见稿 (RFC) 流程,并由 API 工作组成员进行审核。

¥Major API proposals in the Electron project that require consensus go through a Request for Comments (RFC) process, which gets reviewed by members of our API Working Group.

今年,我们推进了两项重要提案,它们有可能为 Electron 应用开启新的功能维度。这些提案仍处于高度实验性阶段,但让我们先睹为快!

¥This year, we have driven forward two major proposals that have the potential to unlock a new dimension of capabilities for Electron apps. These proposals are highly experimental, but here’s a sneak peek of what to expect!

新的原生插件增强功能 (C API)

¥New native addon enhancements (C APIs)

此提案概述了 Electron C API 的新层,允许应用开发者编写自己的原生 Node 插件,并与 Electron 的内部资源进行交互,类似于 Node 自身的 Node-API。有关拟议的新 API 可以在这里找到 的更多信息。

¥This proposal outlines a new layer of Electron C APIs that will allow app developers to write their own Native Node Addons that interface with Electron’s internal resources, similar to Node’s own Node-API. More information about the proposed new API can be found here.

示例:使用 Chromium 资源为应用增压

¥Example: Supercharging apps with Chromium resources

许多 Electron 应用维护自己的分支,以便直接与 Chromium 内部组件交互,否则原始(未修改的)Electron 无法访问这些组件。通过在 C API 层公开这些资源,这些代码可以作为原生模块与 Electron 共存,从而潜在地减轻应用开发者的维护负担。

¥Many Electron apps maintain their own forks to interact directly with Chromium internals that would otherwise be inaccessible with vanilla (unmodified) Electron. By exposing these resources in the C API layer, this code can instead live as a native module alongside Electron, potentially reducing app developer maintenance burden.

公开 Chromium 的 UI 层(Views API)

¥Exposing Chromium’s UI layer (Views API)

Chrome 用户界面 (UI) 中非网站部分,例如工具栏、标签页或按钮,都是基于名为 Views 的框架构建的。Views API 提案将该框架的部分内容作为 JavaScript 类引入到 Electron 中,最终目标是允许开发者为其 Electron 应用创建非 Web UI 元素。这将防止应用拼凑网页内容。

¥Under the hood, the non-website parts of Chrome’s user interface (UI), such as toolbars, tabs, or buttons, are built with a framework called Views. The Views API proposal introduces parts of this framework as JavaScript classes in Electron, with the eventual goal of allowing developers to create non-web UI elements to their Electron applications. This will prevent apps from having to hack together web contents.

目前正在进行实现这套新 API 的基础工作。以下是一些你近期可以期待的早期功能。

¥The groundwork to make this new set of APIs possible is currently in progress. Here are a few of the first things you can expect in the near future.

示例:使用 WebContentsView 重构窗口模型

¥Example: Refactoring the window model with WebContentsView

我们计划的第一个变更是将 Chrome 的 WebContentsView 暴露给 Electron 的 API 接口,这将取代我们现有的 BrowserView API(尽管名称如此,但它是 Electron 特有的代码,与 Chromium Views 无关)。随着 WebContentsView 的公开,我们将拥有一个可重用的 View 对象,它可以显示 Web 内容,从而为将 BrowserWindow 类变成纯 JavaScript 语言打开了大门,并进一步降低了代码复杂性。

¥Our first planned change is to expose Chrome’s WebContentsView to Electron’s API surface, which will be the successor to our existing BrowserView API (which, despite the name, is Electron-specific code unrelated to Chromium Views). With WebContentsView exposed, we will have a reusable View object that can display web contents, opening the door to making the BrowserWindow class pure JavaScript and eliminating even more code complexity.

虽然此更改并未为应用开发者提供太多新功能,但它是一项大型重构,能够消除大量底层代码,简化 Chromium 升级,并降低主要版本之间出现新 bug 的风险。

¥Although this change doesn’t provide a lot of new functionality to app developers, it is a large refactor that eliminates a lot of code under the hood, simplifying Chromium upgrades and reducing the risk of new bugs appearing between major versions.

如果你是 Electron 开发者,并在应用中使用 BrowserViews:别担心,我们没有忘记你!我们计划将现有的 BrowserView 类作为 WebContentsView 的填充程序,以便在你过渡到较新的 API 时提供缓冲。

¥If you’re an Electron developer using BrowserViews in your app: don’t worry, we haven’t forgotten about you! We plan on making the existing BrowserView class a shim for WebContentsView to provide a buffer as you transition to the newer APIs.

看:electron/electron#35658

¥See: electron/electron#35658

示例:使用 ScrollView 滚动网页内容

¥Example: Scrollable web contents with ScrollView

我们在 Stack 的朋友们一直在推动一项计划,将 Chromium ScrollView 组件开放给 Electron 的 API。使用此新 API,任何子视图组件都可以水平或垂直滚动​​。

¥Our friends at Stack have been driving an initiative to expose the Chromium ScrollView component to Electron’s API. With this new API, any child View component can be made scrollable horizontally or vertically.

虽然这个新 API 仅实现了一个较小的功能,但团队的最终目标是构建一组实用的 View 组件,可用作构建更复杂的非 HTML 界面的工具包。

¥Although this new API fulfills a single smaller functionality, the team’s eventual goal is to build a set of utility View components that can be used as a toolkit to build more complex non-HTML interfaces.

参与其中

¥Getting involved

你是一位 Electron 应用开发者,对这两个 API 提案感兴趣吗?虽然我们尚未准备好接收更多 RFC,但请继续关注未来的更多详细信息!

¥Are you an Electron app developer interested in either of these API proposals? Although we’re not quite ready to receive additional RFCs, please stay tuned for more details in the future!

Electron Forge v6 稳定版

¥Electron Forge v6 stable release

自该框架诞生以来,Electron 的构建工具生态系统主要由社区驱动,包含许多小型的单一用途软件包(例如 electron-winstaller、electron-packager、electron-notarize 和 electron-osx-sign)。虽然这些工具运行良好,但对于用户来说,拼凑一个可行的构建流程却令人望而生畏。

¥Since the framework’s inception, Electron’s build tooling ecosystem has been largely community-driven and has consisted of many small single-purpose packages (e.g. electron-winstaller, electron-packager, electron-notarize, electron-osx-sign). Although these tools work well, it’s intimidating for users to piece together a working build pipeline.

为了给 Electron 开发者打造更友好的体验,我们构建了 Electron Forge,这是一个一体化解决方案,将所有现有工具整合到一个界面中。尽管 Forge 自 2017 年以来一直在开发中,但该项目在过去几年中一直处于停滞状态。然而,考虑到社区对 Electron 构建工具状态的反馈,我们一直在努力发布 Forge 的下一代稳定主版本。

¥To help build a friendlier experience for Electron developers, we built Electron Forge, an all-in-one solution that combines all this existing tooling into a single interface. Although Forge has been in development since 2017, the project has lain dormant for the last few years. However, given community feedback on the state of build tooling in Electron, we have been hard at work on releasing the next-gen stable major version of Forge.

Electron Forge 6 提供一流的 TypeScript 和 Webpack 支持,以及一个可扩展的 API,允许开发者创建自己的插件和安装程序。

¥Electron Forge 6 comes with first-class TypeScript and Webpack support, as well as an extensible API that allows developers to create their own plugins and installers.

敬请期待:即将发布公告

¥Stay tuned: announcement coming soon

如果你有兴趣使用 Forge 构建项目,或者使用 Forge 可扩展的第三方 API 构建模板或插件,请持续关注我们本月发布的 Forge v6 稳定版官方公告!

¥If you’re interested in building a project with Forge or building templates or plugins with Forge’s extensible third-party APIs, stay tuned for our official announcement on the Forge v6 stable release sometime this month!

下一步是什么?

¥What’s next?

除此之外,团队一直在考虑一系列探索性项目,以改善应用开发者和终端用户的 Electron 体验。我们正在尝试其他更新工具、API 审核流程和增强文档。我们希望在不久的将来有更多新闻分享!

¥Aside from the above, the team is always thinking of a bunch of exploratory projects to make the Electron experience better for app developers and end users. Updater tooling, API review processes, and enhanced documentation are other things we are experimenting with. We hope to have more news to share in the near future!

Electron 21.0.0

· 5 min read

Electron 21.0.0 已发布!它包含对 Chromium 106、V8 10.6 和 Node.js 16.16.0 的升级。请阅读下文了解更多详情!

¥Electron 21.0.0 has been released! It includes upgrades to Chromium 106, V8 10.6, and Node.js 16.16.0. Read below for more details!


Electron 团队非常高兴地宣布 Electron 21.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息。

¥The Electron team is excited to announce the release of Electron 21.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.

如果你有任何反馈,请在 Twitter 上与我们分享,或加入我们的社区 Discord!可以在 Electron 的 问题跟踪器 中报告错误和功能请求。

¥If you have any feedback, please share it with us on Twitter, or join our community Discord! Bugs and feature requests can be reported in Electron's issue tracker.

显著变化

¥Notable Changes

技术栈变更

¥Stack Changes

新功能

¥New Features

  • 添加了 webFrameMain.origin#35534

    ¥Added webFrameMain.origin. #35534

  • 添加了新的 WebContents.ipcWebFrameMain.ipc API。#35231

    ¥Added new WebContents.ipc and WebFrameMain.ipc APIs. #35231

  • 添加了对类似面板行为的支持。窗口可以悬浮在全屏应用上方。#34388

    ¥Added support for panel-like behavior. Window can float over full-screened apps. #34388

  • 添加了对 macOS 应用从 APNs 推送通知的支持。#33574

    ¥Added support for push notifications from APNs for macOS apps. #33574

重大变更和 API 变更

¥Breaking & API Changes

以下是 Electron 21 中引入的重大变更。

¥Below are breaking changes introduced in Electron 21.

V8 内存笼已启用

¥V8 Memory Cage Enabled

Electron 21 启用了 V8 沙盒指针,紧随 Chrome 的 决定在 Chrome 103 中也采取同样的措施 之后。这对原生模块有一些影响。此功能具有性能和安全性优势,但也对原生模块施加了一些新的限制,例如指向外部("off-heap")内存的 ArrayBuffer 的使用。请参阅 这篇博文 了解更多信息。#34724

¥Electron 21 enables V8 sandboxed pointers, following Chrome's decision to do the same in Chrome 103. This has some implications for native modules. This feature has performance and security benefits, but also places some new restrictions on native modules, e.g. use of ArrayBuffers that point to external ("off-heap") memory. Please see this blog post for more information. #34724

重构 webContents.printToPDF

¥Refactored webContents.printToPDF

重构了 webContents.printToPDF 函数,使其与 Chromium 的 headless 实现保持一致。请参阅 #33654 了解更多信息。

¥Refactored webContents.printToPDF to align with Chromium's headless implementation. See #33654 for more information.

有关这些变更和未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about these and future changes can be found on the Planned Breaking Changes page.

18.x.y 支持终止

¥End of Support for 18.x.y

Electron 18.x.y 已根据项目 支持政策 终止支持。建议开发者和应用升级到较新版本的 Electron。

¥Electron 18.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.

E18 (2022 年 3 月)E19 (2022 年 5 月)E20 (2022 年 8 月)E21 (2022 年 9 月)E22 (2022 年 12 月)
18.x.y19.x.y20.x.y21.x.y22.x.y
17.x.y18.x.y19.x.y20.x.y21.x.y
16.x.y17.x.y18.x.y19.x.y20.x.y

下一步计划

¥What's Next

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。

¥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.

你可以找到 Electron 公开时间线

¥You can find Electron's public timeline here.

有关未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about future changes can be found on the Planned Breaking Changes page.

Electron 20.0.0

· 8 min read

Electron 20.0.0 已发布!它包含对 Chromium 104、V8 10.4 和 Node.js 16.15.0 的升级。请阅读下文了解更多详情!

¥Electron 20.0.0 has been released! It includes upgrades to Chromium 104, V8 10.4, and Node.js 16.15.0. Read below for more details!


Electron 团队非常高兴地宣布 Electron 20.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息,并请分享你的任何反馈!

¥The Electron team is excited to announce the release of Electron 20.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

新功能

¥New Features

  • 在 Windows 上添加了沉浸式暗黑模式。#34549

    ¥Added immersive dark mode on Windows. #34549

  • 添加了对类似面板行为的支持。窗口可以悬浮在全屏应用上方。#34665

    ¥Added support for panel-like behavior. Window can float over full-screened apps. #34665

  • 更新了 Windows Control Overlay 按钮,使其在 Windows 11 上的外观和体验更加原生。#34888

    ¥Updated Windows Control Overlay buttons to look and feel more native on Windows 11. #34888

  • 除非指定 nodeIntegration: truesandbox: false,否则渲染器现在默认处于沙盒状态。#35125

    ¥Renderers are now sandboxed by default unless nodeIntegration: true or sandbox: false is specified. #35125

  • 在使用 nan 构建原生模块时添加了安全措施。#35160

    ¥Added safeguards when building native modules with nan. #35160

技术栈变更

¥Stack Changes

重大变更和 API 变更

¥Breaking & API Changes

以下是 Electron 20 中引入的重大变更。有关这些变更和未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

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

默认更改:没有 nodeIntegration: true 的渲染器默认被沙箱化

¥Default Changed: renderers without nodeIntegration: true are sandboxed by default

以前,指定预加载脚本的渲染器默认为未沙箱化。这意味着默认情况下,预加载脚本可以访问 Node.js。在 Electron 20 中,这个默认值已经改变。从 Electron 20 开始,渲染器将默认被沙箱化,除非指定了 nodeIntegration: truesandbox: false

¥Previously, renderers that specified a preload script defaulted to being unsandboxed. This meant that by default, preload scripts had access to Node.js. In Electron 20, this default has changed. Beginning in Electron 20, renderers will be sandboxed by default, unless nodeIntegration: true or sandbox: false is specified.

如果你的预加载脚本不依赖于 Node,则无需执行任何操作。如果你的预加载脚本确实依赖于 Node,请重构它们以从渲染器中删除 Node 使用,或者为相关渲染器显式指定 sandbox: false

¥If your preload scripts do not depend on Node, no action is needed. If your preload scripts do depend on Node, either refactor them to remove Node usage from the renderer, or explicitly specify sandbox: false for the relevant renderers.

已修复:nan 原生模块自发崩溃

¥Fixed: spontaneous crashing in nan native modules

在 Electron 20 中,我们更改了两项与原生模块相关的内容:

¥In Electron 20, we changed two items related to native modules:

  1. V8 的头文件现在默认使用 c++17。此标志已添加到 electron-rebuild 中。

    ¥V8 headers now use c++17 by default. This flag was added to electron-rebuild.

  2. 我们修复了缺少 include 会导致依赖于 nan 的原生模块自发崩溃的问题。

    ¥We fixed an issue where a missing include would cause spontaneous crashing in native modules that depended on nan.

为了获得最高的稳定性,我们建议在重新构建原生模块(尤其是依赖于 nan 的模块)时使用 node-gyp >=8.4.0 和 electron-rebuild >=3.2.9。请参阅 electron #35160 和 node-gyp #2497 了解更多信息。

¥For the most stability, we recommend using node-gyp >=8.4.0 and electron-rebuild >=3.2.9 when rebuilding native modules, particularly modules that depend on nan. See electron #35160 and node-gyp #2497 for more information.

删除:Linux 上的 .skipTaskbar

¥Removed: .skipTaskbar on Linux

在 X11 上,skipTaskbar 向 X11 窗口管理器发送 _NET_WM_STATE_SKIP_TASKBAR 消息。Wayland 没有直接的等效项,并且已知的解决方法具有不可接受的权衡(例如 GNOME 中的 Window.is_skip_taskbar 需要不安全模式),因此 Electron 无法在 Linux 上支持此功能。

¥On X11, skipTaskbar sends a _NET_WM_STATE_SKIP_TASKBAR message to the X11 window manager. There is not a direct equivalent for Wayland, and the known workarounds have unacceptable tradeoffs (e.g. Window.is_skip_taskbar in GNOME requires unsafe mode), so Electron is unable to support this feature on Linux.

17.x.y 支持终止

¥End of Support for 17.x.y

Electron 17.x.y 已根据项目 支持政策 终止支持。建议开发者和应用升级到较新版本的 Electron。

¥Electron 17.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.

E18 (2022 年 3 月)E19 (2022 年 5 月)E20 (2022 年 8 月)E21 (2022 年 9 月)E22 (2022 年 12 月)
18.x.y19.x.y20.x.y21.x.y22.x.y
17.x.y18.x.y19.x.y20.x.y21.x.y
16.x.y17.x.y18.x.y19.x.y20.x.y
15.x.y--------

下一步计划

¥What's Next

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。虽然我们谨慎地不对发布日期做出承诺,但我们计划大约每两个月发布一次 Electron 的新主要版本及其组件的新版本。

¥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 公开时间线

¥You can find Electron's public timeline here.

有关未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about future changes can be found on the Planned Breaking Changes page.

Electron 和 V8 内存笼

· 16 min read

Electron 21 及更高版本将启用 V8 内存笼,这将对某些原生模块产生影响。

¥Electron 21 and later will have the V8 Memory Cage enabled, with implications for some native modules.


更新 (2022/11/01)

要跟踪 Electron 21+ 中关于原生模块使用情况的持续讨论,请参阅 electron/electron#35801

¥To track ongoing discussion about native module usage in Electron 21+, see electron/electron#35801.

在 Electron 21 中,我们将在 Electron 中启用 V8 沙盒指针,紧随 Chrome 的 决定在 Chrome 103 中也采取同样的措施 之后。这对原生模块有一些影响。此外,我们之前在 Electron 14 中启用了相关技术 指针压缩。当时我们并没有过多讨论指针压缩,但指针压缩确实会影响 V8 的最大堆大小。

¥In Electron 21, we will be enabling V8 sandboxed pointers in Electron, following Chrome's decision to do the same in Chrome 103. This has some implications for native modules. Also, we previously enabled a related technology, pointer compression, in Electron 14. We didn't talk about it much then, but pointer compression has implications for the maximum V8 heap size.

启用这两项技术后,将显著提升安全性、性能和内存使用率。然而,启用它们也有一些缺点。

¥These two technologies, when enabled, are significantly beneficial for security, performance and memory usage. However, there are some downsides to enabling them, too.

启用沙盒指针的主要缺点是指向外部("off-heap")内存的 ArrayBuffer 不再被允许。这意味着依赖于 V8 中此功能的原生模块需要重构才能继续在 Electron 20 及更高版本中工作。

¥The main downside of enabling sandboxed pointers is that ArrayBuffers which point to external ("off-heap") memory are no longer allowed. This means that native modules which rely on this functionality in V8 will need to be refactored to continue working in Electron 20 and later.

启用指针压缩的主要缺点是 V8 堆的最大大小限制为 4GB。具体细节有点复杂 - 例如,ArrayBuffers 与 V8 堆的其余部分分开计数,但都有各自的 自身的限制

¥The main downside of enabling pointer compression is that the V8 heap is limited to a maximum size of 4GB. The exact details of this are a little complicated—for example, ArrayBuffers are counted separately from the rest of the V8 heap, but have their own limits.

Electron 升级工作组 认为指针压缩和 V8 内存保护机制利大于弊。这样做主要有三个原因:

¥The Electron Upgrades Working Group believes that the benefits of pointer compression and the V8 memory cage outweigh the downsides. There are three main reasons for doing so:

  1. 它使 Electron 更接近 Chromium。Electron 在复杂的内部细节(例如 V8 配置)上与 Chromium 的差异越小,我们就越不可能意外引入错误或安全漏洞。Chromium 的安全团队非常强大,我们希望确保充分利用他们的成果。此外,如果一个 bug 仅影响 Chromium 中未使用的配置,那么修复它可能不会成为 Chromium 团队的首要任务。

    ¥It keeps Electron closer to Chromium. The less Electron diverges from Chromium in complex internal details such as V8 configuration, the less likely we are to accidentally introduce bugs or security vulnerabilities. Chromium's security team is formidable, and we want to make sure we are taking advantage of their work. Further, if a bug only affects configurations that aren't used in Chromium, fixing it is not likely to be a priority for the Chromium team.

  2. 性能提升。指针压缩可将 V8 堆大小减少高达 40%,并将 CPU 和 GC 性能提升 5% 至 10%。对于绝大多数不会遇到 4GB 堆大小限制且不使用需要外部缓冲区的原生模块的 Electron 应用来说,这些改进将带来显著的性能提升。

    ¥It performs better. Pointer compression reduces V8 heap size by up to 40% and improves CPU and GC performance by 5%–10%. For the vast majority of Electron applications which won't bump into the 4GB heap size limit and don't use native modules that require external buffers, these are significant performance wins.

  3. 更安全。一些 Electron 应用运行不受信任的 JavaScript(希望遵循我们的 安全建议!),对于这些应用,启用 V8 内存笼可以保护它们免受大量 V8 漏洞的攻击。

    ¥It's more secure. Some Electron apps run untrusted JavaScript (hopefully following our security recommendations!), and for those apps, having the V8 memory cage enabled protects them from a large class of nasty V8 vulnerabilities.

最后,对于确实需要更大堆大小的应用,有一些解决方法。例如,你可以在你的应用中包含一个 Node.js 副本,该副本在构建时禁用了指针压缩,并将占用大量内存的工作移至子进程。虽然有些复杂,但如果你决定根据特定用例进行不同的权衡,也可以构建一个禁用指针压缩的自定义 Electron 版本。最后,在不久的将来,wasm64 将允许使用 WebAssembly 在 Web 和 Electron 中构建的应用使用超过 4GB 的内存。

¥Lastly, there are workarounds for apps that really need a larger heap size. For example, it is possible to include a copy of Node.js with your app, which is built with pointer compression disabled, and move the memory-intensive work to a child process. Though somewhat complicated, it is also possible to build a custom version of Electron with pointer compression disabled, if you decide you want a different trade-off for your particular use case. And lastly, in the not-too-distant future, wasm64 will allow apps built with WebAssembly both on the Web and in Electron to use significantly more than 4GB of memory.


常见问题

¥FAQ

我如何知道我的应用是否受到此变更的影响?

¥How will I know if my app is impacted by this change?

在 Electron 20+ 版本中,尝试用 ArrayBuffer 封装外部内存会导致运行时崩溃。

¥Attempting to wrap external memory with an ArrayBuffer will crash at runtime in Electron 20+.

如果你的应用中未使用任何原生 Node 模块,则不会出现此崩溃 - 纯 JS 代码无法触发此崩溃。此更改仅影响在 V8 堆外分配内存(例如使用 mallocnew),然后用 ArrayBuffer 封装外部内存的原生 Node 模块。这是一个相当罕见的用例,但有些模块确实使用了这种技术,这些模块需要重构才能与 Electron 20+ 兼容。

¥If you don't use any native Node modules in your app, you're safe—there's no way to trigger this crash from pure JS. This change only affects native Node modules which allocate memory outside of the V8 heap (e.g. using malloc or new) and then wrap the external memory with an ArrayBuffer. This is a fairly rare use case, but some modules do use this technique, and such modules will need to be refactored in order to be compatible with Electron 20+.

如何测量我的应用使用了多少 V8 堆内存,以了解是否接近 4GB 的限制?

¥How can I measure how much V8 heap memory my app is using to know if I'm close to the 4GB limit?

在渲染器进程中,你可以使用 performance.memory.usedJSHeapSize,它将以字节为单位返回 V8 堆的使用情况。在主要流程中,你可以使用 process.memoryUsage().heapUsed,它与 Chromium 相当。

¥In the renderer process, you can use performance.memory.usedJSHeapSize, which will return the V8 heap usage in bytes. In the main process, you can use process.memoryUsage().heapUsed, which is comparable.

什么是 V8 内存笼?

¥What is the V8 memory cage?

一些文档将其称为 "V8 沙盒",但该术语很容易与 Chromium 中的 其他类型的沙盒 混淆,因此我坚持使用 "内存限制"。

¥Some documents refer to it as the "V8 sandbox", but that term is easily confusable with other kinds of sandboxing that happen in Chromium, so I'll stick to the term "memory cage".

有一种相当常见的 V8 漏洞利用方式如下:

¥There's a fairly common kind of V8 exploit that goes something like this:

  1. 在 V8 的 JIT 引擎中发现一个 bug。JIT 引擎会分析代码,以便能够省略缓慢的运行时类型检查,并生成快速的机器码。有时逻辑错误会导致分析错误,从而忽略实际需要的类型检查 - 比如,它会认为 x 是一个字符串,但实际上它是一个对象。

    ¥Find a bug in V8's JIT engine. JIT engines analyze code in order to be able to omit slow runtime type checks and produce fast machine code. Sometimes logic errors mean it gets this analysis wrong, and omits a type check that it actually needed—say, it thinks x is a string, but in fact it's an object.

  2. 利用这种混淆来覆盖 V8 堆中的部分内存,例如,指向 ArrayBuffer 开头的指针。

    ¥Abuse this confusion to overwrite some bit of memory inside the V8 heap, for instance, the pointer to the beginning of an ArrayBuffer.

  3. 现在,你拥有一个指向任意位置的 ArrayBuffer,因此你可以在进程中读写任何内存,即使是 V8 通常无法访问的内存。

    ¥Now you have an ArrayBuffer that points wherever you like, so you can read and write any memory in the process, even memory that V8 normally doesn't have access to.

V8 内存笼是一种旨在彻底阻止此类攻击的技术。实现此漏洞的方法是不在 V8 堆中存储任何指针。所有对 V8 堆内其他内存的引用都存储为相对于某个保留区域起始位置的偏移量。这样一来,即使攻击者设法破坏了 ArrayBuffer 的基址(例如通过利用 V8 中的类型混淆错误),他们所能做的最坏的事情也不过是读取和写入 Cage 内的内存,而他们很可能已经这样做了。关于 V8 内存笼的工作原理,还有很多资料可供参考,所以我就不在这里赘述了 - 最好的入门资料可能是 Chromium 团队的 高级设计文档 模块。

¥The V8 memory cage is a technique designed to categorically prevent this kind of attack. The way this is accomplished is by not storing any pointers in the V8 heap. Instead, all references to other memory inside the V8 heap are stored as offsets from the beginning of some reserved region. Then, even if an attacker manages to corrupt the base address of an ArrayBuffer, for instance by exploiting a type confusion error in V8, the worst they can do is read and write memory inside the cage, which they could likely already do anyway. There's a lot more available to read on how the V8 memory cage works, so I won't go into further detail here—the best place to start reading is probably the high-level design doc from the Chromium team.

我想重构一个 Node 原生模块以支持 Electron 21+。我该怎么做?

¥I want to refactor a Node native module to support Electron 21+. How do I do that?

重构原生模块以兼容 V8 内存框架有两种方法。第一个方法是将外部创建的缓冲区复制到 V8 内存中,然后再传递给 JavaScript。这通常是一个简单的重构,但当缓冲区很大时可能会很慢。另一种方法是使用 V8 的内存分配器来分配最终要传递给 JavaScript 的内存。这虽然有点复杂,但可以避免复制,这意味着大缓冲区的性能会更好。

¥There are two ways to go about refactoring a native module to be compatible with the V8 memory cage. The first is to copy externally-created buffers into the V8 memory cage before passing them to JavaScript. This is generally a simple refactor, but it can be slow when the buffers are large. The other approach is to use V8's memory allocator to allocate memory which you intend to eventually pass to JavaScript. This is a bit more involved, but will allow you to avoid the copy, meaning better performance for large buffers.

为了更具体说明,以下是一个使用外部数组缓冲区的 N-API 模块示例:

¥To make this more concrete, here's an example N-API module that uses external array buffers:

// Create some externally-allocated buffer.
// |create_external_resource| allocates memory via malloc().
size_t length = 0;
void* data = create_external_resource(&length);
// Wrap it in a Buffer--will fail if the memory cage is enabled!
napi_value result;
napi_create_external_buffer(
env, length, data,
finalize_external_resource, NULL, &result);

当内存笼启用时,这将崩溃,因为数据是在内存笼外分配的。重构后,将数据复制到 Cage 中,我们得到:

¥This will crash when the memory cage is enabled, because data is allocated outside the cage. Refactoring to instead copy the data into the cage, we get:

size_t length = 0;
void* data = create_external_resource(&length);
// Create a new Buffer by copying the data into V8-allocated memory
napi_value result;
void* copied_data = NULL;
napi_create_buffer_copy(env, length, data, &copied_data, &result);
// If you need to access the new copy, |copied_data| is a pointer
// to it!

这会将数据复制到 V8 内存笼内新分配的内存区域中。N-API 还可以选择提供指向新复制数据的指针,以便你事后需要修改或引用它。

¥This will copy the data into a newly-allocated memory region that is inside the V8 memory cage. Optionally, N-API can also provide a pointer to the newly-copied data, in case you need to modify or reference it after the fact.

重构后使用 V8 的内存分配器会稍微复杂一些,因为它需要修改 create_external_resource 函数以使用 V8 分配的内存,而不是使用 malloc。这可能或多或少可行,取决于你是否控制 create_external_resource 的定义。我们的想法是首先使用 V8(例如使用 napi_create_buffer)创建缓冲区,然后将资源初始化到 V8 分配的内存中。保留 napi_ref资源生命周期 的 Buffer 对象非常重要,否则 V8 可能会对 Buffer 进行垃圾回收,并可能导致释放后使用错误。

¥Refactoring to use V8's memory allocator is a little more complicated, because it requires modifying the create_external_resource function to use memory allocated by V8, instead of using malloc. This may be more or less feasible, depending on whether or not you control the definition of create_external_resource. The idea is to first create the buffer using V8, e.g. with napi_create_buffer, and then initialize the resource into the memory that has been allocated by V8. It is important to retain a napi_ref to the Buffer object for the lifetime of the resource, otherwise V8 may garbage-collect the Buffer and potentially result in use-after-free errors.

Electron 19.0.0

· 5 min read

Electron 19.0.0 已发布!它包含对 Chromium 102、V8 10.2 和 Node.js 16.14.2 的升级。请阅读下文了解更多详情!

¥Electron 19.0.0 has been released! It includes upgrades to Chromium 102, V8 10.2, and Node.js 16.14.2. Read below for more details!


Electron 团队非常高兴地宣布 Electron 19.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息,并请分享你的任何反馈!

¥The Electron team is excited to announce the release of Electron 19.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 发布节奏变更

¥Electron Release Cadence Change

该项目正在恢复其先前的支持最新三个主要版本的政策。查看我们的版本控制文档 了解 Electron 版本控制和支持的更多详细信息。为了帮助用户适应从 Electron 15 开始的新发布节奏,我们暂时将其分为四个主要版本。你可以阅读 完整详情请见此处

¥The project is returning to its earlier policy of supporting the latest three major versions. See our versioning document for more detailed information about Electron versioning and support. This had temporarily been four major versions to help users adjust to the new release cadence that began in Electron 15. You can read the full details here.

技术栈变更

¥Stack Changes

重大变更和 API 变更

¥Breaking & API Changes

以下是 Electron 19 中引入的重大变更。有关这些变更和未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

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

Linux 上不支持:.skipTaskbar

¥Unsupported on Linux: .skipTaskbar

BrowserWindow 构造函数选项 skipTaskbar 在 Linux 上不再受支持。#33226 中的变更

¥The BrowserWindow constructor option skipTaskbar is no longer supported on Linux. Changed in #33226

移除 WebPreferences.preloadURL

¥Removed WebPreferences.preloadURL

半文档化的 preloadURL 属性已从 WebPreferences 中移除。#33228。应该使用 WebPreferences.preload

¥The semi-documented preloadURL property has been removed from WebPreferences. #33228. WebPreferences.preload should be used instead.

15.x.y 终止支持和 16.x.y

¥End of Support for 15.x.y and 16.x.y

Electron 14.x.y 和 15.x.y 均已终止支持。此 returns Electron 更新至其 现有政策,支持最新的三个主要版本。建议开发者和应用升级到较新版本的 Electron。

¥Electron 14.x.y and 15.x.y have both reached end-of-support. This returns Electron to its existing policy of supporting the latest three major versions. Developers and applications are encouraged to upgrade to a newer version of Electron.

E15 (2021 年 9 月)E16 (2021 年 11 月)E17 (2022 年 2 月)E18 (2022 年 3 月)E19 (2022 年 5 月)
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

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。虽然我们谨慎地不对发布日期做出承诺,但我们计划大约每两个月发布一次 Electron 的新主要版本及其组件的新版本。

¥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 公开时间线

¥You can find Electron's public timeline here.

有关未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about future changes can be found on the Planned Breaking Changes page.

S3 存储桶迁移

· 4 min read

Electron 正在更改其主要的 S3 存储桶,你可能需要更新构建脚本。

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


发生了什么?

¥What is happening?

大量 Electron 的构建工件被上传到名为 gh-contractor-zcbenz 的 S3 存储桶。作为自 2020 年开始的持续基础设施/所有权迁移的一部分,我们将把所有使用 gh-contractor-zcbenz 的资源从其旧存储 S3 迁移到托管在 https://artifacts.electronjs.org 的新存储系统。我们大多数资源使用的路径前缀也略有变化。示例如下:

¥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:

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

¥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

这里重要的是更改了主机名和 /atom-shell 前缀。另一个示例,这次是调试符号:

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

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

¥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

再次强调,主机名和 /atom-shell 前缀均已更改。

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

这会对你有什么影响?

¥How might this impact you?

任何使用标准构建工具(例如 electron-rebuildelectron-packager@electron/get)的用户无需执行任何操作。这应该是大多数人的习惯。

¥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.

对于直接引用 S3 存储桶的任何人,你必须更新引用以指向主机名并更新路径。

¥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?

gh-contractor-zcbenz bucket 中的大部分数据已克隆到新的存储系统中。这意味着所有调试符号和所有头文件都已复制。如果你依赖该存储桶中某些尚未复制的数据,请在 electron/electron 中提交问题并告知我们。

¥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.

当前的 gh-contractor-zcbenz S3 存储桶不会被主动删除。但是,我们无法保证该 bucket 能保留多久。我们强烈建议尽快更新以适应新的存储桶。

¥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.

Electron 18.0.0

· 7 min read

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

¥Electron 18.0.0 has been released! It includes upgrades to Chromium 100, V8 10.0, and Node.js 16.13.2. Read below for more details!


Electron 团队非常高兴地宣布 Electron 18.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息,并请分享你的任何反馈!

¥The Electron team is excited to announce the release of Electron 18.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 发布节奏变更

¥Electron Release Cadence Change

从 Electron 15 开始,Electron 将每 8 周发布一个新的主要稳定版本。你可以阅读 完整详情请见此处

¥As of Electron 15, Electron will release a new major stable version every 8 weeks. You can read the full details here.

此外,Electron 的支持版本已从最新三个版本更改为最新四个版本,有效期至 2022 年 5 月。查看我们的版本控制文档 了解 Electron 版本控制的更多详细信息。2022 年 5 月后,我们将恢复对最新三个版本的支持。

¥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

  • 添加了用于设置代码缓存目录的 ses.setCodeCachePath() API。#33286

    ¥Added ses.setCodeCachePath() API for setting code cache directory. #33286

  • 移除了基于 BrowserWindowProxy 的旧 window.open 实现。这还会从 webPreferences 中删除 nativeWindowOpen 选项。#29405

    ¥Removed the old BrowserWindowProxy-based implementation of window.open. This also removes the nativeWindowOpen option from webPreferences. #29405

  • WebContents 中添加了 'focus' 和 'blur' 事件。#25873

    ¥Added 'focus' and 'blur' events to WebContents. #25873

  • 在 macOS 上添加了替换菜单角色:showSubstitutions, toggleSmartQuotes, toggleSmartDashes, toggleTextReplacement.#32024

    ¥Added Substitutions menu roles on macOS: showSubstitutions, toggleSmartQuotes, toggleSmartDashes, toggleTextReplacement. #32024

  • app.requestSingleInstanceLock() 流程中添加了 first-instance-ack 事件,允许用户无缝地将数据从第一个实例传输到第二个实例。#31460

    ¥Added a first-instance-ack event to the app.requestSingleInstanceLock() flow, allowing users to seamlessly transmit data from the first instance to the second instance. #31460

  • setBackgroundColor 中添加了对更多颜色格式的支持。#33364

    ¥Added support for more color formats in setBackgroundColor. #33364

请参阅 18.0.0 发行说明 获取新功能和变更的完整列表。

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

重大变更和 API 变更

¥Breaking & API Changes

以下是 Electron 18 中引入的重大变更。有关这些变更和未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

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

删除:nativeWindowOpen

¥Removed: nativeWindowOpen

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

¥Prior to Electron 15, 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. Since Electron 15, nativeWindowOpen has been enabled by default.

请参阅 Electron 中的 window.open 文档 获取更多详情。已在 #29405 中移除

¥See the documentation for window.open in Electron for more details. Removed in #29405

14.x.y 终止支持

¥End of Support for 14.x.y

Electron 14.x.y 已根据项目 支持政策 终止支持。建议开发者和应用升级到较新版本的 Electron。

¥Electron 14.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.

从 Electron 15 开始,我们已将支持的版本从最新的三个版本更改为最新的四个版本,直至 2022 年 5 月 Electron 19 的发布。Electron 19 发布后,我们将恢复对最新三个版本的支持。此版本支持更改是我们新节奏更改的一部分。请参阅 我们的博客文章,详情请点击此处

¥As of Electron 15, we have changed supported versions from latest three versions to latest four versions until May 2022 with Electron 19. After Electron 19, we will return to supporting the latest three versions. This version support change is part of our new cadence change. Please see our blog post for full details here.

E15 (2021 年 9 月)E16 (2021 年 11 月)E17 (2022 年 2 月)E18 (2022 年 3 月)E19 (2022 年 5 月)
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

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。虽然我们谨慎地不对发布日期做出承诺,但我们计划大约每两个月发布一次 Electron 的新主要版本及其组件的新版本。

¥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 公开时间线

¥You can find Electron's public timeline here.

有关未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about future changes can be found on the Planned Breaking Changes page.

2022 年 Google 编程夏令营

· 4 min read

Electron 团队非常高兴地宣布,我们将在今年首次参加 Google Summer of Code!

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


什么是 Google Summer of Code?

¥What is Google Summer of Code?

Google Summer of Code (GSoC) 是一项年度指导计划,旨在将开源软件项目与潜在贡献者联系起来。以前仅对学生开放,现在任何 18 岁及以上的人都可以注册 GSoC。

¥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.

更多信息,请查看 Summer of Code 主页

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

如何注册?

¥How do I sign up?

你有兴趣与 Electron 合作吗?如果你是开源贡献者新手或初学者,欢迎你申请!

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

想要被选为 Google 编程之夏的 Electron 贡献者,你需要提交申请。申请开放时间为 2022 年 4 月 4 日,截止时间为 2022 年 4 月 19 日。你可以关注 Google 的更新:Summer of Code 申请指南在此

¥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.

有关在 Electron 应用中提交哪些内容的详细指南,请参见此处。

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

你还可以阅读 官方 GSoC 学生/贡献者指南 提供关于准备提案的重要提示。

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

如果你想讨论项目提案或有任何疑问,欢迎加入我们的 #gsoc-general Discord 通道

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

参考

¥References

Electron 17.0.0

· 7 min read

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

¥Electron 17.0.0 has been released! It includes upgrades to Chromium 98, V8 9.8, and Node.js 16.13.0. Read below for more details!


Electron 团队非常高兴地宣布 Electron 17.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息,并请分享你的任何反馈!

¥The Electron team is excited to announce the release of Electron 17.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 发布节奏变更

¥Electron Release Cadence Change

从 Electron 15 开始,Electron 将每 8 周发布一个新的主要稳定版本。你可以阅读 完整详情请见此处

¥As of Electron 15, Electron will release a new major stable version every 8 weeks. You can read the full details here.

此外,Electron 的支持版本已从最新三个版本更改为最新四个版本,有效期至 2022 年 5 月。查看我们的版本控制文档 了解 Electron 版本控制的更多详细信息。2022 年 5 月后,我们将恢复对最新三个版本的支持。

¥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

  • 已添加 webContents.getMediaSourceId(),可与 getUserMedia 一起使用以获取 WebContents 的流。#31204

    ¥Added webContents.getMediaSourceId(), can be used with getUserMedia to get a stream for a WebContents. #31204

  • 弃用 webContents.getPrinters() 并引入 webContents.getPrintersAsync()#31023

    ¥Deprecates webContents.getPrinters() and introduces webContents.getPrintersAsync(). #31023

  • desktopCapturer.getSources 现在仅在主进程中可用。#30720

    ¥desktopCapturer.getSources is now only available in the main process. #30720

请参阅 17.0.0 发行说明 获取新功能和变更的完整列表。

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

重大变化

¥Breaking Changes

以下是 Electron 17 中引入的重大变更。有关这些变更和未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

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

渲染器中的 desktopCapturer.getSources

¥desktopCapturer.getSources in the renderer

desktopCapturer.getSources API 现在仅在主进程中可用。为了提高 Electron 应用的默认安全性,这一点已更改。

¥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 变更

¥API Changes

Electron 17 中没有 API 变更。

¥There were no API changes in Electron 17.

移除/弃用的变更

¥Removed/Deprecated Changes

  • 渲染器中 desktopCapturer.getSources API 的使用已被移除。有关如何在应用中替换此 API 的详细信息,请参阅 此处

    ¥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 终止支持

¥End of Support for 13.x.y

Electron 13.x.y 已根据项目 支持政策 终止支持。建议开发者和应用升级到较新版本的 Electron。

¥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.

从 Electron 15 开始,我们已将支持的版本从最新的三个版本更改为最新的四个版本,直至 2022 年 5 月 Electron 19 的发布。Electron 19 发布后,我们将恢复对最新三个版本的支持。此版本支持更改是我们新节奏更改的一部分。请参阅 我们的博客文章,详情请点击此处

¥As of Electron 15, we have changed supported versions from latest three versions to latest four versions until May 2022 with Electron 19. After Electron 19, we will return to supporting the latest three versions. This version support change is part of our new cadence change. Please see our blog post for full details here.

E15 (2021 年 9 月)E16 (2021 年 11 月)E17 (2022 年 2 月)E18 (2022 年 3 月)E19 (2022 年 5 月)
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

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。虽然我们谨慎地不对发布日期做出承诺,但我们计划大约每两个月发布一次 Electron 的新主要版本及其组件的新版本。

¥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 公开时间线

¥You can find Electron's public timeline here.

有关未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about future changes can be found on the Planned Breaking Changes page.

Spectron 弃用通知

· 4 min read

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

¥Spectron will be deprecated on February 1st, 2022.


从 2022 年 2 月开始,Spectron 将升级到 Electron 团队已正式弃用

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

为什么要弃用 Spectron?

¥Why Deprecate Spectron?

虽然 Spectron 一直在为 Electron 的每个新版本发布新版本,但该项目一年多来几乎没有维护和改进,目前也没有全职维护人员。随着远程模块从 Electron 核心移出并移至 Electron 14 中的外部模块,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.

在审查了 Spectron 持续维护的几个可用选项后,Electron 团队决定在 2022 年弃用 Spectron。

¥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:

  • 2021 年 11 月 - 2022 年 1 月:Electron 团队将继续接受来自社区的拉取请求。

    ¥November 2021 - January 2022: The Electron team will continue to accept pull requests from the community.

  • 2022 年 1 月:关于 Spectron 弃用警告的最终公告版本即将发布。

    ¥January 2022: A final version of announcement warning about Spectron's deprecation will be released.

  • 2022 年 2 月 1 日:Spectron 的仓库将被标记为 "archived"。不再接受拉取请求。

    ¥February 1, 2022: Spectron's repo will be marked as "archived". No more pull requests will be accepted.

2022 年 2 月 1 日之后,Electron 将继续无限期地保留 Spectron 代码库,以便其他人可以 fork 或将现有代码用于他们的项目。我们希望这能为仍然依赖 Spectron 的项目提供更长的过渡期。

¥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.

Spectron 的替代方案

¥Alternatives to Spectron

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

¥If you're currently using Spectron in your project and would like to migrate to an alternative testing solution, you can read our guide for automated testing here.

目前,我们推荐了其他几种 Spectron 的替代方案,包括 Playwright 和 WebDriverIO。每个选项的官方教程都可以在我们的自动化测试文档中找到。

¥We currently have several other recommended alternatives to Spectron, including Playwright and WebDriverIO. Official tutorials for each option can be found in our Automated Testing documentation.

下一步计划

¥What's Next

Electron 团队感谢你使用 Spectron 和 Electron。我们理解许多人依赖 Spectron 来测试应用,我们希望尽可能让你轻松完成这一过渡。感谢你选择 Electron!

¥We here on the Electron team appreciate you using Spectron and Electron. We understand that many of you depend on Spectron for testing your apps, and we want to make this transition as painless for you as possible. Thank you for choosing Electron!