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

feat: add helper process #2753

Merged
merged 18 commits into from
Jun 13, 2023
Merged

feat: add helper process #2753

merged 18 commits into from
Jun 13, 2023

Conversation

pengx17
Copy link
Collaborator

@pengx17 pengx17 commented Jun 11, 2023

fix #2614

The goal is to have another helper process using Electron's new UtilityProcess API to offload the blocking APIs (workspace, DB, dialog).

In order to do so, we need to have a different solution than the existing IPC based solutions. Here in this PR we introduced a MessagePort enabled bi-directional communication between UtilityProcess and renderer, and abstract the API with async-rpc-call recommended by @himself65.

The issues

  • since we added another peer (helper) that we have a total of three now, the communication and initialization logic between each peer shall be dealt with differently.
    • we need three pairs of bidirectional RPC now between main, helper and renderer
    • main and helper shall be initialized earlier than renderer and will pass the api meta to renderer
    • both main and helper will expose APIs to renderer, but with different scopes (mostly, helper cannot invoke electron related APIs)
  • there is no good solution for PUSH notifications based on JSON-RPC/async-call-rpc yet. We have to hack it around. See rpc.postEvent
  • types are mostly ignored. We shall revisit it later.

The general design:
image

@codesandbox
Copy link

codesandbox bot commented Jun 11, 2023

This branch is running in CodeSandbox. Use the links below to review this PR faster.


CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders | Preview

@vercel
Copy link

vercel bot commented Jun 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
affine-preview ❌ Failed (Inspect) Jun 12, 2023 2:31pm
affine-storybook ❌ Failed (Inspect) Jun 12, 2023 2:31pm

@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:00 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:00 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:00 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:00 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:00 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:00 — with GitHub Actions Inactive
@github-actions github-actions bot added app:electron Related to electron app test labels Jun 11, 2023
@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:03 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Jun 11, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.12 ⚠️

Comparison is base (dff8a0d) 69.76% compared to head (8284601) 69.65%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2753      +/-   ##
==========================================
- Coverage   69.76%   69.65%   -0.12%     
==========================================
  Files         335      335              
  Lines        7204     7204              
  Branches     1021     1021              
==========================================
- Hits         5026     5018       -8     
- Misses       1875     1882       +7     
- Partials      303      304       +1     
Flag Coverage Δ
e2etest 62.89% <ø> (-0.15%) ⬇️
e2etest-macos-latest-x64 ∅ <ø> (∅)
e2etest-ubuntu-latest-x64 45.17% <ø> (-0.02%) ⬇️
e2etest-windows-latest-x64 ∅ <ø> (?)
server-test 73.11% <ø> (ø)
unittest 50.47% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/debug/src/index.ts 57.89% <ø> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:04 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:04 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:04 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:04 — with GitHub Actions Inactive
@vercel vercel bot temporarily deployed to Preview – affine-preview June 11, 2023 16:05 Inactive
@perfsee
Copy link

perfsee bot commented Jun 11, 2023

affine-toeverything

Bundle main

diff ------------------- Bundle Size Diff -------------------------

@@                       EntryPoint: main                        @@
##                     master …elper-process                 +/- ##
===================================================================
= Bundle              4.44 MB        4.44 MB                       
= Initial JS          2.33 MB        2.33 MB                       
= Initial CSS          117 kB         117 kB                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
= Assets                   77             77                       
= Chunks                   60             60                       
= Packages                196            196                       
= Duplicates               15             15                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~#
! Deduplicate versions of libraries                                
! Separate mixed content assets files                              
! Avoid non-minified assets                                        

@@                    EntryPoint: pages/_app                     @@
##                     master …elper-process                 +/- ##
===================================================================
= Bundle              4.32 MB        4.32 MB                       
= Initial JS          2.21 MB        2.21 MB                       
= Initial CSS          117 kB         117 kB                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
= Assets                   75             75                       
= Chunks                   58             58                       
= Packages                196            196                       
= Duplicates               15             15                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~#
! Deduplicate versions of libraries                                
! Separate mixed content assets files                              
! Avoid non-minified assets                                        

@@                   EntryPoint: pages/_error                    @@
##                     master …elper-process                 +/- ##
===================================================================
= Bundle              16.6 kB        16.6 kB                       
= Initial JS          16.6 kB        16.6 kB                       
= Initial CSS             0 B            0 B                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
= Assets                    2              2                       
= Chunks                    2              2                       
= Packages                  5              5                       
= Duplicates                0              0                       

...and more

@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:05 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:05 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:05 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 16:05 — with GitHub Actions Inactive
@cloudflare-pages
Copy link

cloudflare-pages bot commented Jun 11, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8284601
Status: ✅  Deploy successful!
Preview URL: https://37e46ba6.affine-dev.pages.dev
Branch Preview URL: https://xp-0611-feat-helper-process.affine-dev.pages.dev

View logs

@vercel vercel bot temporarily deployed to Preview – affine-storybook June 11, 2023 16:08 Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 17:23 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 17:23 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 11, 2023 17:23 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 14:28 — with GitHub Actions Inactive
@vercel vercel bot temporarily deployed to Preview – affine-storybook June 12, 2023 14:31 Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 14:32 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 14:32 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 14:32 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 14:32 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 14:32 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 14:32 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 14:32 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 14:32 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@pengx17 pengx17 temporarily deployed to development June 12, 2023 15:36 — with GitHub Actions Inactive
@himself65 himself65 merged commit 5ba2dff into master Jun 13, 2023
6 of 8 checks passed
@himself65 himself65 deleted the xp/0611/feat/helper-process branch June 13, 2023 02:01
himself65 pushed a commit that referenced this pull request Jun 14, 2023
(cherry picked from commit 5ba2dff)
himself65 pushed a commit that referenced this pull request Jun 15, 2023
(cherry picked from commit 5ba2dff)
himself65 pushed a commit that referenced this pull request Jun 16, 2023
(cherry picked from commit 5ba2dff)
himself65 pushed a commit that referenced this pull request Jun 20, 2023
(cherry picked from commit 5ba2dff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app:electron Related to electron app app:web mod:dev
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Move DB handler implementations off main process
2 participants