Skip to content

Commit 5daeec1

Browse files
authored
perf - update window jump list in new phase Eventually (microsoft#159536)
1 parent f454646 commit 5daeec1

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/vs/code/electron-main/app.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ import { ExtensionsProfileScannerService, IExtensionsProfileScannerService } fro
109109
import { IExtensionsScannerService } from 'vs/platform/extensionManagement/common/extensionsScannerService';
110110
import { ExtensionsScannerService } from 'vs/platform/extensionManagement/node/extensionsScannerService';
111111
import { UserDataTransientProfilesHandler } from 'vs/platform/userDataProfile/electron-main/userDataTransientProfilesHandler';
112+
import { RunOnceScheduler, runWhenIdle } from 'vs/base/common/async';
112113

113114
/**
114115
* The main VS Code application. There will only ever be one instance,
@@ -555,9 +556,16 @@ export class CodeApplication extends Disposable {
555556
if (this.environmentMainService.args.trace) {
556557
appInstantiationService.invokeFunction(accessor => this.stopTracingEventually(accessor, windows));
557558
}
559+
560+
// Set lifecycle phase to `Eventually` after a short delay and when idle (min 2.5sec, max 5sec)
561+
const eventuallyPhaseScheduler = this._register(new RunOnceScheduler(() => {
562+
this._register(runWhenIdle(() => this.lifecycleMainService.phase = LifecycleMainPhase.Eventually, 2500));
563+
}, 2500));
564+
eventuallyPhaseScheduler.schedule();
558565
}
559566

560567
private setUpHandlers(instantiationService: IInstantiationService): void {
568+
561569
// Auth Handler
562570
this._register(instantiationService.createInstance(ProxyAuthHandler));
563571

src/vs/platform/lifecycle/electron-main/lifecycleMainService.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ export const enum LifecycleMainPhase {
175175
* and is typically the best place to do work that is not required
176176
* for the window to open.
177177
*/
178-
AfterWindowOpen = 3
178+
AfterWindowOpen = 3,
179+
180+
/**
181+
* The last phase after a window has opened and some time has passed
182+
* (2-5 seconds).
183+
*/
184+
Eventually = 4
179185
}
180186

181187
export class LifecycleMainService extends Disposable implements ILifecycleMainService {

src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
6262

6363
private registerListeners(): void {
6464

65-
// Install window jump list after opening window
66-
this.lifecycleMainService.when(LifecycleMainPhase.AfterWindowOpen).then(() => this.handleWindowsJumpList());
65+
// Install window jump list delayed after opening window
66+
// because perf measurements have shown this to be slow
67+
this.lifecycleMainService.when(LifecycleMainPhase.Eventually).then(() => this.handleWindowsJumpList());
6768

6869
// Add to history when entering workspace
6970
this._register(this.workspacesManagementMainService.onDidEnterWorkspace(event => this.addRecentlyOpened([{ workspace: event.workspace, remoteAuthority: event.window.remoteAuthority }])));

0 commit comments

Comments
 (0)