Skip to content

Commit

Permalink
Remove canvas renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Apr 26, 2024
1 parent 5c213a1 commit 6cdd364
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 79 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
"@vscode/windows-mutex": "^0.5.0",
"@vscode/windows-process-tree": "^0.6.0",
"@vscode/windows-registry": "^1.1.0",
"@xterm/addon-canvas": "0.8.0-beta.17",
"@xterm/addon-image": "0.9.0-beta.17",
"@xterm/addon-search": "0.16.0-beta.17",
"@xterm/addon-serialize": "0.14.0-beta.17",
Expand Down
1 change: 0 additions & 1 deletion remote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"@vscode/vscode-languagedetection": "1.0.21",
"@vscode/windows-process-tree": "^0.6.0",
"@vscode/windows-registry": "^1.1.0",
"@xterm/addon-canvas": "0.8.0-beta.17",
"@xterm/addon-image": "0.9.0-beta.17",
"@xterm/addon-search": "0.16.0-beta.17",
"@xterm/addon-serialize": "0.14.0-beta.17",
Expand Down
1 change: 0 additions & 1 deletion remote/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"@microsoft/1ds-post-js": "^3.2.13",
"@vscode/iconv-lite-umd": "0.7.0",
"@vscode/vscode-languagedetection": "1.0.21",
"@xterm/addon-canvas": "0.8.0-beta.17",
"@xterm/addon-image": "0.9.0-beta.17",
"@xterm/addon-search": "0.16.0-beta.17",
"@xterm/addon-serialize": "0.14.0-beta.17",
Expand Down
5 changes: 0 additions & 5 deletions remote/web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@
resolved "https://registry.yarnpkg.com/@vscode/vscode-languagedetection/-/vscode-languagedetection-1.0.21.tgz#89b48f293f6aa3341bb888c1118d16ff13b032d3"
integrity sha512-zSUH9HYCw5qsCtd7b31yqkpaCU6jhtkKLkvOOA8yTrIRfBSOFb8PPhgmMicD7B/m+t4PwOJXzU1XDtrM9Fd3/g==

"@xterm/addon-canvas@0.8.0-beta.17":
version "0.8.0-beta.17"
resolved "https://registry.yarnpkg.com/@xterm/addon-canvas/-/addon-canvas-0.8.0-beta.17.tgz#309630c738aa2e44742cdce5ee88fb8079fa652c"
integrity sha512-1km1RE02rxdbJWp1sev6Um6T/4tWlpEhJ88OP7xwfUFuedhFEby0JXmKzP7qB0cFzEvFTCq1bOAHSA3DX8vlFQ==

"@xterm/addon-image@0.9.0-beta.17":
version "0.9.0-beta.17"
resolved "https://registry.yarnpkg.com/@xterm/addon-image/-/addon-image-0.9.0-beta.17.tgz#343d0665a6060d4f893b4f2d32de6ccbbd00bb63"
Expand Down
5 changes: 0 additions & 5 deletions remote/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@
resolved "https://registry.yarnpkg.com/@vscode/windows-registry/-/windows-registry-1.1.0.tgz#03dace7c29c46f658588b9885b9580e453ad21f9"
integrity sha512-5AZzuWJpGscyiMOed0IuyEwt6iKmV5Us7zuwCDCFYMIq7tsvooO9BUiciywsvuthGz6UG4LSpeDeCxvgMVhnIw==

"@xterm/addon-canvas@0.8.0-beta.17":
version "0.8.0-beta.17"
resolved "https://registry.yarnpkg.com/@xterm/addon-canvas/-/addon-canvas-0.8.0-beta.17.tgz#309630c738aa2e44742cdce5ee88fb8079fa652c"
integrity sha512-1km1RE02rxdbJWp1sev6Um6T/4tWlpEhJ88OP7xwfUFuedhFEby0JXmKzP7qB0cFzEvFTCq1bOAHSA3DX8vlFQ==

"@xterm/addon-image@0.9.0-beta.17":
version "0.9.0-beta.17"
resolved "https://registry.yarnpkg.com/@xterm/addon-image/-/addon-image-0.9.0-beta.17.tgz#343d0665a6060d4f893b4f2d32de6ccbbd00bb63"
Expand Down
1 change: 0 additions & 1 deletion scripts/xterm-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const path = require('path');

const moduleNames = [
'@xterm/xterm',
'@xterm/addon-canvas',
'@xterm/addon-image',
'@xterm/addon-search',
'@xterm/addon-serialize',
Expand Down
61 changes: 4 additions & 57 deletions src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/

import type { IBuffer, ITerminalOptions, ITheme, Terminal as RawXtermTerminal, LogLevel as XtermLogLevel } from '@xterm/xterm';
import type { CanvasAddon as CanvasAddonType } from '@xterm/addon-canvas';
import type { ISearchOptions, SearchAddon as SearchAddonType } from '@xterm/addon-search';
import type { Unicode11Addon as Unicode11AddonType } from '@xterm/addon-unicode11';
import type { WebglAddon as WebglAddonType } from '@xterm/addon-webgl';
Expand Down Expand Up @@ -45,7 +44,6 @@ const enum RenderConstants {
SmoothScrollDuration = 125
}

let CanvasAddon: typeof CanvasAddonType;
let ImageAddon: typeof ImageAddonType;
let SearchAddon: typeof SearchAddonType;
let SerializeAddon: typeof SerializeAddonType;
Expand Down Expand Up @@ -121,7 +119,6 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
private _decorationAddon: DecorationAddon;

// Optional addons
private _canvasAddon?: CanvasAddonType;
private _searchAddon?: SearchAddonType;
private _unicode11Addon?: Unicode11AddonType;
private _webglAddon?: WebglAddonType;
Expand All @@ -136,7 +133,7 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
get findResult(): { resultIndex: number; resultCount: number } | undefined { return this._lastFindResult; }

get isStdinDisabled(): boolean { return !!this.raw.options.disableStdin; }
get isGpuAccelerated(): boolean { return !!(this._canvasAddon || this._webglAddon); }
get isGpuAccelerated(): boolean { return !!this._webglAddon; }

private readonly _onDidRequestRunCommand = this._register(new Emitter<{ command: ITerminalCommand; copyAsHtml?: boolean; noNewLine?: boolean }>());
readonly onDidRequestRunCommand = this._onDidRequestRunCommand.event;
Expand All @@ -159,7 +156,7 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
get shellIntegration(): IShellIntegration { return this._shellIntegrationAddon; }

get textureAtlas(): Promise<ImageBitmap> | undefined {
const canvas = this._webglAddon?.textureAtlas || this._canvasAddon?.textureAtlas;
const canvas = this._webglAddon?.textureAtlas;
if (!canvas) {
return undefined;
}
Expand Down Expand Up @@ -332,8 +329,6 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
if (options.enableGpu) {
if (this._shouldLoadWebgl()) {
this._enableWebglRenderer();
} else if (this._shouldLoadCanvas()) {
this._enableCanvasRenderer();
}
}

Expand Down Expand Up @@ -406,11 +401,6 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
this._enableWebglRenderer();
} else {
this._disposeOfWebglRenderer();
if (this._shouldLoadCanvas()) {
this._enableCanvasRenderer();
} else {
this._disposeOfCanvasRenderer();
}
}
}
}
Expand All @@ -423,10 +413,6 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
return (this._terminalConfigurationService.config.gpuAcceleration === 'auto' && XtermTerminal._suggestedRendererType === undefined) || this._terminalConfigurationService.config.gpuAcceleration === 'on';
}

private _shouldLoadCanvas(): boolean {
return this._terminalConfigurationService.config.gpuAcceleration === 'canvas';
}

forceRedraw() {
this.raw.clearTextureAtlas();
}
Expand Down Expand Up @@ -680,7 +666,6 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach

const Addon = await this._getWebglAddonConstructor();
this._webglAddon = new Addon();
this._disposeOfCanvasRenderer();
try {
this.raw.loadAddon(this._webglAddon);
this._logService.trace('Webgl was loaded');
Expand All @@ -706,38 +691,10 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
this._disposeOfWebglRenderer();
}

/**
* @deprecated This will be removed in the future, see https://github.com/microsoft/vscode/issues/209276
*/
private async _enableCanvasRenderer(): Promise<void> {
if (!this.raw.element || this._canvasAddon) {
return;
}
const Addon = await this._getCanvasAddonConstructor();
this._canvasAddon = new Addon();
this._disposeOfWebglRenderer();
try {
this.raw.loadAddon(this._canvasAddon);
this._logService.trace('Canvas renderer was loaded');
} catch (e) {
this._logService.warn(`Canvas renderer could not be loaded, falling back to dom renderer`, e);
XtermTerminal._suggestedRendererType = 'dom';
this._disposeOfCanvasRenderer();
}
this._refreshImageAddon();
}

protected async _getCanvasAddonConstructor(): Promise<typeof CanvasAddonType> {
if (!CanvasAddon) {
CanvasAddon = (await importAMDNodeModule<typeof import('@xterm/addon-canvas')>('@xterm/addon-canvas', 'lib/xterm-addon-canvas.js')).CanvasAddon;
}
return CanvasAddon;
}

@debounce(100)
private async _refreshImageAddon(): Promise<void> {
// Only allow the image addon when a canvas is being used to avoid possible GPU issues
if (this._terminalConfigurationService.config.enableImages && (this._canvasAddon || this._webglAddon)) {
// Only allow the image addon when webgl is being used to avoid possible GPU issues
if (this._terminalConfigurationService.config.enableImages && this._webglAddon) {
if (!this._imageAddon) {
const AddonCtor = await this._getImageAddonConstructor();
this._imageAddon = new AddonCtor();
Expand Down Expand Up @@ -788,16 +745,6 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
return SerializeAddon;
}

private _disposeOfCanvasRenderer(): void {
try {
this._canvasAddon?.dispose();
} catch {
// ignore
}
this._canvasAddon = undefined;
this._refreshImageAddon();
}

private _disposeOfWebglRenderer(): void {
try {
this._webglAddon?.dispose();
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export interface ITerminalConfiguration {
altClickMovesCursor: boolean;
macOptionIsMeta: boolean;
macOptionClickForcesSelection: boolean;
gpuAcceleration: 'auto' | 'on' | 'canvas' | 'off';
gpuAcceleration: 'auto' | 'on' | 'off';
rightClickBehavior: 'default' | 'copyPaste' | 'paste' | 'selectWord' | 'nothing';
middleClickBehavior: 'default' | 'paste';
cursorBlinking: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,11 @@ const terminalConfiguration: IConfigurationNode = {
},
[TerminalSettingId.GpuAcceleration]: {
type: 'string',
enum: ['auto', 'on', 'off', 'canvas'],
enum: ['auto', 'on', 'off'],
markdownEnumDescriptions: [
localize('terminal.integrated.gpuAcceleration.auto', "Let VS Code detect which renderer will give the best experience."),
localize('terminal.integrated.gpuAcceleration.on', "Enable GPU acceleration within the terminal."),
localize('terminal.integrated.gpuAcceleration.off', "Disable GPU acceleration within the terminal. The terminal will render much slower when GPU acceleration is off but it should reliably work on all systems."),
localize('terminal.integrated.gpuAcceleration.canvas', "Use the terminal's fallback canvas renderer which uses a 2d context instead of webgl which may perform better on some systems. Note that some features are limited in the canvas renderer like opaque selection.")
],
default: 'auto',
description: localize('terminal.integrated.gpuAcceleration', "Controls whether the terminal will leverage the GPU to do its rendering.")
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1913,11 +1913,6 @@
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-2.0.5.tgz#325db42395cd49fe6c14057f9a900e427df8810e"
integrity sha512-lqaoKnRYBdo1UgDX8uF24AfGMifWK19TxPmM5FHc2vAGxrJ/qtyUyFBWoY1tISZdelsQ5fBcOusifo5o5wSJxQ==

"@xterm/addon-canvas@0.8.0-beta.17":
version "0.8.0-beta.17"
resolved "https://registry.yarnpkg.com/@xterm/addon-canvas/-/addon-canvas-0.8.0-beta.17.tgz#309630c738aa2e44742cdce5ee88fb8079fa652c"
integrity sha512-1km1RE02rxdbJWp1sev6Um6T/4tWlpEhJ88OP7xwfUFuedhFEby0JXmKzP7qB0cFzEvFTCq1bOAHSA3DX8vlFQ==

"@xterm/addon-image@0.9.0-beta.17":
version "0.9.0-beta.17"
resolved "https://registry.yarnpkg.com/@xterm/addon-image/-/addon-image-0.9.0-beta.17.tgz#343d0665a6060d4f893b4f2d32de6ccbbd00bb63"
Expand Down

0 comments on commit 6cdd364

Please sign in to comment.