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

Experiencing delays in some terminals after closing Textual app #1920

Closed
mrossinek opened this issue Mar 1, 2023 · 10 comments · Fixed by #1910
Closed

Experiencing delays in some terminals after closing Textual app #1920

mrossinek opened this issue Mar 1, 2023 · 10 comments · Fixed by #1910
Assignees
Labels
bug Something isn't working Task

Comments

@mrossinek
Copy link

Please give a brief but clear explanation of the issue. If you can, include a complete working example that demonstrates the bug. > Check it can run without modifications.

In some terminals closing any textual app has a certain delay. I can reproduce this with any of the provided examples.
The oddest aspect is, that the delays differ between terminals. Below some estimated closing times (i.e. the delay between hitting the quit keybind (triggers the screen clearing immediately) and the time until the next prompt renders). These are on Arch Linux 6.1.11-arch1-1:

  • Alacritty 0.11.0 (8dbaa0bb): instant
  • Kitty 0.27.1: approx 2 seconds
  • Wezterm 20221119-145034-49b9839f: I have not seen the next prompt appear at all... (this is how I noticed in the first place 😅)

It will be helpful if you run the following command and paste the results:

textual diagnose
Wezterm
# Textual Diagnostics

## Versions

| Name    | Value  |
|---------|--------|
| Textual | 0.12.1 |
| Rich    | 13.1.0 |

## Python

| Name           | Value                                                    |
|----------------|----------------------------------------------------------|
| Version        | 3.10.9                                                   |
| Implementation | CPython                                                  |
| Compiler       | GCC 12.2.0                                               |
| Executable     | /home/max/Git/cobib/feature/rich/.direnv/venv/bin/python |

## Operating System

| Name    | Value                                                  |
|---------|--------------------------------------------------------|
| System  | Linux                                                  |
| Release | 6.1.11-arch1-1                                         |
| Version | #1 SMP PREEMPT_DYNAMIC Thu, 09 Feb 2023 20:06:08 +0000 |

## Terminal

| Name                 | Value                              |
|----------------------|------------------------------------|
| Terminal Application | WezTerm (20221119-145034-49b9839f) |
| TERM                 | xterm-256color                     |
| COLORTERM            | truecolor                          |
| FORCE_COLOR          | *Not set*                          |
| NO_COLOR             | *Not set*                          |

## Rich Console options

| Name           | Value                |
|----------------|----------------------|
| size           | width=151, height=65 |
| legacy_windows | False                |
| min_width      | 1                    |
| max_width      | 151                  |
| is_terminal    | True                 |
| encoding       | utf-8                |
| max_height     | 65                   |
| justify        | None                 |
| overflow       | None                 |
| no_wrap        | False                |
| highlight      | None                 |
| markup         | None                 |
| height         | None                 |
Kitty
# Textual Diagnostics

## Versions

| Name    | Value  |
|---------|--------|
| Textual | 0.12.1 |
| Rich    | 13.1.0 |

## Python

| Name           | Value                                                    |
|----------------|----------------------------------------------------------|
| Version        | 3.10.9                                                   |
| Implementation | CPython                                                  |
| Compiler       | GCC 12.2.0                                               |
| Executable     | /home/max/Git/cobib/feature/rich/.direnv/venv/bin/python |

## Operating System

| Name    | Value                                                  |
|---------|--------------------------------------------------------|
| System  | Linux                                                  |
| Release | 6.1.11-arch1-1                                         |
| Version | #1 SMP PREEMPT_DYNAMIC Thu, 09 Feb 2023 20:06:08 +0000 |

## Terminal

| Name                 | Value       |
|----------------------|-------------|
| Terminal Application | Kitty       |
| TERM                 | xterm-kitty |
| COLORTERM            | truecolor   |
| FORCE_COLOR          | *Not set*   |
| NO_COLOR             | *Not set*   |

## Rich Console options

| Name           | Value                |
|----------------|----------------------|
| size           | width=113, height=37 |
| legacy_windows | False                |
| min_width      | 1                    |
| max_width      | 113                  |
| is_terminal    | True                 |
| encoding       | utf-8                |
| max_height     | 37                   |
| justify        | None                 |
| overflow       | None                 |
| no_wrap        | False                |
| highlight      | None                 |
| markup         | None                 |
| height         | None                 |
Alacritty
# Textual Diagnostics

## Versions

| Name    | Value  |
|---------|--------|
| Textual | 0.12.1 |
| Rich    | 13.1.0 |

## Python

| Name           | Value                                                    |
|----------------|----------------------------------------------------------|
| Version        | 3.10.9                                                   |
| Implementation | CPython                                                  |
| Compiler       | GCC 12.2.0                                               |
| Executable     | /home/max/Git/cobib/feature/rich/.direnv/venv/bin/python |

## Operating System

| Name    | Value                                                  |
|---------|--------------------------------------------------------|
| System  | Linux                                                  |
| Release | 6.1.11-arch1-1                                         |
| Version | #1 SMP PREEMPT_DYNAMIC Thu, 09 Feb 2023 20:06:08 +0000 |

## Terminal

| Name                 | Value     |
|----------------------|-----------|
| Terminal Application | Alacritty |
| TERM                 | alacritty |
| COLORTERM            | truecolor |
| FORCE_COLOR          | *Not set* |
| NO_COLOR             | *Not set* |

## Rich Console options

| Name           | Value               |
|----------------|---------------------|
| size           | width=53, height=17 |
| legacy_windows | False               |
| min_width      | 1                   |
| max_width      | 53                  |
| is_terminal    | True                |
| encoding       | utf-8               |
| max_height     | 17                  |
| justify        | None                |
| overflow       | None                |
| no_wrap        | False               |
| highlight      | None                |
| markup         | None                |
| height         | None                |

Feel free to add screenshots and / or videos. These can be very helpful!

Nothing much to see here to be honest 🤔

@Textualize Textualize deleted a comment from github-actions bot Mar 1, 2023
@davep
Copy link
Contributor

davep commented Mar 1, 2023

This ties in quite nicely with some oddness I noticed with kitty on macOS while I was iterating over the checkbox and radio button code last week. @willmcgugan may recall that we were comparing how things looked in iTerm vs kitty and I kept complaining that there was an odd delay when I exited the test app in kitty; at the time I dismissed it as a likely clash between my fish config/prompt and kitty and didn't pay it much more attention. Given I'm a pretty avid iTerm user I didn't dive in after that.

Now that @mrossinek has seen a similar thing I'm reminded of that.

Curiously, exiting any Textual app in kitty is slow (vs iTerm), but exiting Midnight Commander (picking another full terminal app) is fine.

@davep
Copy link
Contributor

davep commented Mar 1, 2023

As a further data point: if I run one of my own apps installed via pipx, which is built on top of Textual 0.11.1, it's fine. Nice and snappy on exit. Upgrade that app to 0.12.1, no other changes, and suddenly I see the slowdown.

@mrossinek
Copy link
Author

I did a git bisection and this seems to be the first bad commit: 4d1a3a5

kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
kokizzu pushed a commit to kokizzu/textual that referenced this issue Mar 2, 2023
@willmcgugan
Copy link
Collaborator

Interesting. I don't see that on iTerm, but I do in Kitty.

Commenting out the begin_update doesn't appear to make any difference. More investigation needed.

@mrossinek thanks for looking in to this.

@willmcgugan
Copy link
Collaborator

Found the culprit! I think I might do a point release for this.

@davep
Copy link
Contributor

davep commented Mar 2, 2023

Nice! What was it in the end?

@mrossinek
Copy link
Author

Interesting. I don't see that on iTerm, but I do in Kitty.

Yesterday evening I was discussing this with @davep over on Discord, too. iTerm seemed to be fine on MacOS then, too, but Kitty was not. I recall we tested some more terminal then as well but cannot access right now to share here..

@davep davep added bug Something isn't working Task labels Mar 2, 2023
@github-actions
Copy link

github-actions bot commented Mar 2, 2023

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

@willmcgugan
Copy link
Collaborator

I mixed up begin_update with begin_batch. The former writes an escape sequence that says "don't display anything until end_update". It should have been begin_batch which tells Textual not to render anything until the end of the batch.

So the terminal was stuck waiting for the end_batch. Not sure why iTerm treats this differently to Kitty and others.

@davep
Copy link
Contributor

davep commented Mar 2, 2023

D'oh! Good catch! I didn't even register that when I looked at the commit!

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

Successfully merging a pull request may close this issue.

3 participants