wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.71k stars 793 forks source link

High CPU usage when hovering over tabs #3276

Open iskeld opened 1 year ago

iskeld commented 1 year ago

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

wezterm 20230317-153901-2d255c2d

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

I was going to enchance non-fancy tab bar with powerline symbols according to this sample, but with additional changes

It worked but the terminal felt laggy.

I removed the event handler and kept quickly moving the mouse cursor over the tab headers (so that each gets hover) and even empty wezterm reached almost 30% CPU by doing nothing but hovering the tabs.

To Reproduce

Run some kind of cpu monitor Keep moving mouse horizontally back and forth over the tabs. See CPU usage of wezterm

Configuration

local wezterm = require 'wezterm'

function scheme_for_appearance(appearance)
  if appearance:find 'Dark' then
    return 'Gruvbox dark, medium (base16)'
  else
    return 'Gruvbox light, hard (base16)'
  end
end

-- The filled in variant of the < symbol
local SOLID_LEFT_ARROW = utf8.char(0xe0ba)

-- The filled in variant of the > symbol
local SOLID_RIGHT_ARROW = utf8.char(0xe0bc)

local scheme_name = scheme_for_appearance(wezterm.gui.get_appearance())
local scheme = wezterm.color.get_builtin_schemes()[scheme_name]

return {
    color_scheme = scheme_name,
    font_size = 14.0,
    use_fancy_tab_bar = false,
    window_decorations = "RESIZE",
    window_padding = {
        bottom = "0.5cell",
        left = "0.5cell",
        right = "0.5cell",
        top = "0.5cell",
    },
}

Expected Behavior

Smaller CPU usage

Logs

No response

Anything else?

OS: macOS 13.1 22C65 arm64 CPU/GPU: Apple M1 Pro

wez commented 1 year ago

I've pushed a commit that avoids over invalidating when hovering the tabs. It reduces the CPU usage a bit.

That should be available as a nightly download in about an hour.

MLFlexer commented 1 year ago

I'm having the same problem with high CPU usage when hovering and formatting tabs with format-tab-title on the current nightly version, ubuntu 23.04, X11

joetifa2003 commented 8 months ago

Having the same issue with format-tab-title,

First it was quite complex so i thought that my config was way too demanding.

But just tried with

wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width)
    return "foo"
end)

And hovering just freezes wezterm.

Also had a similar issue with update-status, scrolling neovim lags when using battery info