Skip to content

Commit 224ac6f

Browse files
committed
Require canvas/webgl use to enable image support
Part of microsoft#187198
1 parent def43e0 commit 224ac6f

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
@@ -40,6 +40,7 @@ import { SuggestAddon } from 'vs/workbench/contrib/terminal/browser/xterm/sugges
4040
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
4141
import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/terminalContextKey';
4242
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
43+
import { debounce } from 'vs/base/common/decorators';
4344

4445
const enum RenderConstants {
4546
/**
@@ -262,7 +263,6 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
262263

263264
// Load addons
264265
this._updateUnicodeVersion();
265-
this._refreshImageAddon();
266266
this._markNavigationAddon = this._instantiationService.createInstance(MarkNavigationAddon, _capabilities);
267267
this.raw.loadAddon(this._markNavigationAddon);
268268
this._decorationAddon = this._instantiationService.createInstance(DecorationAddon, this._capabilities);
@@ -405,7 +405,6 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
405405
}
406406
}
407407
}
408-
this._refreshImageAddon();
409408
}
410409

411410
private _shouldLoadWebgl(): boolean {
@@ -640,6 +639,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
640639
this._logService.info(`Webgl lost context, disposing of webgl renderer`);
641640
this._disposeOfWebglRenderer();
642641
});
642+
this._refreshImageAddon();
643643
// Uncomment to add the texture atlas to the DOM
644644
// setTimeout(() => {
645645
// if (this._webglAddon?.textureAtlas) {
@@ -679,6 +679,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
679679
XtermTerminal._suggestedRendererType = 'dom';
680680
this._disposeOfCanvasRenderer();
681681
}
682+
this._refreshImageAddon();
682683
}
683684

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

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

752756
private _disposeOfWebglRenderer(): void {
@@ -756,6 +760,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
756760
// ignore
757761
}
758762
this._webglAddon = undefined;
763+
this._refreshImageAddon();
759764
}
760765

761766
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)