chore: update to Electron 22 (#177600)

* Revert "chore: revert to Electron 19 (#175851)"

This reverts commit 3a11b47eee.

* chore: bump electron@22.3.3

* build: use custom version for V8 sandbox

* chore: update electron@22.4.1

* chore: enable forceAllocationsToV8Sandbox for extension host

* chore: bump electron@22.4.2

* chore: bump electron@22.4.3

* sandbox - cleanup from electron 22 update (#178919)

* Revert "chore: revert to Electron 19 (#175851)"

This reverts commit 3a11b47eee.

* chore: bump electron@22.3.3

* build: use custom version for V8 sandbox

* chore: update electron@22.4.1

* chore: enable forceAllocationsToV8Sandbox for extension host

* chore: bump electron@22.4.2

* chore: bump electron@22.4.3

* temp: update distro

* sandbox - cleanup from electron 22 update

* missing comile

* more changes

* fix build

* restore

* 💄

* compile

---------

Co-authored-by: deepak1556 <hop2deep@gmail.com>

---------

Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com>
This commit is contained in:
Robo
2023-04-03 09:09:31 +02:00
committed by GitHub
co-authored by Benjamin Pasero
parent fdb61c765f
commit e5f61433b5
68 changed files with 368 additions and 1871 deletions
@@ -1,18 +0,0 @@
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; connect-src 'self' https:;">
</head>
<body aria-label="">
Shared Process
</body>
<!-- Startup (do not modify order of script tags!) -->
<script src="../../../../bootstrap.js"></script>
<script src="../../../../vs/loader.js"></script>
<script src="../../../../bootstrap-window.js"></script>
<script src="sharedProcess.js"></script>
</html>
@@ -1,15 +0,0 @@
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; connect-src 'self' https:;">
</head>
<body aria-label="">
Shared Process
</body>
<!-- Startup (do not modify order of script tags!) -->
<script src="sharedProcess.js"></script>
</html>
@@ -1,46 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
//@ts-check
(function () {
'use strict';
const bootstrapWindow = bootstrapWindowLib();
// Load shared process into window
bootstrapWindow.load(['vs/code/node/sharedProcess/sharedProcessMain'], function (sharedProcess, configuration) {
return sharedProcess.main(configuration);
},
{
configureDeveloperSettings: function () {
return {
disallowReloadKeybinding: true
};
}
}
);
/**
* @typedef {import('../../../base/parts/sandbox/common/sandboxTypes').ISandboxConfiguration} ISandboxConfiguration
*
* @returns {{
* load: (
* modules: string[],
* resultCallback: (result, configuration: ISandboxConfiguration) => unknown,
* options?: {
* configureDeveloperSettings?: (config: ISandboxConfiguration) => {
* forceEnableDeveloperKeybindings?: boolean,
* disallowReloadKeybinding?: boolean,
* removeDeveloperKeybindingsAfterLoad?: boolean
* }
* }
* ) => Promise<unknown>
* }}
*/
function bootstrapWindowLib() {
// @ts-ignore (defined in bootstrap-window.js)
return window.MonacoBootstrapWindow;
}
}());
@@ -4,9 +4,6 @@
*--------------------------------------------------------------------------------------------*/
/* eslint-disable local/code-layering, local/code-import-patterns */
// TODO@bpasero remove these once utility process is the only way
import { Server as BrowserWindowMessagePortServer } from 'vs/base/parts/ipc/electron-browser/ipc.mp';
import { SharedProcessWorkerService } from 'vs/platform/sharedProcess/electron-browser/sharedProcessWorkerService';
import { ILocalPtyService } from 'vs/platform/terminal/electron-sandbox/terminal';
import { hostname, release } from 'os';
@@ -15,7 +12,7 @@ import { onUnexpectedError, setUnexpectedErrorHandler } from 'vs/base/common/err
import { combinedDisposable, Disposable, toDisposable } from 'vs/base/common/lifecycle';
import { Schemas } from 'vs/base/common/network';
import { URI } from 'vs/base/common/uri';
import { IPCServer, ProxyChannel, StaticRouter } from 'vs/base/parts/ipc/common/ipc';
import { ProxyChannel, StaticRouter } from 'vs/base/parts/ipc/common/ipc';
import { Server as UtilityProcessMessagePortServer, once } from 'vs/base/parts/ipc/node/ipc.mp';
import { CodeCacheCleaner } from 'vs/code/node/sharedProcess/contrib/codeCacheCleaner';
import { LanguagePackCachedDataCleaner } from 'vs/code/node/sharedProcess/contrib/languagePackCachedDataCleaner';
@@ -85,7 +82,6 @@ import { ISharedTunnelsService } from 'vs/platform/tunnel/common/tunnel';
import { SharedTunnelsService } from 'vs/platform/tunnel/node/tunnelService';
import { ipcSharedProcessTunnelChannelName, ISharedProcessTunnelService } from 'vs/platform/remote/common/sharedProcessTunnelService';
import { SharedProcessTunnelService } from 'vs/platform/tunnel/node/sharedProcessTunnelService';
import { ISharedProcessWorkerService } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { UriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentityService';
import { isLinux } from 'vs/base/common/platform';
@@ -107,8 +103,6 @@ import { UserDataSyncResourceProviderService } from 'vs/platform/userDataSync/co
import { ExtensionsContributions } from 'vs/code/node/sharedProcess/contrib/extensions';
import { localize } from 'vs/nls';
import { LogService } from 'vs/platform/log/common/logService';
import { ipcUtilityProcessWorkerChannelName, IUtilityProcessWorkerConfiguration } from 'vs/platform/utilityProcess/common/utilityProcessWorkerService';
import { isUtilityProcess } from 'vs/base/parts/sandbox/node/electronTypes';
import { ISharedProcessLifecycleService, SharedProcessLifecycleService } from 'vs/platform/lifecycle/node/sharedProcessLifecycleService';
import { RemoteTunnelService } from 'vs/platform/remoteTunnel/node/remoteTunnelService';
import { ExtensionsProfileScannerService } from 'vs/platform/extensionManagement/node/extensionsProfileScannerService';
@@ -122,21 +116,13 @@ import { RemoteStorageService } from 'vs/platform/storage/common/storageService'
class SharedProcessMain extends Disposable {
private readonly server: IPCServer;
private sharedProcessWorkerService: ISharedProcessWorkerService | undefined = undefined;
private readonly server = this._register(new UtilityProcessMessagePortServer());
private lifecycleService: SharedProcessLifecycleService | undefined = undefined;
constructor(private configuration: ISharedProcessConfiguration, private ipcRenderer?: typeof import('electron').ipcRenderer) {
constructor(private configuration: ISharedProcessConfiguration) {
super();
if (isUtilityProcess(process)) {
this.server = this._register(new UtilityProcessMessagePortServer());
} else {
this.server = this._register(new BrowserWindowMessagePortServer());
}
this.registerListeners();
}
@@ -153,29 +139,7 @@ class SharedProcessMain extends Disposable {
}
};
process.once('exit', onExit);
if (isUtilityProcess(process)) {
once(process.parentPort, 'vscode:electron-main->shared-process=exit', onExit);
} else {
this.ipcRenderer!.once('vscode:electron-main->shared-process=exit', onExit);
}
if (!isUtilityProcess(process)) {
// Shared process worker lifecycle
//
// We dispose the listener when the shared process is
// disposed to avoid disposing workers when the entire
// application is shutting down anyways.
const eventName = 'vscode:electron-main->shared-process=disposeWorker';
const onDisposeWorker = (event: unknown, configuration: IUtilityProcessWorkerConfiguration) => { this.onDisposeWorker(configuration); };
this.ipcRenderer!.on(eventName, onDisposeWorker);
this._register(toDisposable(() => this.ipcRenderer!.removeListener(eventName, onDisposeWorker)));
}
}
private onDisposeWorker(configuration: IUtilityProcessWorkerConfiguration): void {
this.sharedProcessWorkerService?.disposeWorker(configuration);
once(process.parentPort, 'vscode:electron-main->shared-process=exit', onExit);
}
async init(): Promise<void> {
@@ -245,10 +209,6 @@ class SharedProcessMain extends Disposable {
this.lifecycleService = this._register(new SharedProcessLifecycleService(logService));
services.set(ISharedProcessLifecycleService, this.lifecycleService);
// Worker
this.sharedProcessWorkerService = new SharedProcessWorkerService(logService);
services.set(ISharedProcessWorkerService, this.sharedProcessWorkerService);
// Files
const fileService = this._register(new FileService(logService));
services.set(IFileService, fileService);
@@ -301,7 +261,7 @@ class SharedProcessMain extends Disposable {
services.set(IV8InspectProfilingService, new SyncDescriptor(V8InspectProfilingService, undefined, false /* proxied to other processes */));
// Native Host
const nativeHostService = ProxyChannel.toService<INativeHostService>(mainProcessService.getChannel('nativeHost'), { context: this.configuration.windowId });
const nativeHostService = ProxyChannel.toService<INativeHostService>(mainProcessService.getChannel('nativeHost'));
services.set(INativeHostService, nativeHostService);
// Download
@@ -464,10 +424,6 @@ class SharedProcessMain extends Disposable {
const sharedProcessTunnelChannel = ProxyChannel.fromService(accessor.get(ISharedProcessTunnelService));
this.server.registerChannel(ipcSharedProcessTunnelChannelName, sharedProcessTunnelChannel);
// Worker
const sharedProcessWorkerChannel = ProxyChannel.fromService(accessor.get(ISharedProcessWorkerService));
this.server.registerChannel(ipcUtilityProcessWorkerChannelName, sharedProcessWorkerChannel);
// Remote Tunnel
const remoteTunnelChannel = ProxyChannel.fromService(accessor.get(IRemoteTunnelService));
this.server.registerChannel('remoteTunnel', remoteTunnelChannel);
@@ -476,19 +432,8 @@ class SharedProcessMain extends Disposable {
private registerErrorHandler(logService: ILogService): void {
// Listen on global error events
if (isUtilityProcess(process)) {
process.on('uncaughtException', error => onUnexpectedError(error));
process.on('unhandledRejection', (reason: unknown) => onUnexpectedError(reason));
} else {
(globalThis as any).addEventListener('unhandledrejection', (event: any) => {
// See https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent
onUnexpectedError(event.reason);
// Prevent the printing of this event to the console
event.preventDefault();
});
}
process.on('uncaughtException', error => onUnexpectedError(error));
process.on('unhandledRejection', (reason: unknown) => onUnexpectedError(reason));
// Install handler for unexpected errors
setUnexpectedErrorHandler(error => {
@@ -507,31 +452,15 @@ export async function main(configuration: ISharedProcessConfiguration): Promise<
// create shared process and signal back to main that we are
// ready to accept message ports as client connections
let ipcRenderer: typeof import('electron').ipcRenderer | undefined = undefined;
if (!isUtilityProcess(process)) {
ipcRenderer = (await import('electron')).ipcRenderer;
}
const sharedProcess = new SharedProcessMain(configuration, ipcRenderer);
if (isUtilityProcess(process)) {
process.parentPort.postMessage('vscode:shared-process->electron-main=ipc-ready');
} else {
ipcRenderer!.send('vscode:shared-process->electron-main=ipc-ready');
}
const sharedProcess = new SharedProcessMain(configuration);
process.parentPort.postMessage('vscode:shared-process->electron-main=ipc-ready');
// await initialization and signal this back to electron-main
await sharedProcess.init();
if (isUtilityProcess(process)) {
process.parentPort.postMessage('vscode:shared-process->electron-main=init-done');
} else {
ipcRenderer!.send('vscode:shared-process->electron-main=init-done');
}
process.parentPort.postMessage('vscode:shared-process->electron-main=init-done');
}
if (isUtilityProcess(process)) {
process.parentPort.once('message', (e: Electron.MessageEvent) => {
main(e.data as ISharedProcessConfiguration);
});
}
process.parentPort.once('message', (e: Electron.MessageEvent) => {
main(e.data as ISharedProcessConfiguration);
});