Closed wez closed 5 years ago
and to be clear: it does respond to input, it just looks funny until the first keypress because the screen is incomplete and there's no status bar at the bottom
All the read
calls in poll_input
should be non-blocking. Can you work out which fd it's reading?
(lldb) up
frame #2: 0x000000010cafc5fe sp`_$LT$termwiz..terminal..unix..UnixTerminal$u20$as$u20$termwiz..terminal..Terminal$GT$::poll_input::h6fbe481e85ab86cb(self=0x00007ffee33864b0, wait=Option<core::time::Duration> @ 0x00007ffee3385640) at unix.rs:496:18
493
494 if pfd[1].revents != 0 {
495 let mut buf = [0u8; 64];
-> 496 match self.read.read(&mut buf) {
497 Ok(n) => {
498 let input_queue = &mut self.input_queue;
499 self.input_parser.parse(
(lldb)
(but note that I'm temporarily pointing this to termwiz 0.2 because I think you may have force-pushed the wezterm branch in your cargo.toml; I'll publish 0.3.0 with your latest changes as soon as the CI is done building them)
In this case, poll_input
is being called with wait=None, which leads to that blocking read.
Digging into this a bit more, this appears to be yet another macOS poll(2) bug.
This stackoverflow page has a similar question that manifests the same way:
https://stackoverflow.com/questions/591826/it-really-looks-like-os-x-has-a-bug-when-using-poll-on-a-named-pipe-fifo
I'm seeing the poll call return POLLNVAL for the tty input stream.
I'll take this as a termwiz issue: I think we need to use select(2)
to get reliable behavior on macos :-/
It looks like it is that bug. In poll_input(wait = None)
, only the call to poll
should be blocking - the reads to the other pipes should all be nonblocking (set up elsewhere in the module).
I have a version of this that uses select(2)
on macos, but now the behavior is that we're blocked forever in select(2)
and the screen isn't fully painted. I think part of the problem here is that poll_input is being called with wait=None before the screen has been fully painted at least once.
I think there is still something fishy with polling the tty on macos and I'm continuing to poke at this.
Traced this to three issues:
This may end up being a termwiz bug...
It looks like it reads twenty-something lines and stops; looks like we're blocked in
read
:Possibly related to https://github.com/wez/wezterm/commit/cc0d2e5493f0f2b810ca243c650fa02d83084937