Skip to content

Too many onDidChangeSelectedNotebooks subscribers leads to new kernels not being able to accept notebook association #204416

@andyscho

Description

@andyscho

This is the underlying cause for the issue in microsoft/vscode-jupyter#15075. This issue details the problem fixed by #204417.

Currently, users can supply arbitrary numbers of kernels. Each kernel that's added gets a listener for onDidChangeSelectedNotebooks in order to properly associate the kernel with the notebook so it can be executed if it is switched to.

const listener = this._notebookKernelService.onDidChangeSelectedNotebooks(e => {
if (e.oldKernel === kernel.id) {
this._proxy.$acceptNotebookAssociation(handle, e.notebook, false);
} else if (e.newKernel === kernel.id) {
this._proxy.$acceptNotebookAssociation(handle, e.notebook, true);
}
});

The Emitter that is used for onDidChangeSelectedNotebooks is constructed with default settings.

private readonly _onDidChangeNotebookKernelBinding = this._register(new Emitter<ISelectedNotebooksChangeEvent>());

If users have too many kernels, the threshold can be hit.

if (this._leakageMon && this._size > this._leakageMon.threshold * 3) {
console.warn(`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far`);
return Disposable.None;
}

When this happens, the kernel will show as selected in the UI, but will fail to execute because the kernel won't be able to properly associate with the notebook. See the vscode-jupyter issue referenced above for a demonstration of this.

  • VS Code Version: Multiple VS Code versions, including current insiders
  • OS Version: Present on Mac and Linux at least

Steps to Reproduce:
See microsoft/vscode-jupyter#15075 for reproducing details.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugfreeze-slow-crash-leakVS Code crashing, performance, freeze and memory leak issuesinsiders-releasedPatch has been released in VS Code InsidersverifiedVerification succeeded

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions