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

fix: initialize asar support in worker threads #33216

Merged

Conversation

indutny
Copy link
Contributor

@indutny indutny commented Mar 10, 2022

Description of Change

Use ObjectWrap instead of gin's Wrap in electron_api_asar.cc because
gin isn't fully initialized (and apparently not possible to initialize
without ruining the isolate configuration and array buffer allocator) in
worker threads. In the worker thread call setupAsarSupport just as we
do for the main process.

Test case: github.com/indutny-signal/asar-worker

cc @codebytere

Checklist

Release Notes

Notes: fix: initialize asar support in worker threads

@indutny indutny requested review from a team as code owners March 10, 2022 02:03
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Mar 10, 2022
@indutny-signal indutny-signal force-pushed the feature/asar-support-in-worker-threads branch from ccb5b37 to 98bc950 Compare March 10, 2022 02:15
Use `ObjectWrap` instead of gin's Wrap in `electron_api_asar.cc` because
gin isn't fully initialized (and apparently not possible to initialize
without ruining the isolate configuration and array buffer allocator) in
worker threads. In the worker thread call `setupAsarSupport` just as we
do for the main process.
@indutny indutny force-pushed the feature/asar-support-in-worker-threads branch from 98bc950 to 3a05f9c Compare March 10, 2022 02:51
Copy link
Member

@RaisinTen RaisinTen left a comment

Choose a reason for hiding this comment

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

Would it make sense to add the test to spec/asar-spec.js and include the asar in spec/fixtures?

lib/asar/fs-wrapper.ts Outdated Show resolved Hide resolved
patches/node/worker_thread_add_asar_support.patch Outdated Show resolved Hide resolved
indutny and others added 3 commits March 9, 2022 22:26
Co-authored-by: Darshan Sen <raisinten@gmail.com>
Co-authored-by: Darshan Sen <raisinten@gmail.com>
@indutny-signal
Copy link
Contributor

indutny-signal commented Mar 10, 2022

@RaisinTen good point. Added a test into spec-main's asar test suite. Thank you!

@indutny-signal
Copy link
Contributor

I suppose I can also cc @zcbenz , not sure who the code owner is for this part of the code.

@indutny-signal
Copy link
Contributor

(Friendly ping to keep the notifications up in inbox)

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Mar 17, 2022
@zcbenz zcbenz added semver/patch backwards-compatible bug fixes target/17-x-y labels Mar 21, 2022
@indutny-signal
Copy link
Contributor

Awesome. Thanks for approving! Do we need one more approval to merge it @zcbenz ?

@zcbenz
Copy link
Member

zcbenz commented Mar 21, 2022

I prefer waiting for one more approval, but if there is none I think it is ok to just merge this.

@indutny
Copy link
Contributor Author

indutny commented Mar 22, 2022

cc @MarshallOfSound @nornagon and just in case @codebytere

@jkleinsc jkleinsc merged commit 06a00b7 into electron:main Mar 23, 2022
@release-clerk
Copy link

release-clerk bot commented Mar 23, 2022

Release Notes Persisted

fix: initialize asar support in worker threads

trop bot pushed a commit that referenced this pull request Mar 23, 2022
* fix: initialize asar support in worker threads

Use `ObjectWrap` instead of gin's Wrap in `electron_api_asar.cc` because
gin isn't fully initialized (and apparently not possible to initialize
without ruining the isolate configuration and array buffer allocator) in
worker threads. In the worker thread call `setupAsarSupport` just as we
do for the main process.

* Update lib/asar/fs-wrapper.ts

Co-authored-by: Darshan Sen <raisinten@gmail.com>

* Update patches/node/worker_thread_add_asar_support.patch

Co-authored-by: Darshan Sen <raisinten@gmail.com>

* Add a test

Co-authored-by: Darshan Sen <raisinten@gmail.com>
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
trop bot pushed a commit that referenced this pull request Mar 23, 2022
* fix: initialize asar support in worker threads

Use `ObjectWrap` instead of gin's Wrap in `electron_api_asar.cc` because
gin isn't fully initialized (and apparently not possible to initialize
without ruining the isolate configuration and array buffer allocator) in
worker threads. In the worker thread call `setupAsarSupport` just as we
do for the main process.

* Update lib/asar/fs-wrapper.ts

Co-authored-by: Darshan Sen <raisinten@gmail.com>

* Update patches/node/worker_thread_add_asar_support.patch

Co-authored-by: Darshan Sen <raisinten@gmail.com>

* Add a test

Co-authored-by: Darshan Sen <raisinten@gmail.com>
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
@trop
Copy link
Contributor

trop bot commented Mar 23, 2022

I have automatically backported this PR to "17-x-y", please check out #33395

@trop
Copy link
Contributor

trop bot commented Mar 23, 2022

I have automatically backported this PR to "18-x-y", please check out #33396

@indutny-signal indutny-signal deleted the feature/asar-support-in-worker-threads branch March 23, 2022 00:43
@indutny-signal
Copy link
Contributor

Thank you!

zcbenz pushed a commit that referenced this pull request Mar 24, 2022
* fix: initialize asar support in worker threads (#33216)

* fix: initialize asar support in worker threads

Use `ObjectWrap` instead of gin's Wrap in `electron_api_asar.cc` because
gin isn't fully initialized (and apparently not possible to initialize
without ruining the isolate configuration and array buffer allocator) in
worker threads. In the worker thread call `setupAsarSupport` just as we
do for the main process.

* Update lib/asar/fs-wrapper.ts

Co-authored-by: Darshan Sen <raisinten@gmail.com>

* Update patches/node/worker_thread_add_asar_support.patch

Co-authored-by: Darshan Sen <raisinten@gmail.com>

* Add a test

Co-authored-by: Darshan Sen <raisinten@gmail.com>
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

* chore: update .patches after merge

Co-authored-by: Fedor Indutny <fedor@indutny.com>
Co-authored-by: Darshan Sen <raisinten@gmail.com>
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
@trop trop bot removed the in-flight/17-x-y label Mar 24, 2022
jkleinsc added a commit that referenced this pull request Mar 24, 2022
* fix: initialize asar support in worker threads (#33216)

* fix: initialize asar support in worker threads

Use `ObjectWrap` instead of gin's Wrap in `electron_api_asar.cc` because
gin isn't fully initialized (and apparently not possible to initialize
without ruining the isolate configuration and array buffer allocator) in
worker threads. In the worker thread call `setupAsarSupport` just as we
do for the main process.

* Update lib/asar/fs-wrapper.ts

Co-authored-by: Darshan Sen <raisinten@gmail.com>

* Update patches/node/worker_thread_add_asar_support.patch

Co-authored-by: Darshan Sen <raisinten@gmail.com>

* Add a test

Co-authored-by: Darshan Sen <raisinten@gmail.com>
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

* chore: update patches

Co-authored-by: Fedor Indutny <fedor@indutny.com>
Co-authored-by: Darshan Sen <raisinten@gmail.com>
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
bavulapati pushed a commit to bavulapati/electron that referenced this pull request Apr 29, 2022
* fix: initialize asar support in worker threads

Use `ObjectWrap` instead of gin's Wrap in `electron_api_asar.cc` because
gin isn't fully initialized (and apparently not possible to initialize
without ruining the isolate configuration and array buffer allocator) in
worker threads. In the worker thread call `setupAsarSupport` just as we
do for the main process.

* Update lib/asar/fs-wrapper.ts

Co-authored-by: Darshan Sen <raisinten@gmail.com>

* Update patches/node/worker_thread_add_asar_support.patch

Co-authored-by: Darshan Sen <raisinten@gmail.com>

* Add a test

Co-authored-by: Darshan Sen <raisinten@gmail.com>
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
* fix: initialize asar support in worker threads

Use `ObjectWrap` instead of gin's Wrap in `electron_api_asar.cc` because
gin isn't fully initialized (and apparently not possible to initialize
without ruining the isolate configuration and array buffer allocator) in
worker threads. In the worker thread call `setupAsarSupport` just as we
do for the main process.

* Update lib/asar/fs-wrapper.ts

Co-authored-by: Darshan Sen <raisinten@gmail.com>

* Update patches/node/worker_thread_add_asar_support.patch

Co-authored-by: Darshan Sen <raisinten@gmail.com>

* Add a test

Co-authored-by: Darshan Sen <raisinten@gmail.com>
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
nzh63 added a commit to nzh63/Ame that referenced this pull request Oct 22, 2023
参见electron/electron#33216
electron已经支持从asar中启动worker threads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants