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

[xterm-addon-web-links] Typing with link highlighted causes serious performance impact #4845

Closed
raiden-dev opened this issue Oct 14, 2023 · 3 comments
Labels
area/links type/bug Something is misbehaving

Comments

@raiden-dev
Copy link

Details

  • Browser and browser version: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36
  • OS version: Windows 11 Pro / 22H2
  • xterm.js version: Any version with loaded xterm-addon-web-links. Tested on version bundled with ttyd: "xterm": "^5.3.0, "xterm-addon-web-links": "^0.9.0".

Steps to reproduce

  1. Make a terminal with loaded WebLinksAddon from xterm-addon-web-links package.
  2. Move mouse pointer to any link in xterm.js canvas to highlight it.
  3. Try to type anything. Overall performance will degrade with every new keypress and may result to tab crash.

Here's the traced performance profile: Trace-20231014T084401.json

Screenshot 2023-10-14 084530
@jerch
Copy link
Member

jerch commented Nov 3, 2023

@raiden-dev Thx for finding this one, can repro it as long as the typed content adds the the link while the link is hovered. This really feels like some exp runtime issue, the perf degrades really fast. Interesting sidenote - the perf resets if I re-hover the link and continue typing.

From a first glance at devtools it seems the time gets eaten in this method:

private _clearCurrentLink(startRow?: number, endRow?: number): void {
if (!this._element || !this._currentLink || !this._lastMouseEvent) {
return;
}
// If we have a start and end row, check that the link is within it
if (!startRow || !endRow || (this._currentLink.link.range.start.y >= startRow && this._currentLink.link.range.end.y <= endRow)) {
this._linkLeave(this._element, this._currentLink.link, this._lastMouseEvent);
this._currentLink = undefined;
disposeArray(this._linkCacheDisposables);
}
}

but that code looks rather innocent to me. Maybe there is something off with this._linkCacheDisposables, not sure yet.

@jerch jerch added type/bug Something is misbehaving area/links labels Nov 3, 2023
@jerch
Copy link
Member

jerch commented Nov 3, 2023

I cannot repro it on our demo, works with all renderers as expected not showing any quadratic/exp runtime growth. This is somewhat weird, as there were no substantial code changes to the linkifier or the web-links addon almost in a year.

@Tyriar My best guess here is, that this was also solved with #4814. Gonna close the issue, as master does not exhibit the toxic growth anymore.

@jerch jerch closed this as completed Nov 3, 2023
@Tyriar
Copy link
Member

Tyriar commented Nov 3, 2023

Yep #4814 was a pretty bad bug.

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

No branches or pull requests

3 participants