Skip to content

Commit

Permalink
Experimental setting for deferring onStartupFinished extension acti…
Browse files Browse the repository at this point in the history
…vation
  • Loading branch information
joyceerhl committed Jan 19, 2023
1 parent ef9fb8a commit 1456180
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/vs/workbench/api/common/extHostExtensionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
import * as path from 'vs/base/common/path';
import * as performance from 'vs/base/common/performance';
import { originalFSPath, joinPath, extUriBiasedIgnorePathCase } from 'vs/base/common/resources';
import { asPromise, Barrier, IntervalTimer, timeout } from 'vs/base/common/async';
import { asPromise, Barrier, IntervalTimer, runWhenIdle, timeout } from 'vs/base/common/async';
import { dispose, toDisposable, Disposable } from 'vs/base/common/lifecycle';
import { TernarySearchTree } from 'vs/base/common/ternarySearchTree';
import { URI, UriComponents } from 'vs/base/common/uri';
Expand Down Expand Up @@ -598,15 +598,22 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
// startup is considered finished
this._mainThreadExtensionsProxy.$setPerformanceMarks(performance.getMarks());

for (const desc of this._myRegistry.getAllExtensionDescriptions()) {
if (desc.activationEvents) {
for (const activationEvent of desc.activationEvents) {
if (activationEvent === 'onStartupFinished') {
this._activateOneStartupFinished(desc, activationEvent);
this._extHostConfiguration.getConfigProvider().then((configProvider) => {
const shouldDeferActivation = configProvider.getConfiguration('extensions.experimental').get<boolean>('deferredStartupFinishedActivation');
for (const desc of this._myRegistry.getAllExtensionDescriptions()) {
if (desc.activationEvents) {
for (const activationEvent of desc.activationEvents) {
if (activationEvent === 'onStartupFinished') {
if (shouldDeferActivation) {
this._register(runWhenIdle(() => this._activateOneStartupFinished(desc, activationEvent)));
} else {
this._activateOneStartupFinished(desc, activationEvent);
}
}
}
}
}
}
});
}

// Handle "eager" activation extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
}
}
}
},
'extensions.experimental.deferredStartupFinishedActivation': {
type: 'boolean',
description: localize('extensionsDeferredStartupFinishedActivation', "When enabled, extensions which declare the `onStartupFinished` activation event will be activated using idle callbacks."),
default: false
}
}
});
Expand Down

0 comments on commit 1456180

Please sign in to comment.