Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore(deps): Upgrade electron to 20 #7692

Merged
merged 23 commits into from Jan 9, 2023
Merged

Conversation

sprocketc
Copy link
Collaborator

@sprocketc sprocketc commented Dec 12, 2022

Electron 19 reached end of support. Upgrading would also (hopefully) help us resolve various font rendering issues on linux. Electron 22.0.0 was released a couple of weeks ago, but it might be too soon to upgrade to 22. Also, electron 21 introduced a breaking change related to V8 Memory Cage that might cause issues. so I decided to go with 20 for now.

  • Upgrade to electron to 20.3.8
  • Upgade better-sqlite3 to 8.0.1 to include this fix (no relevant breaking changes on 8.0.0)
  • Set sandbox window option to false (renderers are sandboxed by default on electron 20+)
  • Rename and upgrade electron-rebuild to @electron/rebuild 3.2.10 (name deprecation notice here)
  • Upgrade nan to handle this issue
  • Upgrade electron-forge to 6.0.4 (this is a good opportunity to move to a stable version)

Successfully built and tested on

  • Linux
  • Windows
  • MacOS

Regarding electron 21+

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

See #7692 (comment)

@github-actions github-actions bot added the :type/dev This label is used to indicate that an issue or PR is related to development tasks or changes that label Dec 12, 2022
@sprocketc sprocketc marked this pull request as ready for review December 13, 2022 11:36
@cnrpman
Copy link
Collaborator

cnrpman commented Dec 13, 2022

Good!
For more time to collect feedback, can we hold this until 0.8.13 is cut?

@sprocketc sprocketc added the :type/hold Hold this PR. won't merge for now label Dec 13, 2022
@andelf
Copy link
Collaborator

andelf commented Dec 14, 2022

Fails to build on my macOS. Even after rm all and starting over.

electron-rebuild fails to rebuild fsevents with an error message related to the nan package.

@sprocketc sprocketc marked this pull request as draft December 14, 2022 11:33
@cnrpman
Copy link
Collaborator

cnrpman commented Dec 14, 2022

Check the rendering issue after upgrade:
#7233 (comment)

@sprocketc sprocketc marked this pull request as ready for review December 14, 2022 16:30
This reverts commit cc63ce5.
@Bad3r
Copy link
Collaborator

Bad3r commented Dec 15, 2022

✅ Tested building and running on Arch Linux using the latest kernel 6.1.0 using NodeJS LTS 16 (gallium). Logseq builds with NodeJS LTS 18 (hydrogen) but crashes when re-indexing the graph

[3591228:1215/015431.290602:ERROR:node_bindings.cc(146)] Fatal error in V8: v8_ArrayBuffer_NewBackingStore When the V8 Sandbox is enabled, ArrayBuffer backing stores must be allocated inside the sandbox address space. Please use an appropriate ArrayBuffer::Allocator to allocate these buffers.
[3591344:1215/015432.786357:ERROR:broker_posix.cc(40)] Recvmsg error: Connection reset by peer (104)
Segmentation fault (core dumped)

@Bad3r Bad3r self-requested a review December 15, 2022 07:06
@sprocketc
Copy link
Collaborator Author

@Bad3r Thanks a lot for testing this! I updated the description of the PR with information that might be related to your issue. Could you please also post the exact versions of NodeJS that you used?

@sprocketc
Copy link
Collaborator Author

electron-rebuild fails to rebuild fsevents with an error message related to the nan package.

@andelf Thanks! That should be handled now.

@Bad3r
Copy link
Collaborator

Bad3r commented Dec 15, 2022

Could you please also post the exact versions of NodeJS that you used?

I used NodeJS LTS Hydrogen (18.12.1)

https://nodejs.dev/en/about/releases/

Btw logseq fails to build with NodeJS 19/electron 21 due to better-sqlite3

In the electron 21 pr you linked to, they mention using NodeJS 16.17.0
(WiseLibs/better-sqlite3#870)

@Bad3r
Copy link
Collaborator

Bad3r commented Dec 21, 2022

Is there more testing needed before pushing v20?

@sprocketc
Copy link
Collaborator Author

Is there more testing needed before pushing v20?

Hey @Bad3r! We put this on hold until 0.8.13-14. Let's wait for the rest of the team to also take a look. You have done more than enough ❤️

@cnrpman
Copy link
Collaborator

cnrpman commented Jan 3, 2023

I hope now it's a good chance to introduce the upgrade?

@cnrpman cnrpman added the looking-for-review PRs that requires attention label Jan 3, 2023
@Bad3r Bad3r changed the title Chore (deps): Upgrade electron to 20 Chore(deps): Upgrade electron to 20 Jan 3, 2023
@Bad3r Bad3r added this to the 0.8.16 milestone Jan 4, 2023
@tiensonqin
Copy link
Contributor

Any blockers on this PR?

@sprocketc
Copy link
Collaborator Author

Any blockers on this PR?

We should be good to merge this.

@Bad3r Bad3r self-requested a review January 6, 2023 04:40
Copy link
Collaborator

@Bad3r Bad3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 
I have been testing it on Linux for a while without any issues

@tiensonqin tiensonqin merged commit 2e929eb into master Jan 9, 2023
@tiensonqin tiensonqin deleted the chore/upgrade-electron branch January 9, 2023 05:57
@tiensonqin
Copy link
Contributor

Awesome, merged! 🚢

sallto pushed a commit to sallto/logseq that referenced this pull request Jan 18, 2023
@cnrpman
Copy link
Collaborator

cnrpman commented Mar 16, 2023

If you met this in the main.log (log for Electron main thread) in dev environment:

[2023-03-16 16:32:00.562] [error] Error: The module '/Users/jun/git/logseq/static/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 108. This version of Node.js requires
NODE_MODULE_VERSION 107. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).: local

try the following command to rebuild better-sqlite3:

  1. go to the better-sqlite3 folder in node_modules inside the static folder;
  2. npx node-gyp rebuild --release --target=20.3.8 --dist-url=https://electronjs.org/headers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
looking-for-review PRs that requires attention :type/dev This label is used to indicate that an issue or PR is related to development tasks or changes that
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants