Skip to main content

Electron 16.0.0

· 9 min read

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

¥Electron 16.0.0 has been released! It includes upgrades to Chromium 96, V8 9.6, and Node.js 16.9.1. Read below for more details!


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

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

  • 现在支持 WebHID API。#30213

    ¥Now supports the WebHID API. #30213

  • app.requestSingleInstanceLock 添加数据参数,以便在实例之间共享数据。#30891

    ¥Add data parameter to app.requestSingleInstanceLock to share data between instances. #30891

  • 将 securityOrigin 传递给媒体权限请求处理程序。#31357

    ¥Pass securityOrigin to media permissions request handler. #31357

  • 添加 commandLine.removeSwitch#30933

    ¥Add commandLine.removeSwitch. #30933

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

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

重大变化

¥Breaking Changes

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

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

构建原生模块

¥Building Native Modules

如果你的项目使用 node-gyp 构建原生模块,则可能需要根据项目的设置和 Electron 版本使用 --force-process-config 调用它。有关此变更的更多信息,请参阅 #2497

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

行为改变:Linux 上的 crashReporter 实现切换到 Crashpad

¥Behavior Changed: crashReporter implementation switched to Crashpad on Linux

Linux 上 crashReporter API 的底层实现已从 Breakpad 更改为 Crashpad,使其与 Windows 和 Mac 保持一致。因此,现在会自动监视子进程,并且不再需要在 Node 子进程中调用 process.crashReporter.start(并且不建议这样做,因为它将启动 Crashpad 报告程序的第二个实例)。

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

Linux 上注释的报告方式也有一些细微的变化,包括长值将不再在附加 __1__2 等的注释之间分割,而是会在(新的、更长的)注释值限制处被截断 。

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

¥API Changes

Electron 16 中没有 API 变更。

¥There were no API changes in Electron 16.

移除/弃用的变更

¥Removed/Deprecated Changes

  • 渲染器中使用 desktopCapturer.getSources API 已被弃用并将被删除。此更改提高了 Electron 应用的默认安全性。有关如何在应用中替换此 API 的详细信息,请参阅 此处

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

12.x.y 终止支持

¥End of Support for 12.x.y

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

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

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

寂静之地 (2021 年 12 月)

· 3 min read

Electron 项目将在 2021 年 12 月暂停,然后在 2022 年 1 月恢复全速运行。

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

via GIPHY


12 月会有什么相同之处?

¥What will be the same in December

  1. 零日漏洞和其他主要安全相关版本将根据需要发布。安全事件应通过 SECURITY.md 报告。

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

12 月会有什么不同?

¥What will be different in December

  1. 12 月未发布新的 Beta 版或稳定版。12 月最后两周未发布 Nightly 版本。

    ¥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. 维护人员未提供 Discord 调试帮助。

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

我应该担心 Electron 的未来吗?

¥Should I be worried about the future of Electron?

不需要。我们之所以能够迈出这一步,是因为项目进展顺利。大家都期待 2022 年,我们期待美好的事情发生!

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

Electron 15.0.0

· 9 min read

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

¥Electron 15.0.0 has been released! It includes upgrades to Chromium 94, V8 9.4, and Node.js 16.5.0. We've added API updates to window.open, bug fixes, and general improvements. Read below for more details!


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

¥The Electron team is excited to announce the release of Electron 15.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 周发布一个新的主要稳定版本。你可以阅读 完整详情请见此处

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

此外,Electron 的支持版本将从最新三个版本更改为最新四个版本,有效期至 2022 年 5 月。有关 Electron 版本控制的更多详细信息,请参阅 查看我们的版本控制文档

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

技术栈变更

¥Stack Changes

亮点功能

¥Highlight Features

  • nativeWindowOpen: true 不再是实验性的,现在是默认值。

    ¥nativeWindowOpen: true is no longer experimental, and is now the default.

  • 添加了 safeStorage 字符串加密 API。#30430

    ¥Added safeStorage string encryption API. #30430

  • WebContents 上添加了 'frame-created' 事件,该事件在页面中创建框架时触发。#30801

    ¥Added 'frame-created' event to WebContents which emits when a frame is created in the page. #30801

  • BrowserWindowwill-resize 事件添加了调整 edge 大小的信息。#29199

    ¥Added resize edge info to BrowserWindow's will-resize event. #29199

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

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

重大变化

¥Breaking Changes

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

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

默认更改:nativeWindowOpen 默认为 true

¥Default Changed: nativeWindowOpen defaults to true

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

¥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. nativeWindowOpen: true is no longer experimental, and is now the default.

请参阅 Electron 中的 window.open 文档了解更多详情。

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

API 变更

¥API Changes

  • WebContents 上添加了 'frame-created' 事件,该事件在页面中创建框架时触发。#30801

    ¥Added 'frame-created' event to WebContents which emits when a frame is created in the page. #30801

  • 添加了 safeStorage 字符串加密 API。#30430

    ¥Added safeStorage string encryption API. #30430

  • dialog.showMessageBox 中添加了 signal 选项。#26102

    ¥Added signal option to dialog.showMessageBox. #26102

  • 添加了 Electron Fuse,用于在应用加载的 app.asar 文件上强制执行代码签名。需要最新的 asar 模块(v3.1.0 或更高版本)。#30900

    ¥Added an Electron Fuse for enforcing code signatures on the app.asar file your application loads. Requires the latest asar module (v3.1.0 or higher). #30900

  • 添加了保险丝,用于在打包应用中禁用 NODE_OPTIONS--inspect 调试参数。#30420

    ¥Added fuses to disable NODE_OPTIONS and --inspect debug arguments in packaged apps. #30420

  • 添加了新的 MenuItem.userAccelerator 属性,用于读取用户分配的 macOS 加速器覆盖。#26682

    ¥Added new MenuItem.userAccelerator property to read user-assigned macOS accelerator overrides. #26682

  • 添加了新的 app.runningUnderARM64Translation 属性,用于检测何时在 Apple Silicon 上的 Rosetta 下运行,或在 Windows 上为 ARM 运行 WOW。#29168

    ¥Added new app.runningUnderARM64Translation property to detect when running under Rosetta on Apple Silicon, or WOW on Windows for ARM. #29168

  • 添加了新的 imageAnimationPolicy Web 首选项,用于控制图片的动画方式。#29095

    ¥Added new imageAnimationPolicy web preference to control how images are animated. #29095

  • 添加了对通过上下文桥发送 Blob 的支持。#29247

    ¥Added support for sending Blobs over the context bridge. #29247

移除/弃用的变更

¥Removed/Deprecated Changes

未删除或弃用任何 API。

¥No APIs have been removed or deprecated.

支持的版本

¥Supported Versions

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

¥Starting in Electron 15, we will change 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.

建议开发者和应用升级到较新版本的 Electron。

¥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 release new major versions of Electron with new versions of those components approximately quarterly.

你可以找到 Electron 公开时间线

¥You can find Electron's public timeline here.

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

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

Electron 14.0.0

· 15 min read

Electron 14.0.0 已发布!此更新包含对 Chromium 93 和 V8 9.3 的升级。我们添加了多个 API 更新、错误修复和常规改进。请阅读下文了解更多详情!

¥Electron 14.0.0 has been released! It includes upgrades to Chromium 93 and V8 9.3. We've added several API updates, bug fixes, and general improvements. Read below for more details!


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

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

从 2021 年 9 月的 Electron 15 开始,Electron 将每 8 周发布一个新的主要稳定版本。你可以阅读 完整详情请见此处。Electron 15 将于 2021 年 9 月 1 日开始 Beta 测试,稳定版本将于 2021 年 9 月 21 日发布。你可以找到 Electron 公开时间线。此外,Electron 的支持版本将从最新三个版本更改为最新四个版本,有效期至 2022 年 5 月。有关 Electron 版本控制的更多详细信息,请参阅 查看我们的版本控制文档

¥Beginning in September 2021 with Electron 15, Electron will release a new major stable version every 8 weeks. You can read the full details here. 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

  • 默认更改:nativeWindowOpen 现在默认为 true(查看文档)

    ¥Default Changed: nativeWindowOpen now defaults to true. (see docs)

  • 子窗口不再从其父窗口继承 BrowserWindow 的构造选项。#28550

    ¥Child windows no longer inherit BrowserWindow construction options from their parents. #28550

  • 添加了新的 session.storagePath API,用于获取会话特定数据在磁盘上的路径。#28665

    ¥Added new session.storagePath API to get the path on disk for session-specific data. #28665

  • 已添加 @electron/remote 使用的 process.contextId#28007

    ¥Added process.contextId used by @electron/remote. #28007

  • Electron Fuse 后面添加了实验性 Cookie 加密支持。#29492

    ¥Added experimental cookie encryption support behind an Electron Fuse. #29492

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

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

重大变化

¥Breaking Changes

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

¥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

¥Removed: app.allowRendererProcessReuse

app.allowRendererProcessReuse 属性已被删除,这是我们计划的一部分,以便与 Chromium 的进程模型更紧密地保持一致,以实现安全性、性能和可维护性。

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

欲了解更多详细信息,请参阅 #18397

¥For more detailed information see #18397.

删除:浏览器窗口亲和性

¥Removed: Browser Window Affinity

为了更紧密地与 Chromium 的进程模型保持一致,在安全性、性能和可维护性方面,我们计划在构建新的 BrowserWindow 时移除 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.

欲了解更多详细信息,请参阅 #18397

¥For more detailed information see #18397.

API 更改:window.open()

¥API Changed: window.open()

可选参数 frameName 不再设置窗口标题。此行为现在遵循 原生文档 中对 windowName 参数描述的规范。

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

如果你之前使用此参数设置窗口标题,则可以改用 win.setTitle(title) 方法。

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

删除:worldSafeExecuteJavaScript

¥Removed: worldSafeExecuteJavaScript

worldSafeExecuteJavaScript 已被移除,且无其他选择。请确保你的代码在启用此属性后正常工作。从 Electron 12 开始它就被默认启用。

¥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,你将受到此更改的影响。你需要确保 上下文桥 API 支持这些方法中任一方法返回的值,因为这些方法使用相同的值传递语义。

¥You will be affected by this change if you use either webFrame.executeJavaScript or webFrame.executeJavaScriptInIsolatedWorld. You will need to ensure that values returned by either of those methods are supported by the Context Bridge API as these methods use the same value passing semantics.

默认更改:nativeWindowOpen 默认为 true

¥Default Changed: nativeWindowOpen defaults to true

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

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

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

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

删除:BrowserWindowConstructorOptions 继承自父窗口

¥Removed: BrowserWindowConstructorOptions inheriting from parent windows

在 Electron 14 之前,使用 window.open 打开的窗口将从其父窗口继承 BrowserWindow 构造函数选项,例如 transparentresizable。从 Electron 14 开始,此行为已被移除,窗口将不会从其父级继承任何 BrowserWindow 构造函数选项。

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

相反,使用 setWindowOpenHandler 显式设置新窗口的选项:

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

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

删除:additionalFeatures

¥Removed: additionalFeatures

WebContents 的 new-windowdid-create-window 事件中已弃用的 additionalFeatures 属性已被删除。由于 new-window 使用位置参数,因此该参数仍然存在,但始终是空数组 []。(注意:new-window 事件本身已弃用,并已被 setWindowOpenHandler 取代。)窗口功能中的裸键现在将在选项对象中显示为值为 true 的键。

¥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']) {
// ...
}
});

删除:remote 模块

¥Removed: remote module

remote 模块在 Electron 12 中已弃用,现已从 Electron 本身移除,并提取到单独的包 @electron/remote 中。@electron/remote 模块将 JavaScript 对象从主进程桥接到渲染进程。这使得你可以访问仅在主进程中可用的对象,就像它们在渲染进程中可用一样。这是 remote 模块的直接替代品。请参阅 模块自述文件 获取迁移说明和参考。

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

¥API Changes

  • 添加了 BrowserWindow.isFocusable() 方法,用于判断窗口是否可聚焦。#28642

    ¥Added BrowserWindow.isFocusable() method to determine whether a window is focusable. #28642

  • 添加了 WebFrameMain.visibilityState 实例属性。#28706

    ¥Added WebFrameMain.visibilityState instance property. #28706

  • 已将 dispositionreferrerpostBody 添加到传递给在 setWindowOpenHandler 注册的窗口打开处理程序的详细信息对象中。#28518

    ¥Added disposition, referrer and postBody to the details object passed to the window open handler registered with setWindowOpenHandler. #28518

  • 已添加 @electron/remote 使用的 process.contextId#28007

    ¥Added process.contextId used by @electron/remote. #28007

  • Electron Fuse 后面添加了实验性 Cookie 加密支持。#29492

    ¥Added experimental cookie encryption support behind an Electron Fuse. #29492

  • webRequest 监听器详情添加了缺失的 resourceType 转换:fontpingcspReportmediawebSocket#30050

    ¥Added missing resourceType conversions for webRequest listener details: font, ping, cspReport, media, webSocket. #30050

  • 添加了新的 session.storagePath API,用于获取会话特定数据在磁盘上的路径。#28665

    ¥Added new session.storagePath API to get the path on disk for session-specific data. #28665

  • 添加了对 macOS 上 Windows 控件覆盖层的支持。#29986

    ¥Added support for Windows Control Overlay on macOS. #29986

  • 添加了使用 --log-file=.../path/to/file.log 将 Chromium 日志记录定向到文件的支持。此外,现在可以通过在第一个 JS tick 期间附加命令行开关来启用 JavaScript 日志记录。#29963

    ¥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

  • 在 Node Crypto 中添加了对 des-ede3 密码的支持。#27897

    ¥Added support for the des-ede3 cipher in node crypto. #27897

  • 添加了 ContextBridgeMutability 功能,允许修改上下文桥接对象。#27348

    ¥Added a ContextBridgeMutability feature that allows context bridge objects to be mutated. #27348

移除/弃用的变更

¥Removed/Deprecated Changes

以下 API 已被删除或弃用:

¥The following APIs have been removed or are now deprecated:

  • remote 模块在 Electron 12 中被弃用后已被移除。#25734

    ¥The remote module has been removed after being deprecated in Electron 12. #25734

  • 子窗口不再从其父窗口继承 BrowserWindow 的构造选项。#28550

    ¥Child windows no longer inherit BrowserWindow construction options from their parents. #28550

  • new-windowdid-create-window WebContents 事件中移除了已弃用的 additionalFeatures 属性。#28548

    ¥Removed deprecated additionalFeatures property from new-window and did-create-window WebContents events. #28548

  • 移除了已弃用的 app.allowRendererProcessReuse 和 BrowserWindow affinity 选项。#26874

    ¥Removed the deprecated app.allowRendererProcessReuse and BrowserWindow affinity options. #26874

  • uploadToServer 为 false 时,crashReporter.startsubmitURL 选项不再是必需参数。#28105

    ¥The submitURL option for crashReporter.start is no longer a required argument when uploadToServer is false. #28105

11.x.y 终止支持

¥End of Support for 11.x.y

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

¥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

短期内,你可以预期团队将继续专注于跟上构成 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 release new major versions of Electron with new versions of those components approximately quarterly.

有关即将推出的 Electron 版本中计划的重大变更的信息,请参阅我们的 计划中的突发事件变更

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

WebView2 和 Electron

· 13 min read

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

¥Over the past weeks, we’ve received several questions about the differences between the new WebView2 and Electron.

两个团队都明确表示,他们的目标是让 Web 技术在桌面端达到最佳状态,并且正在讨论进行一次全面的比较。

¥Both teams have the expressed goal of making web-tech the best it can be on the Desktop, and a shared comprehensive comparison is being discussed.

Electron 和 WebView2 是快速发展且不断发展的项目。我们简要概述了 Electron 和 WebView2 目前存在的异同。

¥Electron and WebView2 are fast-moving and constantly evolving projects. We have assembled a brief snapshot of similarities and differences between Electron and WebView2 as they exist today.


架构概述

¥Architecture Overview

Electron 和 WebView2 均基于 Chromium 源代码构建,用于渲染 Web 内容。严格来说,WebView2 基于 Edge 源代码构建,但 Edge 是使用 Chromium 源代码的分支构建的。Electron 不与 Chrome 共享任何 DLL。WebView2 二进制文件与 Edge(自 Edge 90 起为稳定版本)硬链接,因此它们共享磁盘和一些工作集。有关更多信息,请参阅 Evergreen 分发模式

¥Electron and WebView2 both build from the Chromium source for rendering web content. Strictly speaking, WebView2 builds from the Edge source, but Edge is built using a fork of the Chromium source. Electron does not share any DLLs with Chrome. WebView2 binaries hard link against Edge (Stable channel as of Edge 90), so they share disk and some working set. See Evergreen distribution mode for more info.

Electron 应用始终会打包和分发与其开发时使用的 Electron 版本完全相同的版本。WebView2 有两种分发方式。你可以打包应用开发时使用的 WebView2 库,也可以使用系统中可能已存在的共享运行时版本。WebView2 为每种方法提供了工具,包括在缺少共享运行时时提供的引导安装程序。WebView2 从 Windows 11 开始内置于系统。

¥Electron apps always bundle and distribute the exact version of Electron with which they were developed. WebView2 has two options in distribution. You can bundle the exact WebView2 library your application was developed with, or you can use a shared-runtime version that may already be present on the system. WebView2 provides tools for each approach, including a bootstrapping installer in case the shared runtime is missing. WebView2 is shipped inbox starting with Windows 11.

打包其框架的应用负责更新这些框架,包括小的安全更新。对于使用共享 WebView2 运行时的应用,WebView2 拥有自己的更新程序,类似于 Chrome 或 Edge,它独立于你的应用运行。与 Electron 一样,更新应用代码或其任何其他依赖仍然是开发者的责任。Electron 和 WebView2 均不受 Windows 更新管理。

¥Applications that bundle their frameworks are responsible for updating those frameworks, including minor security releases. For apps using the shared WebView2 runtime, WebView2 has its own updater, similar to Chrome or Edge, that runs independent of your application. Updating the application's code or any of its other dependencies is still a responsibility for the developer, same as with Electron. Neither Electron nor WebView2 is managed by Windows Update.

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

¥Both Electron and WebView2 inherit Chromium’s multi-process architecture - namely, a single main process that communicates with one-or-more renderer processes. These processes are entirely separate from other applications running on the system. Every Electron application is a separate process tree, containing a root browser-process, some utility processes, and zero or more render processes. WebView2 apps that use the same user data folder (like a suite of apps would do), share non-renderer processes. WebView2 apps using different data folders do not share processes.

  • ElectronJS 进程模型:

    ¥ElectronJS Process Model:

ElectronJS Process Model Diagram

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

    ¥WebView2 Based Application Process Model:

WebView2 Process Model Diagram

点击此处阅读有关 WebView2 的流程模型Electron 的进程模型 的更多信息。

¥Read more about WebView2’s process model and Electron’s process model here.

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

¥Electron provides APIs for common desktop application needs such as menus, file system access, notifications, and more. WebView2 is a component meant to be integrated into an application framework such as WinForms, WPF, WinUI, or Win32. WebView2 does not provide operating system APIs outside the web standard via JavaScript.

Node.js 已集成到 Electron 中。Electron 应用可以在渲染器和主进程中使用任何 Node.js API、模块或 node-native-addon。WebView2 应用不会假定应用的其余部分是用哪种语言或框架编写的。你的 JavaScript 代码必须通过应用宿主进程代理任何操作系统访问。

¥Node.js is integrated into Electron. Electron applications may use any Node.js API, module, or node-native-addon from the renderer and main processes. A WebView2 application does not assume which language or framework the rest of your application is written in. Your JavaScript code must proxy any operating system access through the application-host process.

Electron 致力于保持与 Web API 的兼容性,包括基于 Fugu 项目 开发的 API。我们有 Electron 的 Fugu API 快照兼容性。WebView2 维护着与 与 Edge 的 API 差异 类似的列表。

¥Electron strives to maintain compatibility with the web API, including APIs developed from the Fugu Project. We have a snapshot of Electron’s Fugu API compatibility. WebView2 maintains a similar list of API differences from Edge.

Electron 拥有可配置的 Web 内容安全模型,从完全访问到完全沙盒。WebView2 内容始终处于沙盒状态。Electron 拥有 全面的安全文档 安全模型选择指南。WebView2 也拥有 安全最佳实践

¥Electron has a configurable security model for web content, from full-access to full-sandbox. WebView2 content is always sandboxed. Electron has comprehensive security documentation on choosing your security model. WebView2 also has security best practices.

Electron 源代码已在 GitHub 上维护并可用。应用可以修改并构建自己的 Electron 版本。WebView2 源代码在 GitHub 上不可用。

¥The Electron source is maintained and available on GitHub. Applications can modify can build their own brands of Electron. The WebView2 source is not available on GitHub.

快速摘要:

¥Quick Summary:

ElectronWebView2
构建依赖ChromiumEdge
源代码可在 GitHub 上获取是的
共享 Edge/Chrome DLL是(自 Edge 90 起)
应用间共享运行时可选
应用 API是的
Node.js是的
沙盒可选始终
需要应用框架是的
支持的平台Mac、Win、LinuxWin(计划在 Mac/Linux 上线)
应用间进程共享永不可选
框架更新由以下人员管理应用WebView2

性能讨论

¥Performance Discussion

在渲染你的 Web 内容时,我们预计 Electron、WebView2 和任何其他基于 Chromium 的渲染器之间的性能差异很小。我们为那些有兴趣研究潜在性能差异的人创建了 使用 Electron、C++ + WebView2 和 C# + WebView2 构建的应用的脚手架

¥When it comes to rendering your web content, we expect little performance difference between Electron, WebView2, and any other Chromium-based renderer. We created scaffolding for apps built using Electron, C++ + WebView2, and C# + WebView2 for those interested to investigate potential performance differences.

除了渲染 Web 内容之外,它们之间还存在一些差异,来自 Electron、WebView2、Edge 和其他平台的开发者表示有兴趣进行包括 PWA 在内的详细比较。

¥There are a few differences that come into play outside of rendering web content, and folks from Electron, WebView2, Edge, and others have expressed interest in working on a detailed comparison including PWAs.

进程间通信 (IPC)

¥Inter-Process Communication (IPC)

我们想立即强调一个区别,因为我们认为这通常是 Electron 应用性能方面的考量。

¥There is one difference we want to highlight immediately, as we believe it is often a performance consideration in Electron apps.

在 Chromium 中,浏览器进程充当沙盒渲染器和系统其他部分之间的进程间通信代理。虽然 Electron 允许非沙盒渲染进程,但许多应用选择启用沙盒以增强安全性。WebView2 始终启用沙盒,因此对于大多数 Electron 和 WebView2 应用而言,进程间通信 (IPC) 会影响整体性能。

¥In Chromium, the browser process acts as an IPC broker between sandboxed renderers and the rest of the system. While Electron allows unsandboxed render processes, many apps choose to enable the sandbox for added security. WebView2 always has the sandbox enabled, so for most Electron and WebView2 apps IPC can impact overall performance.

尽管 Electron 和 WebView2 具有相似的进程模型,但底层的进程间通信 (IPC) 有所不同。JavaScript 与 C++ 或 C# 之间的通信需要 marshalling 版本,最常见的是 JSON 字符串。JSON 序列化/解析是一项开销很大的操作,IPC 瓶颈可能会对性能产生负面影响。从 Edge 93 开始,WV2 将使用 CBOR 选项处理网络事件。

¥Even though Electron and WebView2 have a similar process models, the underlying IPC differs. Communicating between JavaScript and C++ or C# requires marshalling, most commonly to a JSON string. JSON serialization/parsing is an expensive operation, and IPC-bottlenecks can negatively impact performance. Starting with Edge 93, WV2 will use CBOR for network events.

Electron 支持通过 MessagePorts API 在任意两个进程之间进行直接进程间通信 (IPC),而 MessagePorts API 则利用 结构化克隆算法。利用此功能的应用在进程间发送对象时可以避免 JSON 序列化的繁琐工作。

¥Electron supports direct IPC between any two processes via the MessagePorts API, which utilize the structured clone algorithm. Applications which leverage this can avoid paying the JSON-serialization tax when sending objects between processes.

概括

¥Summary

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

¥Electron and WebView2 have a number of differences, but don't expect much difference with respect to how they perform rendering web content. Ultimately, an app’s architecture and JavaScript libraries/frameworks have a larger impact on memory and performance than anything else because Chromium is Chromium regardless of where it is running.

特别感谢 WebView2 团队审阅这篇文章,并确保我们了解 WebView2 架构的最新情况。他们欢迎任何 项目反馈

¥Special thanks to the WebView2 team for reviewing this post, and ensuring we have an up-to-date view of the WebView2 architecture. They welcome any feedback on the project.

新的 Electron 发布节奏

· 14 min read

从 2021 年 9 月开始,Electron 将每 8 周发布一个新的主要稳定版本。

¥Beginning in September 2021, Electron will release a new major stable version every 8 weeks.


2019 年,Electron 发布了 发布周期改为 12 周,以配合 Chromium 的 6 周发布周期。最近,Chrome 和微软都宣布了一些变化,这让我们重新考虑 Electron 当前的发布节奏:

¥In 2019, Electron moved to a 12 week release cycle to match Chromium's 6 week release cycle. Recently, both Chrome and Microsoft announced changes that made us reconsider Electron's current release cadence:

  1. Chromium 计划每 8 周发布一次 从 2021 年 9 月 21 日的 Chrome 94 开始,每 4 周发布一个新的里程碑。 版本。此发布节奏还增加了每 8 周一次的扩展稳定版本,其中包含所有更新的安全修复。

    ¥Chromium plans to release a new milestone every 4 weeks, starting with Chrome 94 on September 21st, 2021. This release cadence also adds a new Extended Stable option every 8 weeks, which will contain all updated security fixes.

  2. 微软商店将 要求基于 Chromium 的应用版本不早于 2 个主要版本。例如,如果最新发布的 Chromium 主版本号是 85,那么任何基于 Chromium 的浏览器都必须至少运行 Chromium 83 或更高版本。此规则适用于 Electron 应用。

    ¥The Microsoft Store will require Chromium-based apps to be no older than within 2 major versions. As an example, if the latest released major version of Chromium is 85, any browser based on Chromium must be on at least Chromium version 83 or higher. This rule includes Electron apps.

从 2021 年 9 月开始,Electron 将每 8 周发布一个新的主要稳定版本,以匹配 Chromium 每 8 周发布一次的扩展稳定版本。

¥Beginning in September 2021, Electron will release a new major stable version every 8 weeks, to match Chromium's 8 week Extended Stable releases.

我们基于 Chromium Extended Stable 的第一个版本 Electron 15 将于 2021 年 9 月 21 日发布。

¥Our first release with Chromium Extended Stable will be Electron 15 on September 21st, 2021.

鉴于发布节奏的变更将影响其他下游应用,我们希望尽快告知开发者社区。继续阅读有关我们 2021 年发布计划的更多详情。

¥Knowing that a release cadence change will impact other downstream applications, we wanted to let our developer community know as soon as possible. Read on for more details about our 2021 release schedule.

Electron 15:临时 Alpha 测试版

¥Electron 15: Temporary Alpha

鉴于我们最初的 Electron 15 版本定位于非扩展稳定版本(Chromium 的扩展稳定版本基于其偶数版本),我们需要更改最初的目标发布日期。但是,Electron 应用必须使用最新的两个主要版本的 Chromium 才能被微软商店接受,这使得等待两个 Chromium 版本变得难以承受。

¥Given that our original Electron 15 release targeted a non-Extended Stable version (Chromium's Extended Stable versions are based on their even-numbered versions), we needed to change our original target release date. However, an Electron app must use the most recent 2 major versions of Chromium to be accepted to the Microsoft Store, which made waiting for two Chromium versions untenable.

由于这两个要求,我们的团队面临着时间上的困境。将 Electron 15 迁移到 Chromium M94 版本将允许应用开发者使用 Chromium 的第一个扩展稳定版本;然而,这也将 Beta 到稳定版本的周期缩短至仅 3 周。

¥With these two requirements, our team faced a timing dilemma. Moving Electron 15 to include Chromium M94 would allow app developers to get on the very first Extended Stable version of Chromium; however, it would also shorten the beta-to-stable cycle to only 3 weeks.

为了协助完成此切换,Electron 将提供一个临时的 alpha 版本,仅适用于 Electron 15 版本。此 Alpha 版本将使开发者有更多时间测试和规划 Electron 15 的发布,并且其构建比我们目前的夜间版本更稳定。

¥To help with this switchover, Electron will offer a temporary alpha build, only for the Electron 15 release. This alpha build will allow developers more time to test and plan for an Electron 15 release, with a more stable build than our current nightlies.

Alpha 通道版本将于 2021 年 7 月 20 日发布,适用于 Electron 15。它将于 2021 年 9 月 1 日过渡到 Beta 版本,稳定版本目标发布时间为 2021 年 9 月 21 日。后续的 Electron 版本将不会有 Alpha 版本。

¥The alpha channel build will ship for Electron 15 on July 20th, 2021. It will transition to a beta release on September 1st, 2021 with a stable release target of September 21st, 2021. Subsequent Electron releases will not have alpha releases.

2021 年发布计划

¥2021 Plan for Releases

以下是我们 2021 年的当前发布计划:

¥Below is our current release schedule for 2021:

ElectronChromeAlpha 版本Beta 版本稳定版本稳定周期(周)
E13M91*2021 年 3 月 5 日2021 年 5 月 25 日12
E14M93*2021 年 5 月 26 日2021 年 8 月 31 日14
E15M942021 年 7 月 20 日2021 年 9 月 1 日2021 年 9 月 21 日9 点(包含 alpha 测试)
E16M96*2021 年 9 月 22 日2021 年 11 月 16 日8
E17M98*2021 年 11 月 17 日2022 年 2 月 1 日11

添加 Alpha 通道将 Electron 15 发布前的开发时间从 3 周延长至 9 周。 - 更接近我们新的 8 周周期,同时仍然满足 Windows 应用商店提交的要求。

¥Adding the alpha channel extends the development time before Electron 15's launch from 3 weeks to 9 weeks - closer to our new 8 week cycle, while still meeting the requirements for Windows Store submission.

为了进一步帮助应用开发者,从 2021 年剩余时间到 2022 年 5 月,我们还将扩展 Electron 的支持版本政策,从最新的 3 个版本扩展到最新的 4 个版本。这意味着即使你无法立即更改升级计划,旧版本的 Electron 仍将收到安全更新和修复。

¥To further help app developers, for the remainder of 2021 until May 2022, we will also be extending our supported versions policy from the latest 3 versions to the latest 4 versions of Electron. That means that even if you can't immediately alter your upgrade schedule, older versions of Electron will still receive security updates and fixes.

寻址关注点

¥Addressing Concerns

我们之所以在发布周期变更之前就发布这篇文章,是有原因的。我们知道更快的发布周期将对 Electron 应用产生切实的影响。 - 其中一些可能已经发现我们的主要发布节奏过于激进。

¥There's a reason we're publishing this post well before this release cycle change is scheduled. We know that a faster release cycle will have a real impact on Electron apps - some of which may already find our major release cadence aggressive.

我们已尝试解决以下常见问题:

¥We've tried to address common concerns below:

❓ 为什么要进行这样的更改?为什么不保持 12 周的发布节奏?

¥❓ Why even make this change? Why not keep the 12 week release cadence?

为了在 Electron 中提供最新版本的 Chromium,我们的进度安排需要与 Electron 保持一致。更多关于 Chromium 发布周期的信息,请参阅 此处

¥To deliver the most up-to-date versions of Chromium in Electron, our schedule needs to track theirs. More information around Chromium's release cycle can be found here.

此外,由于 Microsoft Store 新的提交要求,目前 12 周的发布节奏将无法维持。即使是基于最新稳定版 Electron 的应用,根据新的安全要求,也可能会经历大约两周的时间被拒绝。

¥Additionally, the current 12 week release cadence would be untenable with the Microsoft Store's new submission requirements. Even apps on the latest stable version of Electron would experience a roughly two week period where their app may be rejected under the new security requirements.

每个新的 Chromium 版本都包含新功能、错误修复/安全修复以及 V8 引擎改进。我们希望作为应用开发者的你能够及时获得这些更改,因此我们的稳定发布日期将继续与其他所有 Chromium 稳定版本保持一致。作为应用开发者,你将比以前更快地获得 Chromium 和 V8 的新功能和修复。

¥Every new Chromium release contains new features, bug fixes / security fixes, and V8 improvements. We want you, as app developers, to have these changes in a timely manner, so our stable release dates will continue to match every other Chromium stable release. As an app developer, you'll have access to new Chromium and V8 features and fixes sooner than before.

❓ 现有的 12 周发布计划已经进展迅速。团队正在采取哪些措施来简化升级?

¥❓ The existing 12 week release schedule already moves quickly. What steps are the team taking to make upgrading easier?

更频繁发布的一个优势是版本更小。我们理解升级 Electron 的主要版本可能很困难。我们希望较小的版本发布能够减少每次发布引入 Chromium 和 Node 的重大变更,以及更少的重大变更。

¥One advantage of more frequent releases is having smaller releases. We understand that upgrading Electron's major versions can be difficult. We hope that smaller releases will introduce fewer major Chromium and Node changes, as well as fewer breaking changes, per release.

❓ 未来 Electron 版本会有 Alpha 版本吗?

¥❓ Will there been an alpha release available for future Electron versions?

目前没有计划支持永久的 Alpha 版本。此 Alpha 版本仅适用于 Electron 15,旨在帮助开发者在缩短的发布期内更轻松地升级。

¥There are no plans to support a permanent alpha release at this time. This alpha is only intended for Electron 15, as a way to help developers upgrade more easily in the shortened release period.

❓ Electron 会扩展支持的版本数量吗?

¥❓ Will Electron extend the number of supported versions?

随着 Electron 19 的发布,我们将把 Electron 的支持版本政策从最新的三个版本扩展到最新的四个版本,直至 2022 年 5 月。Electron 19 发布后,我们将恢复到 支持最新的三个主要版本 版本,以及 Beta 版和 Nightly 版。

¥We will be extending our supported version policy from the latest three versions to the latest four versions of Electron until May 2022, with the release of Electron 19. After Electron 19 is released, we'll return to supporting the latest three major versions, as well as the beta and nightly releases.

E13 (2021 年 5 月)E14 (2021 年 8 月)E15 (2021 年 9 月)E16 (2021 年 11 月)E17 (2022 年 2 月)E18 (2022 年 3 月)E19 (2022 年 5 月)
13.x.y14.x.y15.x.y16.x.y17.x.y18.x.y19.x.y
12.x.y13.x.y14.x.y15.x.y16.x.y17.x.y18.x.y
11.x.y12.x.y13.x.y14.x.y15.x.y16.x.y17.x.y
----12.x.y13.x.y14.x.y15.x.y--

有问题吗?

¥Questions?

📨 如果你有任何问题或疑虑,请发送电子邮件至 info@electronjs.org加入我们的 Discord。我们知道这项变更将影响许多应用和开发者,你的反馈对我们非常重要。我们想听听你的意见!

¥📨 If you have questions or concerns, please mail us at info@electronjs.org or join our Discord. We know this is a change that will impact many apps and developers, and your feedback is very important to us. We want to hear from you!

Electron 13.0.0

· 7 min read

Electron 13.0.0 已发布!此更新包含对 Chromium 91 和 V8 9.1 的升级。我们添加了多个 API 更新、错误修复和常规改进。请阅读下文了解更多详情!

¥Electron 13.0.0 has been released! It includes upgrades to Chromium 91 and V8 9.1. We've added several API updates, bug fixes, and general improvements. Read below for more details!


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

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

技术栈变更

¥Stack Changes

亮点功能

¥Highlight Features

  • 添加了 process.contextIsolated 属性,用于指示当前渲染器上下文是否启用了 contextIsolation#28252

    ¥Added process.contextIsolated property that indicates whether the current renderer context has contextIsolation enabled. #28252

  • 添加了新的 session.storagePath API,用于获取会话特定数据在磁盘上的路径。#28866

    ¥Added new session.storagePath API to get the path on disk for session-specific data. #28866

  • 已弃用 WebContentsnew-window 事件。它已被 webContents.setWindowOpenHandler() 取代

    ¥Deprecated the new-window event of WebContents. It is replaced by webContents.setWindowOpenHandler()

  • 已添加 @electron/remote 使用的 process.contextId#28251

    ¥Added process.contextId used by @electron/remote. #28251

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

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

重大变化

¥Breaking Changes

  • window.open() 参数 frameName 不再设置为窗口标题。#27481

    ¥window.open() parameter frameName is no longer set as window title. #27481

  • 已将 session.setPermissionCheckHandler(handler) 更改为允许 handler 的第一个参数 webContentsnull#19903

    ¥Changed session.setPermissionCheckHandler(handler) to allow for handler's first parameter, webContents to be null. #19903

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

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

API 变更

¥API Changes

  • BrowserWindow 添加了 roundedCorners 选项。#27572

    ¥Added roundedCorners option for BrowserWindow. #27572

  • 添加了新的 session.storagePath API,用于获取会话特定数据在磁盘上的路径。28866

    ¥Added new session.storagePath API to get the path on disk for session-specific data.28866

  • 添加了通过上下文桥传递 DOM 元素的支持。#26776

    ¥Added support for passing DOM elements over the context bridge. #26776

  • 已将 process.uptime() 添加到沙盒渲染器。#26684

    ¥Added process.uptime() to sandboxed renderers. #26684

  • 为作为 context-menu 事件一部分发出的参数添加了缺失的字段。#26788

    ¥Added missing fields to the parameters emitted as part of the context-menu event.#26788

  • 添加了对注册 Manifest V3 扩展服务工作线程的支持。

    ¥Added support for registering Manifest V3 extension service workers.

  • 为 ServiceWorkers 添加了“registration-completed”事件。#27562

    ¥Added ‘registration-completed’ event to ServiceWorkers. #27562

移除/弃用的变更

¥Removed/Deprecated Changes

以下 API 已被删除或弃用:

¥The following APIs have been removed or are now deprecated:

  • 已弃用 WebContentsnew-window 事件。它已被 webContents.setWindowOpenHandler() 取代

    ¥Deprecated the new-window event of WebContents. It is replaced by webContents.setWindowOpenHandler()

  • 移除了已弃用的 shell.moveItemToTrash()#26723

    ¥Removed deprecated shell.moveItemToTrash(). #26723

  • 移除了以下已弃用的 BrowserWindow 扩展 API:

    ¥Removed the following deprecated BrowserWindow extension APIs:

    • BrowserWindow.addExtension(path)

    • BrowserWindow.addDevToolsExtension(path)

    • BrowserWindow.removeExtension(name)

    • BrowserWindow.removeDevToolsExtension(name)

    • BrowserWindow.getExtensions()

    • BrowserWindow.getDevToolsExtensions()

    请改用 session API:

    ¥Use the session APIs instead:

    • ses.loadExtension(path)

    • ses.removeExtension(extension_id)

    • ses.getAllExtensions()

  • 以下 systemPreferences 方法已被弃用:

    ¥The following systemPreferences methods have been deprecated:

    • systemPreferences.isDarkMode()

    • systemPreferences.isInvertedColorScheme()

    • systemPreferences.isHighContrastColorScheme()

    请改用以下 nativeTheme 属性:

    ¥Use the following nativeTheme properties instead:

    • nativeTheme.shouldUseDarkColors

    • nativeTheme.shouldUseInvertedColorScheme

    • nativeTheme.shouldUseHighContrastColors

10.x.y 终止支持

¥End of Support for 10.x.y

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

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

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。虽然我们谨慎地不对发布日期做出承诺,但我们计划大约每季度发布一次 Electron 的新主要版本及其组件的新版本。暂定 14.0.0 计划 模块列出了 Electron 14.0 开发生命周期中的关键日期。此外,查看我们的版本控制文档 提供了有关 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 release new major versions of Electron with new versions of those components approximately quarterly. The tentative 14.0.0 schedule maps out key dates in the Electron 14.0 development life cycle. Also, see our versioning document for more detailed information about versioning in Electron.

有关即将推出的 Electron 版本 查看我们的“计划重大变更”文档 中计划的重大变更的信息。

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

Electron 12.0.0

· 12 min read

Electron 12.0.0 已发布!它包含对 Chromium 89、V8 8.9 和 Node.js 14.16 的升级。我们添加了 remote 模块的更改、contextIsolation 的新默认值、新的 webFrameMain API 以及常规改进。请阅读下文了解更多详情!

¥Electron 12.0.0 has been released! It includes upgrades to Chromium 89, V8 8.9 and Node.js 14.16. We've added changes to the remote module, new defaults for contextIsolation, a new webFrameMain API, and general improvements. Read below for more details!


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

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

技术栈变更

¥Stack Changes

亮点功能

¥Highlight Features

  • ContextBridge exposeInMainWorld 方法现在可以公开非对象 API。#26834

    ¥The ContextBridge exposeInMainWorld method can now expose non-object APIs. #26834

  • 已从 Node 12 升级到 Node 14。#23249

    ¥Upgraded from Node 12 to Node 14. #23249

  • 添加了新的 webFrameMain API,用于从主进程访问 WebContents 实例的子框架。#25464

    ¥Added a new webFrameMain API for accessing sub-frames of a WebContents instance from the main process. #25464

  • contextIsolationworldSafeExecuteJavaScript 的默认值现已改为 true#27949 #27502

    ¥The default values of contextIsolation and worldSafeExecuteJavaScript are now true. #27949 #27502

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

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

重大变化

¥Breaking Changes

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

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

API 变更

¥API Changes

  • 添加了 webFrameMain API:webFrameMain 模块可用于在现有的 WebContents 实例中查找框架。这是现有 webFrame API 的主要流程等效部分。更多关于此新 API 的信息,请参阅 此处 和我们的 documentation

    ¥Added webFrameMain API: The webFrameMain module can be used to look up frames across existing WebContents instances. This is the main process equivalent of the existing webFrame API. More information about this new API can be found here, and in our documentation.

  • app API 变更:

    ¥app API changes:

    • 'child-process-gone' / app.getAppMetrics() 添加了非本地化的 serviceName#25975

      ¥Added non-localized serviceName to 'child-process-gone' / app.getAppMetrics(). #25975

    • 添加了新的 app.runningUnderRosettaTranslation 属性,用于检测何时在 Apple Silicon 上的 Rosetta 下运行。#26444

      ¥Added new app.runningUnderRosettaTranslation property to detect when running under rosetta on Apple silicon. #26444

    • render-process-gone 详细信息中添加了 exitCode(应用和 Web 内容)。#27677

      ¥Added exitCode to render-process-gone details (app & webContents). #27677

  • BrowserWindow API 变更:

    ¥BrowserWindow API changes:

    • 添加了 BrowserWindow.isTabletMode() API。#25209

      ¥Added BrowserWindow.isTabletMode() API. #25209

    • BrowserWindow 中添加了 resized (Windows/macOS) 和 moved (Windows) 事件。#26216

      ¥Added resized (Windows/macOS) and moved (Windows) events to BrowserWindow. #26216

    • 添加了新的 system-context-menu 事件,用于阻止和覆盖系统上下文菜单。#25795

      ¥Added new system-context-menu event to allow preventing and overriding the system context menu. #25795

    • 添加 win.setTopBrowserView() 以便可以触发 BrowserView#27713

      ¥Added win.setTopBrowserView() so that BrowserViews can be raised. #27713

    • 添加 webPreferences.preferredSizeMode 以允许根据文档的最小大小调整视图大小。#25874

      ¥Added webPreferences.preferredSizeMode to allow sizing views according to their document's minimum size. #25874

  • contextBridge API 变更:

    ¥contextBridge API changes:

    • 允许 ContextBridge exposeInMainWorld 方法公开非对象 API。#26834

      ¥Allowed ContextBridge exposeInMainWorld method to expose non-object APIs. #26834

  • display API 变更:

    ¥display API changes:

    • Display 对象中添加了 displayFrequency 属性,以便获取 Windows 上刷新率的信息。#26472

      ¥Added displayFrequency property to the Display object to allow getting information about the refresh rate on Windows. #26472

  • extensions API 变更:

    ¥extensions API changes:

    • 添加了对某些 chrome.management API 的支持。#25098

      ¥Added support for some chrome.management APIs. #25098

  • MenuItem API 变更:

    ¥MenuItem API changes:

    • 添加了对显示 macOS 共享菜单的支持。#25629

      ¥Added support for showing macOS share menu. #25629

  • net API 变更:

    ¥net API changes:

    • net.request() 添加了新的 credentials 选项。#25284

      ¥Added a new credentials option for net.request(). #25284

    • 添加了 net.online,用于检测当前是否有互联网连接。#21004

      ¥Added net.online for detecting whether there is currently internet connection. #21004

  • powerMonitor API 变更:

    ¥powerMonitor API changes:

    • 添加了 powerMonitor.onBatteryPower#26494

      ¥Added powerMonitor.onBatteryPower. #26494

    • 在 macOS 上为 powerMonitor 添加了快速用户切换事件。#25321

      ¥Added fast user switching event to powerMonitor on macOS. #25321

  • session API 变更:

    ¥session API changes:

    • ses.loadExtension() API 中添加了 allowFileAccess 选项。#27702

      ¥Added allowFileAccess option to ses.loadExtension() API. #27702

    • session.setPermissionRequestHandler 添加了 display-capture API。#27696

      ¥Added display-capture API for session.setPermissionRequestHandler. #27696

    • session.setSSLConfig 中添加了 disabledCipherSuites 选项。#25818

      ¥Added a disabledCipherSuites option to session.setSSLConfig. #25818

    • 已将 extension-loadedextension-unloadedextension-ready 事件添加到 session#25385

      ¥Added extension-loaded, extension-unloaded, and extension-ready events to session. #25385

    • 添加了 session.setSSLConfig() 以允许配置 SSL。#25461

      ¥Added session.setSSLConfig() to allow configuring SSL. #25461

    • 添加了在 session.setProxy() 中明确指定 directauto_detectsystem 模式的支持。#24937

      ¥Added support for explicitly specifying direct, auto_detect or system modes in session.setProxy(). #24937

    • 添加了 串行 API 支持。#25237

      ¥Added Serial API support. #25237

    • 添加了用于启用/禁用拼写检查器的 API。#26276

      ¥Added APIs to enable/disable spell checker. #26276

  • shell API 变更:

    ¥shell API changes:

    • 添加了新的异步 shell.trashItem() API,以取代同步 shell.moveItemToTrash()#25114

      ¥Added a new asynchronous shell.trashItem() API, replacing the synchronous shell.moveItemToTrash(). #25114

  • webContents API 变更:

    ¥webContents API changes:

    • 在控制台中添加了一个小型控制台提示,以帮助调试渲染器崩溃。#25317

      ¥Added a small console hint to console to help debug renderer crashes. #25317

    • 在 webRequest 处理程序的 detail 对象中添加了 framewebContents 属性。#27334

      ¥Added frame and webContents properties to the details object in webRequest handlers. #27334

    • 添加 webContents.forcefullyCrashRenderer() 以强制终止渲染器进程,以帮助恢复挂起的渲染器。#25580

      ¥Added webContents.forcefullyCrashRenderer() to forcefully terminate a renderer process to assist with recovering a hung renderer. #25580

    • 为渲染器创建的子窗口添加了 setWindowOpenHandler API,并弃用了 new-window 事件。#24517

      ¥Added setWindowOpenHandler API for renderer-created child windows, and deprecate new-window event. #24517

  • webFrame API 变更:

    ¥webFrame API changes:

    • 为渲染器添加了拼写检查 API。#25060

      ¥Added spellcheck API to renderer. #25060

移除/弃用的变更

¥Removed/Deprecated Changes

以下 API 已被删除或弃用:

¥The following APIs have been removed or are now deprecated:

  • 弃用 remote 模块。已被 @electron/remote 取代。#25293

    ¥Deprecated the remote module. It is replaced by @electron/remote. #25293

  • 移除已弃用的 crashReporter API。#26709

    ¥Removed deprecated crashReporter APIs. #26709

  • 从打包应用中的默认 '帮助' 菜单中移除了指向 Electron 网站的链接。#25831

    ¥Removed links to the Electron website from the default 'Help' menu in packaged apps. #25831

9.x.y 停止支持

¥End of Support for 9.x.y

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

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

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。虽然我们谨慎地不对发布日期做出承诺,但我们计划大约每季度发布一次 Electron 的新主要版本及其组件的新版本。暂定 13.0.0 计划 列出了 Electron 13.0 开发生命周期中的关键日期。此外,查看我们的版本控制文档 提供了有关 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 release new major versions of Electron with new versions of those components approximately quarterly. The tentative 13.0.0 schedule maps out key dates in the Electron 13.0 development life cycle. Also, see our versioning document for more detailed information about versioning in Electron.

有关即将推出的 Electron 版本 查看我们的“计划重大变更”文档 中计划的重大变更的信息。

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

Electron 11.0.0

· 8 min read

Electron 11.0.0 已发布!它包含对 Chromium 87、V8 8.7 和 Node.js 12.18.3 的升级。我们增加了对 Apple 芯片的支持,并进行了常规改进。请阅读下文了解更多详情!

¥Electron 11.0.0 has been released! It includes upgrades to Chromium 87, V8 8.7, and Node.js 12.18.3. We've added support for Apple silicon, and general improvements. Read below for more details!


Electron 团队非常高兴地宣布 Electron 11.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。此版本包含升级、修复和对 Apple M1 硬件的全新支持。

¥The Electron team is excited to announce the release of Electron 11.0.0! You can install it with npm via npm install electron@latest or download it from our releases website. The release is packed with upgrades, fixes, and new support for Apple's M1 hardware.

我们迫不及待地想看看你使用它们构建的内容!继续阅读以了解有关此版本的详细信息,并请分享你的任何反馈!

¥We can't wait to see what you build with them! Continue reading for details about this release, and please share any feedback you have!

显著变化

¥Notable Changes

技术栈变更

¥Stack Changes

亮点功能

¥Highlight Features

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

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

重大变化

¥Breaking Changes

  • 移除了实验性 API:BrowserView.{fromId, fromWebContents, getAllViews}BrowserViewid 属性。#23578

    ¥Removed experimental APIs: BrowserView.{fromId, fromWebContents, getAllViews} and the id property of BrowserView. #23578

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

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

API 变更

¥API Changes

  • 添加了可返回处理特定协议的应用详细信息的 app.getApplicationInfoForProtocol() API。#24112

    ¥Added app.getApplicationInfoForProtocol() API that returns detailed information about the app that handles a certain protocol. #24112

  • 添加了可根据文件路径和最大缩略图大小返回文件预览图的 app.createThumbnailFromPath() API。#24802

    ¥Added app.createThumbnailFromPath() API that returns a preview image of a file given its file path and a maximum thumbnail size. #24802

  • 添加 webContents.forcefullyCrashRenderer() 以强制终止渲染器进程,以帮助恢复挂起的渲染器。#25756

    ¥Added webContents.forcefullyCrashRenderer() to forcefully terminate a renderer process to assist with recovering a hung renderer. #25756

8.x.y 停止支持

¥End of Support for 8.x.y

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

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

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。虽然我们谨慎地不对发布日期做出承诺,但我们计划大约每季度发布一次 Electron 的新主要版本及其组件的新版本。暂定 12.0.0 计划 列出了 Electron 12.0 开发生命周期中的关键日期。此外,查看我们的版本控制文档 提供了有关 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 quarterly. The tentative 12.0.0 schedule maps out key dates in the Electron 12.0 development life cycle. Also, see our versioning document for more detailed information about versioning in Electron.

有关即将推出的 Electron 版本 查看我们的“计划重大变更”文档 中计划的重大变更的信息。

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

继续弃用 remote 模块

¥Continued Work for Deprecation of remote Module

我们开始着手在 Electron 9 中移除 remote 模块。我们计划在 Electron 14 中移除 remote 模块本身。

¥We started work to remove the remote module in Electron 9. We plan to remove the remote module itself in Electron 14.

请阅读并遵循 这个问题 了解弃用的完整计划和详情。

¥Read and follow this issue for full plans and details for deprecation.

要求原生 Node 模块具备上下文感知或 N-API 的最后一步(在 Electron 12 中)

¥Final Step for Requiring Native Node Modules to be Context Aware or N-API (in Electron 12)

从 Electron 6 开始,我们一直在努力确保在渲染器进程中加载​​的 原生 Node 模块 必须是 N-API上下文感知。强制执行此更改可以提高安全性、加快性能并减少维护工作量。该计划的最后一步是移除 Electron 12 中禁用渲染进程复用的功能。

¥From Electron 6 onwards, we've been laying the groundwork to require native Node modules loaded in the renderer process to be either N-API or Context Aware. Enforcing this change allows for stronger security, faster performance, and reduced maintenance workload. The final step of this plan is to remove the ability to disable render process reuse in Electron 12.

请阅读并遵循 这个问题 了解完整详情,包括建议的时间表。

¥Read and follow this issue for full details, including the proposed timeline.

Apple Silicon 支持

· 7 min read

随着 Apple Silicon 硬件将于今年晚些时候发布,你如何让你的 Electron 应用在新硬件上运行?

¥With Apple Silicon hardware being released later this year, what does the path look like for you to get your Electron app running on the new hardware?


随着 Electron 11.0.0-beta.1 的发布,Electron 团队现在正在发布可在 Apple 计划于今年晚些时候发布的全新 Apple Silicon 硬件上运行的 Electron 版本。你可以获取 npm install electron@beta 的最新测试版,也可以直接从我们的 发布网站 下载。

¥With the release of Electron 11.0.0-beta.1, the Electron team is now shipping builds of Electron that run on the new Apple Silicon hardware that Apple plans on shipping later this year. You can grab the latest beta with npm install electron@beta or download it directly from our releases website.

它是如何工作的?

¥How does it work?

从 Electron 11 开始,我们将为 Intel Mac 和 Apple Silicon Mac 分别发布不同的 Electron 版本。在此更改之前,我们已经发布了两个工件,darwin-x64mas-x64,后者用于 Mac App Store 兼容性。我们现在正在发布另外两个工件 darwin-arm64mas-arm64,它们是上述工件的 Apple Silicon 版本。

¥As of Electron 11, we will be shipping separate versions of Electron for Intel Macs and Apple Silicon Macs. Prior to this change, we were already shipping two artifacts, darwin-x64 and mas-x64, with the latter being for Mac App Store compatibility usage. We are now shipping another two artifacts, darwin-arm64 and mas-arm64, which are the Apple Silicon equivalents of the aforementioned artifacts.

我需要做什么?

¥What do I need to do?

你需要发布两个版本的应用:一个用于 x64(Intel Mac),一个用于 arm64(Apple Silicon)。好消息是,electron-packagerelectron-rebuildelectron-forge 已经支持 arm64 架构。只要你运行的是这些软件包的最新版本,那么在将目标架构更新到 arm64 后,你的应用就应该能够完美运行。

¥You will need to ship two versions of your app: one for x64 (Intel Mac) and one for arm64 (Apple Silicon). The good news is that electron-packager, electron-rebuild and electron-forge already support targeting the arm64 architecture. As long as you're running the latest versions of those packages, your app should work flawlessly once you update the target architecture to arm64.

In the future, we will release a package that allows you to "merge" your arm64 and x64 apps into a single universal binary, but it's worth noting that this binary would be huge and probably isn't ideal for shipping to users.

更新:此软件包现已在 @electron/universal 上线。你可以使用它将两个打包的 x64 和 arm64 应用合并为一个二进制文件。

¥Update: This package is now available at @electron/universal. You can use it to merge two packaged x64 and arm64 apps into a single binary.

潜在问题

¥Potential Issues

原生模块

¥Native Modules

由于你的目标是新的架构,因此需要更新一些依赖,这可能会导致构建问题。以下列出了部分依赖的最低版本,供你参考。

¥As you are targeting a new architecture, you'll need to update several dependencies which may cause build issues. The minimum version of certain dependencies are included below for your reference.

依赖版本要求
Xcode>=12.2.0
node-gyp>=7.1.0
electron-rebuild>=1.12.0
electron-packager>=15.1.0

由于这些依赖版本要求,你可能需要修复/更新某些原生模块。值得注意的是,Xcode 升级将引入新版本的 macOS SDK,这可能会导致原生模块的构建失败。

¥As a result of these dependency version requirements, you may have to fix/update certain native modules. One thing of note is that the Xcode upgrade will introduce a new version of the macOS SDK, which may cause build failures for your native modules.

如何测试?

¥How do I test it?

目前,Apple Silicon 应用仅在 Apple Silicon 硬件上运行,而截至撰写本文时,该硬件尚未上市。如果你拥有 开发者过渡工具包,则可以在其上测试你的应用。否则,你必须等到 Apple Silicon 量产硬件发布后才能测试你的应用是否正常运行。

¥Currently, Apple Silicon applications only run on Apple Silicon hardware, which isn't commercially available at the time of writing this blog post. If you have a Developer Transition Kit, you can test your application on that. Otherwise, you'll have to wait for the release of production Apple Silicon hardware to test if your application works.

Rosetta 2 怎么办?

¥What about Rosetta 2?

Rosetta 2 是 Apple Rosetta 技术的最新版本,它允许你在其新的 arm64 Apple Silicon 硬件上运行 x64 Intel 应用。虽然我们相信 x64 Electron 应用可以在 Rosetta 2 下运行,但仍有一些重要事项需要注意(以及为什么你应该发布原生 arm64 二进制文件的原因)。

¥Rosetta 2 is Apple's latest iteration of their Rosetta technology, which allows you to run x64 Intel applications on their new arm64 Apple Silicon hardware. Although we believe that x64 Electron apps will run under Rosetta 2, there are some important things to note (and reasons why you should ship a native arm64 binary).

  • 你的应用性能将显著下降。Electron / V8 使用 JIT 编译 JavaScript,由于 Rosetta 的工作方式,你将有效地运行两次 JIT(一次在 V8 中,一次在 Rosetta 中)。

    ¥Your app's performance will be significantly degraded. Electron / V8 uses JIT compilation for JavaScript, and due to how Rosetta works, you will effectively be running JIT twice (once in V8 and once in Rosetta).

  • 你失去了 Apple Silicon 新技术带来的好处,例如更大的内存页面大小。

    ¥You lose the benefit of new technology in Apple Silicon, such as the increased memory page size.

  • 我们是否提到过性能会显著下降?

    ¥Did we mention that the performance will be significantly degraded?