提交 ec91297c 编写于 作者: B Benjamin Pasero

better fix for #41322

上级 26266020
......@@ -182,22 +182,12 @@ export class WorkbenchShell {
try {
const workbench = instantiationService.createInstance(Workbench, parent, workbenchContainer, this.configuration, serviceCollection, this.lifecycleService);
// Delay the "Restoring" phase for a bit to give our viewlet/editor/panels a faster startup
let restorePhaseTimeoutHandle = setTimeout(() => {
restorePhaseTimeoutHandle = void 0;
this.lifecycleService.phase = LifecyclePhase.Restoring;
}, 800);
// Set lifecycle phase to `Restoring`
this.lifecycleService.phase = LifecyclePhase.Restoring;
// Startup Workbench
workbench.startup().done(startupInfos => {
// Set lifecycle phase to restoring if we started up fast enough and to
// make sure to trigger contributions on this phase if any
if (restorePhaseTimeoutHandle) {
clearTimeout(restorePhaseTimeoutHandle);
this.lifecycleService.phase = LifecyclePhase.Restoring;
}
// Set lifecycle phase to `Runnning` so that other contributions can now do something
this.lifecycleService.phase = LifecyclePhase.Running;
......
......@@ -35,7 +35,7 @@ class LogOutputChannels extends Disposable implements IWorkbenchContribution {
}
}
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(LogOutputChannels, LifecyclePhase.Restoring);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(LogOutputChannels, LifecyclePhase.Running);
const workbenchActionsRegistry = Registry.as<IWorkbenchActionRegistry>(WorkbenchActionExtensions.WorkbenchActions);
const devCategory = nls.localize('developer', "Developer");
......
......@@ -119,16 +119,36 @@ export class ExtensionService extends Disposable implements IExtensionService {
this._extensionHostProcessCustomers = [];
this._extensionHostProcessProxy = null;
this.startDelayed(lifecycleService);
}
private startDelayed(lifecycleService: ILifecycleService): void {
let started = false;
const startOnce = () => {
if (!started) {
started = true;
this._startExtensionHostProcess([]);
this._scanAndHandleExtensions();
}
};
// delay extension host creation and extension scanning
// until the workbench is restoring. we cannot defer the
// extension host more (LifecyclePhase.Running) because
// some editors require the extension host to restore
// and this would result in a deadlock
// see https://github.com/Microsoft/vscode/issues/41322
lifecycleService.when(LifecyclePhase.Restoring).then(() => {
// delay extension host creation and extension scanning
// until the workbench is restoring. we cannot defer the
// extension host more (LifecyclePhase.Running) because
// some editors require the extension host to restore
// and this would result in a deadlock
// see https://github.com/Microsoft/vscode/issues/41322
this._startExtensionHostProcess([]);
this._scanAndHandleExtensions();
// we add an additional delay of 800ms because the extension host
// starting is a potential expensive operation and we do no want
// to fight with editors, viewlets and panels restoring.
setTimeout(() => startOnce(), 800);
});
// if we are running before the 800ms delay, make sure to start
// the extension host right away though.
lifecycleService.when(LifecyclePhase.Running).then(() => startOnce());
}
public dispose(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册