Git Product home page Git Product logo

electron-spawn-perf-bug's Introduction

electron-spawn-bug

We've noticed a bug in macOS 11 (Big Sur) where calling require('child_process').spawn(โ€ฆ) is much slower when called in a code-signed app.

Tested (and reproducible) in Electron 10.1.3, 10.1.4, and 11.0.0-beta.13. Does not seem to be computer-specific and does not affect macOS 10.15 (Catalina).

This affects the main process (2-4ms to 8-10ms), but is especially noticeable in the renderer process since the entire UI freezes (from 1-4ms up to 500-3000ms on a MacBook Pro).

Code-signed Package Version

You need an Apple Developer code-signing certificate installed to reproduce this bug.

yarn install
yarn build
dist/mac/electron-spawn-bug.app/Contents/MacOS/electron-spawn-bug

Main process console output

spawn is fairly fast when run from the main script.

$ dist/mac/electron-spawn-bug.app/Contents/MacOS/electron-spawn-bug 
0: spawning "ls" process
0: spawn launched in 10 ms
1: spawning "ls" process
1: spawn launched in 9 ms
...
7: ls exited in 360 ms
8: ls exited in 358 ms
9: ls exited in 355 ms

Renderer output

spawn is synchronously slow (~400ms) when run from the renderer app.

Note: the entire UI freezes for ~4 seconds before this prints out

0: spawning "ls" process
0: spawn launched in 422 ms
1: spawning "ls" process
1: spawn launched in 466 ms
2: spawning "ls" process
2: spawn launched in 395 ms
...

5: ls exited in 2135 ms
6: ls exited in 1735 ms
7: ls exited in 1329 ms
8: ls exited in 873 ms
9: ls exited in 456 ms

Build non-code-signed version (works fine)

If you run the unpackaged app from command-line (yarn start) or build it without code-signing, it's fast.

yarn install
yarn build-no-sign
dist/mac/electron-spawn-bug.app/Contents/MacOS/electron-spawn-bug

Main process console output

$ dist/mac/electron-spawn-bug.app/Contents/MacOS/electron-spawn-bug 
0: spawning "ls" process
0: spawn launched in 4 ms
1: spawning "ls" process
1: spawn launched in 2 ms
2: spawning "ls" process
2: spawn launched in 3 ms
3: spawning "ls" process
3: spawn launched in 3 ms
...
5: ls exited in 251 ms
6: ls exited in 249 ms
7: ls exited in 247 ms
8: ls exited in 244 ms
9: ls exited in 243 ms

Renderer output

0: spawning "ls" process
0: spawn launched in 4 ms
1: spawning "ls" process
1: spawn launched in 1 ms
2: spawning "ls" process
2: spawn launched in 2 ms
3: spawning "ls" process
3: spawn launched in 2 ms
...
6: ls exited in 27 ms
7: ls exited in 26 ms
8: ls exited in 25 ms
9: ls exited in 24 ms

License

CC0 1.0 (Public Domain)

electron-spawn-perf-bug's People

Contributors

marcello3d avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.