wez / wezterm

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

FTXUI (tui library) canvas example runs slower than windows terminal #2524

Open doongjohn opened 2 years ago

doongjohn commented 2 years ago

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

Windows

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

No response

WezTerm version

20220916-074812-8d2a3cf7

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 trying out FTXUI library and found that this example(canvas_animated.cpp) runs slower than windows terminal https://github.com/ArthurSonzogni/FTXUI/blob/master/examples/component/canvas_animated.cpp

Recording 2022-09-17 at 23 47 50

To Reproduce

https://github.com/ArthurSonzogni/FTXUI/blob/master/examples/component/canvas_animated.cpp compile and run this example

Configuration

local wezterm = require'wezterm'

local wsl_domains = wezterm.default_wsl_domains()
for _, domain in ipairs(wsl_domains) do
  domain.default_cwd = '~'
end

return {
  wsl_domains = wsl_domains,
  default_domain = 'WSL:Void',

  -- key bindings
  keys = {
    { key = 'l', mods = 'ALT',
      action = 'ShowLauncher' },

    { key = '-', mods = 'ALT',
      action = wezterm.action{ SplitVertical = { domain = 'CurrentPaneDomain' } } },

    { key = '/', mods = 'ALT',
      action = wezterm.action{ SplitHorizontal = { domain = 'CurrentPaneDomain' } } },
  },

  -- launch menu
  launch_menu = {
    {
      label = 'Bash',
      args = { 'bash' },
    },
    {
      label = 'Powershell',
      args = { [[/mnt/c/Program Files/PowerShell/7/pwsh.exe]], '-nologo', '-wd', '~' },
    },
  },

  -- font settings
  line_height = 1.32,
  font_size = 14,
  font = wezterm.font_with_fallback({
    -- 'Minecraft Mono',
    'VictorMono NF',
    'NanumGothicCoding',
  }),
  harfbuzz_features = { 'calt=0', 'clig=0', 'liga=0' }, -- disable ligatures
  adjust_window_size_when_changing_font_size = false,

  -- disable hyperlink
  hyperlink_rules = {{ regex = '', format = '', }},

  -- window
  window_decorations = "RESIZE",
  initial_cols = 120,
  initial_rows = 23,
  window_frame = {
    font_size = 10.0,
  },
  window_padding = {
    top = 4,
    bottom = 0,
    left = 10,
    right = 10,
  },

  -- tab bar settings
  use_fancy_tab_bar = false,
  hide_tab_bar_if_only_one_tab = true,
  tab_max_width = 23,
  wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width)
    return {
      { Text = " " .. tab.tab_index .. ": " .. wezterm.truncate_left(tab.active_pane.title, max_width + 2) },
    }
  end),

  -- kanagawa color scheme
  colors = {
    tab_bar = {
      background = '#1f1f28',
      active_tab = {
        fg_color = '#DCD7BA',
        bg_color = '#1F1F28',
      },
      inactive_tab = {
        bg_color = '#2A2A37',
        fg_color = '#C8C093',
      },
      inactive_tab_hover = {
        bg_color = '#363646',
        fg_color = '#C8C093',
        italic = false,
      },
      new_tab = {
        bg_color = '#2A2A37',
        fg_color = '#C8C093',
      },
      new_tab_hover = {
        bg_color = '#363646',
        fg_color = '#C8C093',
        italic = false,
      },
    },
    foreground = '#dcd7ba',
    background = '#1f1f28',
    cursor_bg = '#c8c093',
    cursor_border = '#c8c093',
    selection_fg = '#c8c093',
    selection_bg = '#2d4f67',
    scrollbar_thumb = '#16161d',
    split = '#16161d',
    ansi = {
      '#090618',
      '#c34043',
      '#76946a',
      '#c0a36e',
      '#7e9cd8',
      '#957fb8',
      '#6a9589',
      '#c8c093'
    },
    brights = {
      '#727169',
      '#e82424',
      '#98bb6c',
      '#e6c384',
      '#7fb4ca',
      '#938aa9',
      '#7aa89f',
      '#dcd7ba'
    },
    indexed = {
      [16] = '#ffa066',
      [17] = '#223249'
      -- [17] = '#ff5d62'
    },
  },
}

Expected Behavior

https://github.com/ArthurSonzogni/FTXUI/blob/master/examples/component/canvas_animated.cpp this example should run as fast as (or faster than) windows terminal

Logs

Debug Overlay
wezterm version: 20220916-074812-8d2a3cf7
OpenGL version: NVIDIA GeForce RTX 3070 Ti/PCIe/SSE2 4.5.0 NVIDIA 516.94
Enter lua statements or expressions and hit Enter.
Press ESC or CTRL-D to exit
23:58:57.580 WARN wezterm_term::terminalstate > unhandled DecPrivateMode SetDecPrivateMode(Unspecified(1005))

Anything else?

No response

wez commented 2 years ago

Please capture a terminal recording:

*** Finished recording to /var/tmp/wezterm-recording-sF6B3u.cast.txt

The file is an asciicast (compatible with https://asciinema.org/) and can also be replayed using wezterm replay.

The terminal recording allows me to replicate what is being sent to the terminal without requiring me to install the same applications as you and replicate your configuration for everything.

doongjohn commented 2 years ago

this is weird... when I run wezterm record my keyborad input is producing unwanted ANSI escape code 😢

Recording 2022-09-19 at 18 31 59

wez commented 2 years ago

Those escape sequences are from https://wezfurlong.org/wezterm/config/lua/config/allow_win32_input_mode.html They are showing up because you're defaulting to running WSL which adds additional layers of PTY processing that get confused when you bridge back to win32 from WSL.

You may wish to disable that mode.

I'd suggest making two recordings so that we can compare them:

  1. Start with windows terminal, run wezterm record and record the test application.
  2. Launch wezterm-gui -n; the -n will skip loading your config file. record the test application.
  3. Attach both recordings to this issue.

For your launch menu item that launches powershell, I'd recommend explicitly using the local domain because the default_domain in your config causes every command to be spawned via WSL, which adds undesirable overhead:

{
 args = { 'pwsh.exe', '-nologo' },
 -- always use the local native domain to avoid running via WSL
 -- when using `default_domain`.
 domain = { DomainName = 'local' },
}
doongjohn commented 2 years ago

I recorded with both terminal I hope this can help you fix this issue wezterm-recording-wezterm.cast.txt wezterm-recording-windowsterminal.cast.txt