Re-resolve webview views when extension host restarts

Fixes #108555

Previously webviews were left hanging when the extension host died. With this change, we now try to re-create them once the extension host restarts
This commit is contained in:
Matt Bierner
2020-10-19 19:00:08 -07:00
parent 5eb46b187c
commit a4a4cf5ace
4 changed files with 63 additions and 29 deletions

View File

@@ -5,7 +5,7 @@
import { CancellationToken } from 'vs/base/common/cancellation';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle';
import { MainThreadWebviews, reviveWebviewExtension } from 'vs/workbench/api/browser/mainThreadWebviews';
import * as extHostProtocol from 'vs/workbench/api/common/extHost.protocol';
import { IWebviewViewService, WebviewView } from 'vs/workbench/contrib/webviewView/browser/webviewViewService';
@@ -28,6 +28,15 @@ export class MainThreadWebviewsViews extends Disposable implements extHostProtoc
this._proxy = context.getProxy(extHostProtocol.ExtHostContext.ExtHostWebviewViews);
}
dispose() {
super.dispose();
dispose(this._webviewViewProviders.values());
this._webviewViewProviders.clear();
dispose(this._webviewViews.values());
}
public $setWebviewViewTitle(handle: extHostProtocol.WebviewHandle, value: string | undefined): void {
const webviewView = this.getWebviewView(handle);
webviewView.title = value;
@@ -54,7 +63,7 @@ export class MainThreadWebviewsViews extends Disposable implements extHostProtoc
const extension = reviveWebviewExtension(extensionData);
this._webviewViewService.register(viewType, {
const registration = this._webviewViewService.register(viewType, {
resolve: async (webviewView: WebviewView, cancellation: CancellationToken) => {
const handle = webviewView.webview.id;
@@ -93,6 +102,8 @@ export class MainThreadWebviewsViews extends Disposable implements extHostProtoc
}
}
});
this._webviewViewProviders.set(viewType, registration);
}
public $unregisterWebviewViewProvider(viewType: string): void {