wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

100% CPU usage on non visible window

Open grappas opened this issue 1 year ago • 3 comments

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

Linux Wayland

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

Hyprland

WezTerm version

20231017-091526-fec90ae0

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

When window is non visible (i.e. in other workspace) and has highly changing content (i.e. btop) there's 100% CPU usage.

To Reproduce

  1. Open wezterm.
  2. Open some highly changing app (like top, btop, etc.)
  3. Change workspace.
  4. Check CPU usage.

Configuration

local wezterm = require 'wezterm'
local act = wezterm.action
local mykeys = {
}

local My_font_size = 14.0
local Font_size = My_font_size

function Recompute_font_size(window)
    local window_dims = window:get_dimensions()
    local overrides = window:get_config_overrides() or {}
    local Dpi = window_dims.dpi / 96
    local Scale_factor_general = 7
    local Scale_factor_x = window_dims.pixel_width / ( Scale_factor_general * 9 * Dpi )
    local Scale_factor_y = window_dims.pixel_height / ( Scale_factor_general * 7 * Dpi )
    local Scale_factor = Scale_factor_x

    if (Scale_factor_y > Scale_factor_x)
    then
        Scale_factor = Scale_factor_x
    else
        Scale_factor = Scale_factor_y
    end

    if Scale_factor > My_font_size
    then
        Font_size = My_font_size
    else
        Font_size = math.floor(Scale_factor)
    end
    overrides.font_size = Font_size
    window:set_config_overrides(overrides)
end

wezterm.on('window-resized', function(window)
    Recompute_font_size(window)
end)

for i = 1, 8 do
    -- CTRL+ALT + number to activate that tab
    table.insert(mykeys, {
        key = tostring(i),
        mods = 'CTRL|ALT',
        action = act.ActivateTab(i - 1),
    })
    -- F1 through F8 to activate that tab
    table.insert(mykeys, {
        key = 'F' .. tostring(i),
        action = act.ActivateTab(i - 1),
    })
end

if wezterm.target_triple == 'x86_64-pc-windows-msvc' then
    Default_prog = { 'powershell.exe' }
else
    Default_prog = { 'zsh' }
end

if wezterm.target_triple == 'x86_64-pc-windows-msvc' then
    Font = wezterm.font 'VictorMono NF'
else
    Font = wezterm.font 'VictorMono Nerd Font'
end


return {
    font = Font,
    font_size = Font_size,
    color_scheme = 'GruvboxDark',
    window_background_opacity = 0.9,
    window_close_confirmation = 'NeverPrompt',
    default_prog = Default_prog,
    enable_wayland = true,
    hide_tab_bar_if_only_one_tab = true,
    default_cursor_style = 'SteadyBlock',

    front_end = "WebGpu",

    keys = {
        -- {{{1
        {
            key = 'F1',
            mods = 'CMD',
            action = wezterm.action.DisableDefaultAssignment,
        },
        {
            key = 'F2',
            mods = 'CMD',
            action = wezterm.action.DisableDefaultAssignment,
        },
        {
            key = 'F3',
            mods = 'CMD',
            action = wezterm.action.DisableDefaultAssignment,
        },
        {
            key = 'F4',
            mods = 'CMD',
            action = wezterm.action.DisableDefaultAssignment,
        },
        {
            key = 'F5',
            mods = 'CMD',
            action = wezterm.action.DisableDefaultAssignment,
        },
        {
            key = 'F6',
            mods = 'CMD',
            action = wezterm.action.DisableDefaultAssignment,
        },
        {
            key = 'F7',
            mods = 'CMD',
            action = wezterm.action.DisableDefaultAssignment,
        },
        {
            key = 'F8',
            mods = 'CMD',
            action = wezterm.action.DisableDefaultAssignment,
        },
        {
            key = 'F9',
            mods = 'CMD',
            action = wezterm.action.DisableDefaultAssignment,
        },
        {
            key = 'F10',
            mods = 'CMD',
            action = wezterm.action.DisableDefaultAssignment,
        },
        {
            key = 'F11',
            mods = 'CMD',
            action = wezterm.action.DisableDefaultAssignment,
        },
        {
            key = 'F12',
            mods = 'CMD',
            action = wezterm.action.DisableDefaultAssignment,
        },
        -- }}}
    }
}

Expected Behavior

No unnecessary CPU usage

Logs

Debug Overlay wezterm version: 20231017-091526-fec90ae0 x86_64-unknown-linux-gnu Window Environment: Wayland WebGPU: name=AMD Radeon RX 6750 XT, device_type=DiscreteGpu, backend=Vulkan, driver=AMD open-source driver, driver_info=2023.Q4.1 (LLPC), vendor=4098, device=29663

Anything else?

https://github.com/wez/wezterm/assets/1036957/2e588cdd-88c1-4924-a9d9-964533f360f1

obraz

Also can be reproduced when going to Debug Overlay Also tried without WebGL. Same bug.

grappas avatar Oct 28 '23 19:10 grappas

https://github.com/wez/wezterm/commit/600652583594e9f6195a6427d1fabb09068622a7

Seems not to be an issue anymore with that commit. Closing for now.

grappas avatar Nov 19 '23 15:11 grappas

Nah... I knew I closed it too soon. It's just randomly started to suck whole thread again.

grappas avatar Nov 19 '23 21:11 grappas

30-60s this appears in debug console, to suck whole thread

22:29:00.813  DEBUG  wezterm_term::terminalstate::performer > perform CSI(Mode(SetDecPrivateMode(Code(SynchronizedOutput))))
22:29:00.813  DEBUG  wezterm_term::terminalstate::performer > perform CSI(Cursor(Position { line: OneBased { value: 36 }, col: OneBased { value: 161 } }))
22:29:00.813  DEBUG  wezterm_term::terminalstate::performer > perform Esc(Code(AsciiCharacterSetG0))
22:29:00.813  DEBUG  wezterm_term::terminalstate::performer > perform CSI(Sgr(Reset))
22:29:00.813  DEBUG  wezterm_term::terminalstate            > Reset
22:29:00.813  DEBUG  wezterm_term::terminalstate::performer > perform CSI(Sgr(Intensity(Bold)))
22:29:00.813  DEBUG  wezterm_term::terminalstate            > Intensity(Bold)
22:29:00.813  DEBUG  wezterm_term::terminalstate::performer > perform CSI(Sgr(Foreground(TrueColor(SrgbaTuple(0.15686275, 0.15686275, 0.15686275, 1.0)))))
22:29:00.813  DEBUG  wezterm_term::terminalstate            > Foreground(TrueColor(SrgbaTuple(0.15686275, 0.15686275, 0.15686275, 1.0)))
22:29:00.813  DEBUG  wezterm_term::terminalstate::performer > perform CSI(Sgr(Background(TrueColor(SrgbaTuple(0.65882355, 0.6, 0.5176471, 1.0)))))
22:29:00.813  DEBUG  wezterm_term::terminalstate            > Background(TrueColor(SrgbaTuple(0.65882355, 0.6, 0.5176471, 1.0)))
22:29:00.813  DEBUG  wezterm_term::terminalstate::performer > perform Print('9')
22:29:00.813  DEBUG  wezterm_term::terminalstate::performer > perform CSI(Cursor(Position { line: OneBased { value: 16 }, col: OneBased { value: 41 } }))
22:29:00.813  DEBUG  wezterm_term::terminalstate::performer > perform CSI(Mode(ResetDecPrivateMode(Code(SynchronizedOutput))))
22:29:00.813  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
22:29:00.813  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
22:29:00.813  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
22:29:00.814  DEBUG  wezterm_gui::termwindow                > NeedRepaint
22:29:00.814  DEBUG  wezterm_font::shaper::harfbuzz         > cluster_resolver: ClusterResolver {
    map: {
        0: ClusterInfo {
            start: 0,
            byte_len: 1,
            cell_width: 1,
            incomplete: false,
        },
        3: ClusterInfo {
            start: 3,
            byte_len: 1,
            cell_width: 1,
            incomplete: false,
        },
        2: ClusterInfo {
            start: 2,
            byte_len: 1,
            cell_width: 1,
            incomplete: false,
        },
        1: ClusterInfo {
            start: 1,
            byte_len: 1,
            cell_width: 1,
            incomplete: false,
        },
        5: ClusterInfo {
            start: 5,
            byte_len: 1,
            cell_width: 1,
            incomplete: false,
        },
        4: ClusterInfo {
            start: 4,
            byte_len: 1,
            cell_width: 1,
            incomplete: false,
        },
    },
    presentation_width: Some(
        PresentationWidth {
            cluster: CellCluster {
                attrs: CellAttributes {
                    attributes: 1,
                    intensity: Bold,
                    underline: None,
                    blink: None,
                    italic: false,
                    reverse: false,
                    strikethrough: false,
                    invisible: false,
                    wrapped: false,
                    overline: false,
                    semantic_type: Output,
                    foreground: Default,
                    background: Default,
                    fat: Some(
                        FatAttributes {
                            hyperlink: None,
                            image: [],
                            underline_color: Default,
                            foreground: TrueColorWithDefaultFallback(
                                SrgbaTuple(
                                    0.15686275,
                                    0.15686275,
                                    0.15686275,
                                    1.0,
                                ),
                            ),
                            background: TrueColorWithDefaultFallback(
                                SrgbaTuple(
                                    0.65882355,
                                    0.6,
                                    0.5176471,
                                    1.0,
                                ),
                            ),
                        },
                    ),
                },
                text: "22:29 ",
                width: 6,
                presentation: Text,
                direction: LeftToRight,
                byte_to_cell_idx: [],
                byte_to_cell_width: [],
                first_cell_idx: 156,
            },
        },
    ),
    start_by_cell_idx: {
        156: 0,
        157: 1,
        160: 4,
        159: 3,
        161: 5,
        158: 2,
    },
}
22:29:00.814  DEBUG  wezterm_font::shaper::harfbuzz         > hb info.cluster 0 -> Info { cluster: 0, len: 1, codepoint: 21, x_advance: 1303, y_advance: 0, x_offset: 0, y_offset: 0 }
22:29:00.814  DEBUG  wezterm_font::shaper::harfbuzz         > hb info.cluster 1 -> Info { cluster: 1, len: 1, codepoint: 21, x_advance: 1303, y_advance: 0, x_offset: 0, y_offset: 0 }
22:29:00.814  DEBUG  wezterm_font::shaper::harfbuzz         > hb info.cluster 2 -> Info { cluster: 2, len: 1, codepoint: 29, x_advance: 1303, y_advance: 0, x_offset: 0, y_offset: 0 }
22:29:00.814  DEBUG  wezterm_font::shaper::harfbuzz         > hb info.cluster 3 -> Info { cluster: 3, len: 1, codepoint: 21, x_advance: 1303, y_advance: 0, x_offset: 0, y_offset: 0 }
22:29:00.814  DEBUG  wezterm_font::shaper::harfbuzz         > hb info.cluster 4 -> Info { cluster: 4, len: 1, codepoint: 28, x_advance: 1303, y_advance: 0, x_offset: 0, y_offset: 0 }
22:29:00.814  DEBUG  wezterm_font::shaper::harfbuzz         > hb info.cluster 5 -> Info { cluster: 5, len: 1, codepoint: 3, x_advance: 1303, y_advance: 0, x_offset: 0, y_offset: 0 }
22:29:00.814  DEBUG  wezterm_font::shaper::harfbuzz         > font_idx=0 info_clusters: [
    [
        Info {
            cluster: 0,
            len: 1,
            codepoint: 21,
            x_advance: 1303,
            y_advance: 0,
            x_offset: 0,
            y_offset: 0,
        },
    ],
    [
        Info {
            cluster: 1,
            len: 1,
            codepoint: 21,
            x_advance: 1303,
            y_advance: 0,
            x_offset: 0,
            y_offset: 0,
        },
    ],
    [
        Info {
            cluster: 2,
            len: 1,
            codepoint: 29,
            x_advance: 1303,
            y_advance: 0,
            x_offset: 0,
            y_offset: 0,
        },
    ],
    [
        Info {
            cluster: 3,
            len: 1,
            codepoint: 21,
            x_advance: 1303,
            y_advance: 0,
            x_offset: 0,
            y_offset: 0,
        },
    ],
    [
        Info {
            cluster: 4,
            len: 1,
            codepoint: 28,
            x_advance: 1303,
            y_advance: 0,
            x_offset: 0,
            y_offset: 0,
        },
    ],
    [
        Info {
            cluster: 5,
            len: 1,
            codepoint: 3,
            x_advance: 1303,
            y_advance: 0,
            x_offset: 0,
            y_offset: 0,
        },
    ],
]
22:29:00.814  DEBUG  wezterm_gui::termwindow::render::paint > paint_impl before call_draw elapsed=946.053µs
22:29:00.815  DEBUG  wezterm_gui::termwindow::render::paint > paint_impl elapsed=1.261464ms, fps=0.08801124
22:29:00.815  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
22:29:00.815  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
22:29:01.813  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
22:29:01.814  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
22:29:01.814  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })

grappas avatar Feb 11 '24 21:02 grappas