mitigate hang on reload due to loading workspace storage before loading (#127421)
This commit is contained in:
parent
84323a8046
commit
b67f4ccbbb
4 changed files with 14 additions and 3 deletions
|
@ -20,6 +20,11 @@ import { cwd } from 'vs/base/common/process';
|
|||
|
||||
export const ILifecycleMainService = createDecorator<ILifecycleMainService>('lifecycleMainService');
|
||||
|
||||
export const enum LoadReason {
|
||||
LOAD = 1,
|
||||
RELOAD = 2
|
||||
}
|
||||
|
||||
export const enum UnloadReason {
|
||||
CLOSE = 1,
|
||||
QUIT = 2,
|
||||
|
@ -30,6 +35,7 @@ export const enum UnloadReason {
|
|||
export interface IWindowLoadEvent {
|
||||
window: ICodeWindow;
|
||||
workspace: IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | undefined;
|
||||
reason: LoadReason;
|
||||
}
|
||||
|
||||
export interface IWindowUnloadEvent {
|
||||
|
@ -357,7 +363,7 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe
|
|||
this.windowCounter++;
|
||||
|
||||
// Window Will Load
|
||||
windowListeners.add(window.onWillLoad(e => this._onWillLoadWindow.fire({ window, workspace: e.workspace })));
|
||||
windowListeners.add(window.onWillLoad(e => this._onWillLoadWindow.fire({ window, workspace: e.workspace, reason: e.isReload ? LoadReason.RELOAD : LoadReason.LOAD })));
|
||||
|
||||
// Window Before Closing: Main -> Renderer
|
||||
const win = assertIsDefined(window.win);
|
||||
|
|
|
@ -7,7 +7,7 @@ import { once } from 'vs/base/common/functional';
|
|||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
|
||||
import { ILifecycleMainService, LifecycleMainPhase, LoadReason } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { GlobalStorageMain, IStorageMain, IStorageMainOptions, WorkspaceStorageMain } from 'vs/platform/storage/electron-main/storageMain';
|
||||
import { IEmptyWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
|
@ -61,6 +61,10 @@ export class StorageMainService extends Disposable implements IStorageMainServic
|
|||
// Workspace Storage: Warmup when related window with workspace loads
|
||||
this._register(this.lifecycleMainService.onWillLoadWindow(async e => {
|
||||
if (e.workspace) {
|
||||
if (e.reason === LoadReason.RELOAD) {
|
||||
return; // TODO@bpasero mitigate https://github.com/microsoft/vscode/issues/127421
|
||||
}
|
||||
|
||||
this.workspaceStorage(e.workspace).init();
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -775,7 +775,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
|||
}
|
||||
|
||||
// Event
|
||||
this._onWillLoad.fire({ workspace: configuration.workspace });
|
||||
this._onWillLoad.fire({ workspace: configuration.workspace, isReload: options.isReload ?? false });
|
||||
}
|
||||
|
||||
private updateConfiguration(configuration: INativeWindowConfiguration, options: ILoadOptions): void {
|
||||
|
|
|
@ -62,6 +62,7 @@ export const enum WindowMode {
|
|||
|
||||
export interface ILoadEvent {
|
||||
workspace: IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | undefined;
|
||||
isReload: boolean;
|
||||
}
|
||||
|
||||
export interface ICodeWindow extends IDisposable {
|
||||
|
|
Loading…
Reference in a new issue