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

UI freezes on screen dismissal with new Footer #4552

Closed
twrightsman opened this issue May 24, 2024 · 14 comments · Fixed by #4558
Closed

UI freezes on screen dismissal with new Footer #4552

twrightsman opened this issue May 24, 2024 · 14 comments · Fixed by #4558

Comments

@twrightsman
Copy link

twrightsman commented May 24, 2024

I am getting a UI freeze after clicking the "Save" button in the following example code:

from textual import on
from textual.app import App, ComposeResult
from textual.containers import ScrollableContainer
from textual.screen import ModalScreen
from textual.widgets import Footer, Label, Button


class MyModal(ModalScreen[str | None]):
    BINDINGS = [("escape", "cancel", "Cancel")]

    def __init__(self, s: str):
        self._s = s
        super().__init__()

    def compose(self) -> ComposeResult:
        with ScrollableContainer():
            yield Label("My Screen")
            yield Button("Save", id="save", variant="success")
        yield Footer()

    @on(Button.Pressed, "#save")
    def handle_save(self) -> None:
        self.dismiss("Yes" if (self._s == "Hello!") else None)

    def action_cancel(self) -> None:
        self.dismiss(None)


class MyApp(App):
    BINDINGS = [
        ("m", "modal", "Show modal")
    ]

    def compose(self) -> ComposeResult:
        yield Footer()

    def action_modal(self) -> None:
        s = "Hello!"
        self.push_screen(MyModal(s))


if __name__ == "__main__":
    MyApp().run()

textual console shows:

[17:03:27] EVENT                                          message_pump.py:745
Unmount() >>> ScrollableContainer() method=<Widget.on_unmount>
─────────────────────────────────────────────────────────────────────────────
[17:03:30] WARNING                                            _callback.py:73
Callback functools.partial(<textual.await_remove.AwaitRemove object at 
0x7ff60c5be090>) is still pending after 3 seconds
[17:03:30] WARNING                                            _callback.py:73
Callback functools.partial(<bound method Widget.recompose of Footer()>) is 
still pending after 3 seconds

Using ClassicFooter does not cause the freeze.

Textual Diagnostics

Versions

Name Value
Textual 0.63.3
Rich 13.7.1

Python

Name Value
Version 3.11.2
Implementation CPython
Compiler GCC 12.2.0
Executable /home/[snip]/.venv/bin/python

Operating System

Name Value
System Linux
Release 6.1.0-21-amd64
Version #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03)

Terminal

Name Value
Terminal Application Unknown
TERM foot
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=212, height=46
legacy_windows False
min_width 1
max_width 212
is_terminal True
encoding utf-8
max_height 46
justify None
overflow None
no_wrap False
highlight None
markup None
height None
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@TomJGooding
Copy link
Contributor

Try renaming your app to something like MyApp - do you see the same issues?

@twrightsman
Copy link
Author

@TomJGooding Darn, that fixes this minimal example. But the issue remains in my actual app code. I'll try to make another minimal example that breaks.

@willmcgugan
Copy link
Collaborator

If you manage to reproduce it, can you try against main? There are some changes there that may be relevant.

@twrightsman
Copy link
Author

I was mistaken earlier and forgot to go back to Footer instead of ClassicFooter. I just tested the example code above on my machine on 0.63.3 and master (5195a57) but unfortunately I can still reproduce the freeze when the save button is clicked.

@willmcgugan
Copy link
Collaborator

I can't seem to reproduce that on macOS. With main or the latest release. Can you reproduce it consistently, or is it intermitent?

@twrightsman
Copy link
Author

I can reproduce it consistently. I'd say close to 80-90% of the time it triggers. With main, the textual console output is slightly different than 0.63.3:

[10:03:36] EVENT                                          message_pump.py:732
Unmount() >>> ScrollableContainer() method=<Widget.on_unmount>
─────────────────────────────────────────────────────────────────────────────
[10:03:39] WARNING                                            _callback.py:73
Callback functools.partial(<textual.await_remove.AwaitRemove object at 
0x7fb3a35ac290>) is still pending after 3 seconds
[10:03:39] WARNING                                            _callback.py:73
Callback functools.partial(<function 
Footer.on_mount.<locals>.bindings_changed at 0x7fb3a352b740>, MyModal()) is 
still pending after 3 seconds

@willmcgugan
Copy link
Collaborator

I can't reproduce this on Linux either. What terminal software are you running? Is this on a Raspberry Pi?

@twrightsman
Copy link
Author

I am running foot; but I was just able to reproduce this in GNOME Terminal. I should have some time later to spin up a clean Debian VM and make sure it's not some strange environment configuration of mine.

@twrightsman
Copy link
Author

Alright, it seems this only triggers when tabbing to the Save button and pressing enter to press it. I also do not see the behavior when clicking the button with the mouse. A friend was able to reproduce the freeze on MacOS as well when tabbing to the button and pressing enter.

@willmcgugan
Copy link
Collaborator

Thanks, I can reproduce it now.

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

@willmcgugan
Copy link
Collaborator

Please try 0.63.4

@twrightsman
Copy link
Author

Seems to be fixed, thank you investigating!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants