Skip to content

Commit 6f241be

Browse files
committed
Require canvas/webgl use to enable image support
Part of microsoft#187198
1 parent 65e67d1 commit 6f241be

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { SuggestAddon } from 'vs/workbench/contrib/terminal/browser/xterm/sugges
3939
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
4040
import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/terminalContextKey';
4141
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
42+
import { debounce } from 'vs/base/common/decorators';
4243

4344
const enum RenderConstants {
4445
/**
@@ -261,7 +262,6 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
261262

262263
// Load addons
263264
this._updateUnicodeVersion();
264-
this._refreshImageAddon();
265265
this._markNavigationAddon = this._instantiationService.createInstance(MarkNavigationAddon, _capabilities);
266266
this.raw.loadAddon(this._markNavigationAddon);
267267
this._decorationAddon = this._instantiationService.createInstance(DecorationAddon, this._capabilities);
@@ -404,7 +404,6 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
404404
}
405405
}
406406
}
407-
this._refreshImageAddon();
408407
}
409408

410409
private _shouldLoadWebgl(): boolean {
@@ -639,6 +638,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
639638
this._logService.info(`Webgl lost context, disposing of webgl renderer`);
640639
this._disposeOfWebglRenderer();
641640
});
641+
this._refreshImageAddon();
642642
// Uncomment to add the texture atlas to the DOM
643643
// setTimeout(() => {
644644
// if (this._webglAddon?.textureAtlas) {
@@ -678,6 +678,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
678678
XtermTerminal._suggestedRendererType = 'dom';
679679
this._disposeOfCanvasRenderer();
680680
}
681+
this._refreshImageAddon();
681682
}
682683

683684
protected async _getCanvasAddonConstructor(): Promise<typeof CanvasAddonType> {
@@ -687,8 +688,10 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
687688
return CanvasAddon;
688689
}
689690

691+
@debounce(100)
690692
private async _refreshImageAddon(): Promise<void> {
691-
if (this._configHelper.config.enableImages) {
693+
// Only allow the image addon when a canvas is being used to avoid possible GPU issues
694+
if (this._configHelper.config.enableImages && (this._canvasAddon || this._webglAddon)) {
692695
if (!this._imageAddon) {
693696
const AddonCtor = await this._getImageAddonConstructor();
694697
this._imageAddon = new AddonCtor();
@@ -746,6 +749,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
746749
// ignore
747750
}
748751
this._canvasAddon = undefined;
752+
this._refreshImageAddon();
749753
}
750754

751755
private _disposeOfWebglRenderer(): void {
@@ -755,6 +759,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
755759
// ignore
756760
}
757761
this._webglAddon = undefined;
762+
this._refreshImageAddon();
758763
}
759764

760765
private async _measureRenderTime(): Promise<void> {

src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ const terminalConfiguration: IConfigurationNode = {
587587
},
588588
[TerminalSettingId.EnableImages]: {
589589
restricted: true,
590-
markdownDescription: localize('terminal.integrated.enableImages', "Enables image support in the terminal. Both sixel and iTerm's inline image protocol are supported on Linux and macOS, Windows support will light up automatically when ConPTY passes through the sequences. Images will currently not be restored between window reloads/reconnects."),
590+
markdownDescription: localize('terminal.integrated.enableImages', "Enables image support in the terminal, this will only work when {0} is enabled. Both sixel and iTerm's inline image protocol are supported on Linux and macOS, Windows support will light up automatically when ConPTY passes through the sequences. Images will currently not be restored between window reloads/reconnects.", `\`#${TerminalSettingId.GpuAcceleration}#\``),
591591
type: 'boolean',
592592
default: true
593593
},

0 commit comments

Comments
 (0)