Skip to content

Commit

Permalink
Merge pull request #5182 from jerch/fix_5181
Browse files Browse the repository at this point in the history
fix #5181
  • Loading branch information
Tyriar authored Oct 14, 2024
2 parents a5fc111 + 9c74c81 commit f701d07
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
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

0 comments on commit f701d07

Please sign in to comment.