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

fix #5181 #5182

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions addons/addon-image/test/ImageAddon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import test from '@playwright/test';
import { readFileSync } from 'fs';
import { FINALIZER, introducer, sixelEncode } from 'sixel';
import { ITestContext, createTestContext, openTerminal, pollFor } from '../../../test/playwright/TestUtils';
import { ITestContext, createTestContext, openTerminal, pollFor, timeout } from '../../../test/playwright/TestUtils';
import { deepStrictEqual, ok, strictEqual } from 'assert';

/**
Expand Down Expand Up @@ -199,7 +199,7 @@ test.describe('ImageAddon', () => {
(await getScrollbackPlusRows() - 1)
);
// wait here, as we have to make sure, that eviction did not yet occur
await new Promise(r => setTimeout(r, 100));
await timeout(100);
pollFor(ctx.page, 'window.imageAddon._storage._images.size', 1);
// scroll one further should delete the image
await ctx.page.evaluate(() => new Promise(res => (window as any).term.write('\n', res)));
Expand All @@ -222,13 +222,13 @@ test.describe('ImageAddon', () => {
await ctx.proxy.write(SIXEL_SEQ_0);
await ctx.proxy.write(SIXEL_SEQ_0);
await ctx.proxy.write(SIXEL_SEQ_0);
await new Promise(r => setTimeout(r, 50));
await timeout(100);
const usage = await ctx.page.evaluate('window.imageAddon.storageUsage');
await ctx.proxy.write(SIXEL_SEQ_0);
await ctx.proxy.write(SIXEL_SEQ_0);
await ctx.proxy.write(SIXEL_SEQ_0);
await ctx.proxy.write(SIXEL_SEQ_0);
await new Promise(r => setTimeout(r, 50));
await timeout(100);
strictEqual(await ctx.page.evaluate('window.imageAddon.storageUsage'), usage);
strictEqual(usage as number < 1, true);
});
Expand All @@ -247,25 +247,26 @@ test.describe('ImageAddon', () => {
strictEqual(await ctx.page.evaluate('window.imageAddon.storageUsage'), 0);
});
test('evict tiles by in-place overwrites (only full overwrite tested)', async () => {
await new Promise(r => setTimeout(r, 50));
await timeout(50);
await ctx.proxy.write('\x1b[H' + SIXEL_SEQ_0 + '\x1b[100;100H');
await timeout(50);
let usage = await ctx.page.evaluate('window.imageAddon.storageUsage');
while (usage === 0) {
await new Promise(r => setTimeout(r, 50));
await timeout(50);
usage = await ctx.page.evaluate('window.imageAddon.storageUsage');
}
await ctx.proxy.write('\x1b[H' + SIXEL_SEQ_0 + '\x1b[100;100H');
await new Promise(r => setTimeout(r, 200)); // wait some time and re-check
await timeout(200); // wait some time and re-check
strictEqual(await ctx.page.evaluate('window.imageAddon.storageUsage'), usage);
});
test('manual eviction on alternate buffer must not miss images', async () => {
await ctx.proxy.write('\x1b[?1049h');
await ctx.proxy.write(SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0);
await new Promise(r => setTimeout(r, 50));
await timeout(100);
const usage: number = await ctx.page.evaluate('window.imageAddon.storageUsage');
await ctx.proxy.write(SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0);
await ctx.proxy.write(SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0);
await new Promise(r => setTimeout(r, 50));
await timeout(100);
const newUsage: number = await ctx.page.evaluate('window.imageAddon.storageUsage');
strictEqual(newUsage, usage);
});
Expand Down
4 changes: 2 additions & 2 deletions addons/addon-web-links/test/WebLinksAddon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ test.describe('WebLinksAddon', () => {
test.beforeEach(async () => {
await ctx.page.evaluate(`
window.term.reset();
window._linkaddon?.dispose();
`);
await timeout(50);
await timeout(10);
await ctx.page.evaluate(`
window._linkaddon?.dispose();
window._linkaddon = new WebLinksAddon();
window.term.loadAddon(window._linkaddon);
`);
Expand Down
3 changes: 3 additions & 0 deletions addons/addon-webgl/src/WebglAddon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export class WebglAddon extends Disposable implements ITerminalAddon , IWebglApi
renderService.setRenderer(this._renderer);

this._register(toDisposable(() => {
if ((this._terminal as any)._core._store._isDisposed) {
return;
}
const renderService: IRenderService = (this._terminal as any)._core._renderService;
renderService.setRenderer((this._terminal as any)._core._createRenderer());
renderService.handleResize(terminal.cols, terminal.rows);
Expand Down
Loading