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

resizing in mux domains has issues #5142

Open
crides opened this issue Mar 10, 2024 · 6 comments · May be fixed by #6062
Open

resizing in mux domains has issues #5142

crides opened this issue Mar 10, 2024 · 6 comments · May be fixed by #6062
Labels
bug Something isn't working

Comments

@crides
Copy link
Sponsor Contributor

crides commented Mar 10, 2024

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

Linux X11, macOS

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

No response

WezTerm version

wezterm 20240102-011725-2f7ca41a

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

No, and I'll explain why below

Describe the bug

  1. Resizing makes the bar glitchy
  2. Resizing can change the window size
  3. Resizing can take a long time, where the server resizes and redraws each pane one step at a time, even if the dragging itself is very quick (doesn't happen for resizing with keybinds, which is expected)

To Reproduce

  1. attach to mux ((slow) ssh is better, but unix works fine for at least the first 2)
  2. split (it's easier to see the problems when split vertically)
  3. drag the bar

Configuration

no config

Expected Behavior

No response

Logs

01:05:37.087 ERROR wezterm_term::terminalstate::iterm > my pixel dimensions are wacky! 0x0
01:05:37.149 ERROR mux::connui > while running ConnectionUI loop: recv_timeout: channel is empty and disconnected
01:05:37.560 ERROR wezterm_term::terminalstate::iterm > my pixel dimensions are wacky! 0x0
01:05:37.633 ERROR mux::connui > while running ConnectionUI loop: recv_timeout: channel is empty and disconnected
01:05:38.008 ERROR wezterm_term::terminalstate::iterm > my pixel dimensions are wacky! 0x0
01:05:38.074 ERROR mux::connui > while running ConnectionUI loop: recv_timeout: channel is empty and disconnected
01:05:38.445 ERROR wezterm_term::terminalstate::iterm > my pixel dimensions are wacky! 0x0
01:05:38.514 ERROR mux::connui > while running ConnectionUI loop: recv_timeout: channel is empty and disconnected

Anything else?

mux with unix

wezterm-resize-mux.mp4

mux with ssh. Slightly easier to see the effects, but I wanted to show issue 3 which didn't show up. Issue 3 is clearly visible on my work computer.

wezterm-resize-ssh.mp4
@crides crides added the bug Something isn't working label Mar 10, 2024
@yshui
Copy link

yshui commented Aug 21, 2024

I have the same issue.

The problem is much more pronounced if there is a lot of text in the pane. And sometimes the panes will keep dancing around even after I let go of them, and will only stop after I have detached then re-attached the domain.

@yshui
Copy link

yshui commented Aug 21, 2024

actually, it doesn't take that much, mostly empty panes will struggle too.

here is a video showing off this behavior, it's a bit long. at the start you will notice resizing was extremely slow even for empty panes, then several seconds after I have let go, the panes started to dance around.

the experience is really bad, basically wezterm isn't a viable tmux replacement because of this.

bug.mp4

@yshui
Copy link

yshui commented Aug 21, 2024

I see now that there are actually 2 different problems here. One being that pane resizing is extremely slow. With some profiling I found out one hotspot is TermWindow::update_title_impl. I believe it is called in response to MuxNotification::TabResized, which is sent an extraordinary amount of times, clearly more than what is necessary.

The second being the panes jumping around. This is exacerbated by the first problem, but even after I commented out the call to update_title and saw the CPU usage drop by a lot, this still happens. I haven't figured out this one yet.

@yshui
Copy link

yshui commented Aug 21, 2024

I have noticed that the MuxNotification::TabResized is sometimes sent repeated even after I have let go of the mouse button, and is correlated with the dancing panes.

@yshui
Copy link

yshui commented Aug 22, 2024

I think there is a feedback loop in sync_with_pane_tree

@yshui
Copy link

yshui commented Aug 22, 2024

Yes, so MuxNotification:TabResized leads to the server sending a Pdu::TabResized, which triggers a pane list resync in the client. And because resizing is slow, the pane resize is behind what the client thinks it would be. so the client thinks it was resized again, so it calls mux::tab::TabInner::resize, and the whole thing starts over.

yshui added a commit to yshui/wezterm that referenced this issue Aug 30, 2024
say the pane with 100 cols wide, we got 3 mouse events, one move the
split to 99, the next one move it to 98, then to 90

we would first call resize_split_by with -1, -1, then with -8. the first
resize is completed just as we call resize_split_by(-8), this triggers a
resync, and updates the split position to 99. because of that
resize_split_by(-8) will try to resize it to 91, instead of the desire
90.

in practice, there are a lot more mouse events and the timing is more
unpredictable, the end result can be very chaotic.

partially fix wez#5142
@yshui yshui linked a pull request Aug 30, 2024 that will close this issue
yshui added a commit to yshui/wezterm that referenced this issue Aug 30, 2024
say the pane with 100 cols wide, we got 3 mouse events, one move the
split to 99, the next one move it to 98, then to 90

we would first call resize_split_by with -1, -1, then with -8. the first
resize is completed just as we call resize_split_by(-8), this triggers a
resync, and updates the split position to 99. because of that
resize_split_by(-8) will try to resize it to 91, instead of the desire
90.

in practice, there are a lot more mouse events and the timing is more
unpredictable, the end result can be very chaotic.

partially fix wez#5142
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants