xtermjs / xterm.js

A terminal for the web
https://xtermjs.org/
MIT License
17.56k stars 1.62k forks source link

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

Closed raiden-dev closed 11 months ago

raiden-dev commented 12 months ago

Details

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 commented 11 months ago

@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: https://github.com/xtermjs/xterm.js/blob/a5646a58d5df674190c9917702549d23a275a316/src/browser/Linkifier2.ts#L257-L268

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

jerch commented 11 months ago

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.

Tyriar commented 11 months ago

Yep https://github.com/xtermjs/xterm.js/issues/4814 was a pretty bad bug.