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

dispose() causes an error with canvas renderer #4757

Closed
dstein64 opened this issue Sep 7, 2023 · 9 comments · Fixed by #4785
Closed

dispose() causes an error with canvas renderer #4757

dstein64 opened this issue Sep 7, 2023 · 9 comments · Fixed by #4785
Assignees
Labels
area/addon/canvas type/bug Something is misbehaving
Milestone

Comments

@dstein64
Copy link
Contributor

dstein64 commented Sep 7, 2023

The terminal's dispose() method leads to an uncaught error when using a canvas renderer. This started with the latest release (xterm@5.3.0 and xterm-addon-canvas@0.5.0).

Details

  • Browser and browser version: Chrome 116
  • OS version: Kubuntu 23.04
  • xterm.js version: 5.3.0

Steps to reproduce

Create a page with the following code:

<!doctype html>
<html>
<head>
    <link rel="stylesheet" href="https://unpkg.com/xterm@5.3.0/css/xterm.css" />
    <script src="https://unpkg.com/xterm@5.3.0/lib/xterm.js"></script>
    <script src="https://unpkg.com/xterm-addon-canvas@0.5.0/lib/xterm-addon-canvas.js"></script>
</head>
<body>
<div id="terminal"></div>
<script>
    const term = new Terminal();
    term.loadAddon(new CanvasAddon.CanvasAddon());
    term.open(document.getElementById('terminal'));
    term.writeln('Hello world!');
</script>
</body>
</html>

In the developer console, type term.dispose().

The following error message is printed to the console:

RenderService.ts:206 Uncaught TypeError: Cannot read properties of undefined (reading 'onRequestRedraw')
    at t.RenderService.setRenderer (RenderService.ts:206:26)
    at Object.dispose (CanvasAddon.ts:62:21)
    at a.dispose (Lifecycle.ts:22:9)
    at t.AddonManager._wrappedAddonDispose (AddonManager.ts:50:25)
    at t.dispose (AddonManager.ts:30:35)
    at t.AddonManager.dispose (AddonManager.ts:19:32)
    at d.dispose (Lifecycle.ts:22:9)
    at d.dispose (Terminal.ts:195:11)
    at <anonymous>:1:6

This does not occur when the canvas add-on is not used.

@dstein64 dstein64 changed the title dispose() errors with canvas renderer dispose() causes an error with canvas renderer Sep 7, 2023
@dstein64
Copy link
Contributor Author

dstein64 commented Sep 8, 2023

git bisect indicates that this started at 37b0e40.

@Tyriar Tyriar self-assigned this Sep 8, 2023
@Tyriar
Copy link
Member

Tyriar commented Sep 8, 2023

Thanks for looking into it, I plan on checking this out today or early next week

@Tyriar Tyriar added this to the 5.3.0 milestone Sep 8, 2023
@Tyriar Tyriar added type/bug Something is misbehaving area/addon/canvas labels Sep 8, 2023
@Tyriar
Copy link
Member

Tyriar commented Sep 8, 2023

We can do a stable canvas addon release easily so we can fix and publish this.

@Tyriar
Copy link
Member

Tyriar commented Sep 10, 2023

@dstein64 fix is out in #4785, it's a change in core so we can't do an addon release to fix it. The change is probably harmless, you stick a try around .dispose() if the error is causing problems.

@Tyriar Tyriar modified the milestones: 5.3.0, 5.4.0 Sep 10, 2023
@BrunoQuaresma
Copy link

BrunoQuaresma commented Sep 12, 2023

It is also happening with the WebGL renderer:

TypeError: Cannot read properties of undefined (reading 'onRequestRedraw')

Reverting to 5.2.0 worked.

@catz
Copy link

catz commented Feb 2, 2024

+1 for Bruno issue. Reverted to 5.2.0 fixed the issue with webgl

@catz
Copy link

catz commented Feb 2, 2024

@Tyriar Can you please have a look it for webgl rendered ?

@Tyriar
Copy link
Member

Tyriar commented Feb 2, 2024

@catz this is fixed in 5.4.0 which hasn't been released yet. You can use the beta tag version in the meantime, this should be relatively safe as it's what vscode uses.

@catz
Copy link

catz commented Feb 2, 2024

@Tyriar Daniel, That's awesome news!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/addon/canvas type/bug Something is misbehaving
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants