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.
Fixes#13729
Previously, when adding a window, we were unable to read its current
project paths out of the hash of the URL during window initialization
because the window still considered itself to be loading. Rather than
fixing this issue, we decided to completely eliminate the sharing of
state between processes in the window.location and instead switch to
cached synchronous RPC for the loadSettings and a dedicated RPC-based
mechanism for the project paths.
This performs restarts in the main process and uses ipc to request restarts from application windows. We preserve the following settings:
* dev mode
* custom resource path
* safe mode
* portable mode
* socket path
* log file path
* user data dir
Previously, we used to save the window's state in the renderer process
`beforeunload` event handler: because of the synchronous nature of event
handlers and the asynchronous design of IndexedDB, this could
potentially not save anything if windows close fast enough to prevent
IndexedDB from committing the pending transaction containing the state.
(Ref.: https://mzl.la/2bXCXDn)
With this commit, we will intercept the `before-quit` events on
`electron.app` and the `close` event on `BrowserWindow` (which will fire
respectively before quitting the application and before closing a
window), and prevent them from performing the default action. We will
then ask each renderer process to save its state and, finally, close the
window and/or the app.
If the object passed via IPC contains any keys of the same reference,
all but one of these keys will be nulled out. Converting to/from a
string avoids this problem.
Sometimes, the error event gets emitted before the renderer process has
the chance to subscribe. Therefore, we expose an
`autoUpdateManager.getErrorMessage()` in the browser process, so that we
don’t lose that information.
We can expose just a few event subscription methods on atom.update to
take care of what most packages (e.g. About) would be interested in. Of
course the updater runs on the main thread so we’re proxying them
through IPC. It’s fine.
We need to avoid using the module for synchronous IPC on startup, but
in some cases, we need to know when our asynchronous IPC messages have taken
effect. Now, methods like and
return Promises that indicate when the message has been processed.