This new private API will allow settings-view to communicate
asynchronously with the main process to resolve proxies, instead of
using `remote` and blocking the renderer process during startup.
This will still notify render processes when such events are triggered
without, however, incurring the additional cost of synchronously
retrieving a `BrowserWindow` (and its properties) via `remote` during
startup.
This commit will register the `display-added` and `display-removed`
events only once in the main process in order to disable zoom (see
https://github.com/atom/atom/pull/11345) directly instead of
unnecessarily paying for I/O in the renderer process during startup.
When accessing objects in the main process via the `remote` module,
Electron returns proxy objects that are references to the original ones.
This means that trying to access a remote object's property or function
results in a synchronous message exchange with the main process.
In Atom core we frequently access the load settings coming from the main
process, especially during startup. This caused a lot of synchronous I/O
which was blocking the renderer process for several milliseconds.
With this commit, instead of exposing load settings as a JavaScript
object, we serialize them to JSON in the main process and parse them
back to a JavaScript object in the renderer processes. This allows us to
get a full copy of the object locally and pay for I/O just once when
retrieving load settings from the main process for the first time.
Whoops:
```
Cannot read property 'setPath' of undefined
TypeError: Cannot read property 'setPath' of undefined
at Object.setUserData (C:\Users\Segev\Atom\Atom x64\resources\app.asar\src\atom-paths.js:53:12)
at start (C:\Users\Segev\Atom\Atom x64\resources\app.asar\src\main-process\start.js:27:13)
at Object.<anonymous> (C:\Users\Segev\Atom\Atom x64\resources\app.asar\src\main-process\main.js:36:1)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Object.<anonymous> (C:\Users\Segev\Atom\Atom x64\resources\electron.asar\browser\init.js:166:8)
at Module._compile (module.js:556:32)
```
I didn't test this, submitted directly from GitHub.