Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make webgl default renderer #118011

Merged
merged 10 commits into from Mar 4, 2021
41 changes: 28 additions & 13 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Expand Up @@ -25,7 +25,7 @@ import { activeContrastBorder, scrollbarSliderActiveBackground, scrollbarSliderB
import { ICssStyleCollector, IColorTheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { PANEL_BACKGROUND, SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/widgets/widgetManager';
import { ITerminalProcessManager, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, NEVER_MEASURE_RENDER_TIME_STORAGE_KEY, ProcessState, TERMINAL_VIEW_ID, IWindowsShellHelper, KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, INavigationMode, TitleEventSource, DEFAULT_COMMANDS_TO_SKIP_SHELL, TERMINAL_CREATION_COMMANDS, KEYBINDING_CONTEXT_TERMINAL_ALT_BUFFER_ACTIVE } from 'vs/workbench/contrib/terminal/common/terminal';
import { ITerminalProcessManager, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, NEVER_MEASURE_RENDER_TIME_STORAGE_KEY, ProcessState, TERMINAL_VIEW_ID, IWindowsShellHelper, KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, INavigationMode, TitleEventSource, DEFAULT_COMMANDS_TO_SKIP_SHELL, TERMINAL_CREATION_COMMANDS, KEYBINDING_CONTEXT_TERMINAL_ALT_BUFFER_ACTIVE, SUGGESTED_RENDERER_TYPE } from 'vs/workbench/contrib/terminal/common/terminal';
import { ansiColorIdentifiers, TERMINAL_BACKGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_SELECTION_BACKGROUND_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper';
import { TerminalLinkManager } from 'vs/workbench/contrib/terminal/browser/links/terminalLinkManager';
Expand Down Expand Up @@ -252,6 +252,9 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
if (e.affectsConfiguration('editor.accessibilitySupport')) {
this.updateAccessibilitySupport();
}
if (e.affectsConfiguration('terminal.integrated.rendererType')) {
this._storageService.remove(SUGGESTED_RENDERER_TYPE, StorageScope.GLOBAL);
}
}));

// Clear out initial data events after 10 seconds, hopefully extension hosts are up and
Expand Down Expand Up @@ -418,7 +421,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
fastScrollModifier: 'alt',
fastScrollSensitivity: editorOptions.fastScrollSensitivity,
scrollSensitivity: editorOptions.mouseWheelScrollSensitivity,
rendererType: config.rendererType === 'auto' || config.rendererType === 'experimentalWebgl' ? 'canvas' : config.rendererType,
rendererType: (config.rendererType === 'auto' || config.rendererType === 'experimentalWebgl') ? 'canvas' : config.rendererType,
wordSeparator: config.wordSeparators
});
this._xterm = xterm;
Expand Down Expand Up @@ -660,11 +663,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
if (xterm.getOption('disableStdin')) {
this._attachPressAnyKeyToCloseListener(xterm);
}

const neverMeasureRenderTime = this._storageService.getBoolean(NEVER_MEASURE_RENDER_TIME_STORAGE_KEY, StorageScope.GLOBAL, false);
if (!neverMeasureRenderTime && this._configHelper.config.rendererType === 'auto') {
this._measureRenderTime();
}
}

private async _measureRenderTime(): Promise<void> {
Expand Down Expand Up @@ -1307,13 +1305,12 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._safeSetOption('macOptionClickForcesSelection', config.macOptionClickForcesSelection);
this._safeSetOption('rightClickSelectsWord', config.rightClickBehavior === 'selectWord');
this._safeSetOption('wordSeparator', config.wordSeparators);
if (config.rendererType === 'experimentalWebgl') {
const suggestedRendererType = this._storageService.get(SUGGESTED_RENDERER_TYPE, StorageScope.GLOBAL);
if ((suggestedRendererType === 'auto' && config.rendererType === 'auto') || config.rendererType === 'experimentalWebgl') {
this._enableWebglRenderer();
} else {
this._webglAddon?.dispose();
this._webglAddon = undefined;
// Never set webgl as it's an addon not a rendererType
this._safeSetOption('rendererType', config.rendererType === 'auto' ? 'canvas' : config.rendererType);
this._disposeOfWebglRenderer();
this._safeSetOption('rendererType', config.rendererType);
}
this._refreshEnvironmentVariableInfoWidgetState(this._processManager.environmentVariableInfo);
}
Expand All @@ -1324,7 +1321,25 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
const Addon = await this._terminalInstanceService.getXtermWebglConstructor();
this._webglAddon = new Addon();
this._xterm.loadAddon(this._webglAddon);
try {
this._xterm.loadAddon(this._webglAddon);
this._storageService.store(SUGGESTED_RENDERER_TYPE, 'auto', StorageScope.GLOBAL, StorageTarget.MACHINE);
} catch (e) {
this._logService.warn(`Webgl could not be loaded. Falling back to the canvas renderer type.`, e);
const neverMeasureRenderTime = this._storageService.getBoolean(NEVER_MEASURE_RENDER_TIME_STORAGE_KEY, StorageScope.GLOBAL, false);
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
// if it's already set to dom, no need to measure render time
if (!neverMeasureRenderTime && this._configHelper.config.rendererType !== 'dom') {
this._measureRenderTime();
}
this._safeSetOption('rendererType', 'canvas');
this._storageService.store(SUGGESTED_RENDERER_TYPE, 'canvas', StorageScope.GLOBAL, StorageTarget.MACHINE);
this._disposeOfWebglRenderer();
}
}

private _disposeOfWebglRenderer(): void {
this._webglAddon?.dispose();
this._webglAddon = undefined;
}

private async _updateUnicodeVersion(): Promise<void> {
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/contrib/terminal/common/terminal.ts
Expand Up @@ -55,6 +55,8 @@ export const NEVER_MEASURE_RENDER_TIME_STORAGE_KEY = 'terminal.integrated.neverM

export const TERMINAL_CREATION_COMMANDS = ['workbench.action.terminal.toggleTerminal', 'workbench.action.terminal.new', 'workbench.action.togglePanel', 'workbench.action.terminal.focus'];

export const SUGGESTED_RENDERER_TYPE = 'terminal.integrated.suggestedRendererType';

export const TerminalCursorStyle = {
BLOCK: 'block',
LINE: 'line',
Expand Down