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

TUI: Crash when loading a specific account #499

Open
ArthurHoaro opened this issue Aug 28, 2024 · 4 comments
Open

TUI: Crash when loading a specific account #499

ArthurHoaro opened this issue Aug 28, 2024 · 4 comments

Comments

@ArthurHoaro
Copy link
Contributor

ArthurHoaro commented Aug 28, 2024

This error happens when I try to open this account from a post in the main timeline, using "A".

It looks the same as this issue (solved), but for an account and not a post.
I'm guessing it's because of accented characters in the profile/hashtags.

Account: @juliette@mastodon.green
From post: https://mastodon.green/@juliette/113039496315816199

 ➜ toot env         
toot 0.44.1
Python 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0]
Linux-5.15.0-119-generic-x86_64-with-glibc2.35

Stacktrace:

Traceback (most recent call last):
  File "/home/arthur/.local/bin/toot", line 8, in <module>
    sys.exit(cli())
  File "/home/arthur/.local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/arthur/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/arthur/.local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/arthur/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/arthur/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/arthur/.local/lib/python3.10/site-packages/toot/cli/__init__.py", line 124, in wrapped
    return f(get_context(), *args, **kwargs)
  File "/home/arthur/.local/lib/python3.10/site-packages/toot/cli/tui.py", line 73, in tui
    tui.run()
  File "/home/arthur/.local/lib/python3.10/site-packages/toot/tui/app.py", line 164, in run
    self.loop.run()
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/event_loop/main_loop.py", line 337, in run
    self._run()
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/event_loop/main_loop.py", line 439, in _run
    self.event_loop.run()
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/event_loop/asyncio_loop.py", line 235, in run
    raise exc.with_traceback(exc.__traceback__)
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/event_loop/asyncio_loop.py", line 114, in _entering_idle
    callback()
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/event_loop/main_loop.py", line 650, in entering_idle
    self.draw_screen()
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/event_loop/main_loop.py", line 667, in draw_screen
    canvas = self._topmost_widget.render(self.screen_size, focus=True)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/widget.py", line 112, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/frame.py", line 481, in render
    body = self.body.render((maxcol, maxrow - ftrim - htrim), focus and self.focus_part == "body")
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/widget.py", line 112, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/overlay.py", line 907, in render
    top_c = self.top_w.render(self.top_w_size(real_size, left, right, top, bottom), focus)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/widget.py", line 112, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/widget.py", line 711, in render
    canv = get_delegate(self).render(size, focus=focus)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/widget.py", line 112, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/pile.py", line 873, in render
    canv = w.render(w_size, focus=focus and item_focus)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/widget.py", line 112, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/columns.py", line 1026, in render
    w.render(w_size, focus=focus and self.focus_position == i),
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/widget.py", line 112, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/listbox.py", line 754, in render
    canvas = widget.render((maxcol,))
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/widget.py", line 112, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/pile.py", line 873, in render
    canv = w.render(w_size, focus=focus and item_focus)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/widget.py", line 113, in cached_render
    validate_size(self, size, canv)
  File "/home/arthur/.local/lib/python3.10/site-packages/urwid/widget/widget.py", line 92, in validate_size
    raise WidgetError(
urwid.widget.widget.WidgetError: Widget <TextEmbed fixed/flow widget 'slow living in denmark. interests include \uf8fe\uf8ff\uf8ff\uf8ff\uf8ff\uf8ff\uf8ff, \uf...d \uf8fe\uf8ff\uf8ff\uf8ff\uf8ff.\u2029she/her'> rendered (224 x 1) canvas when passed size (225,)!
@danschwarz
Copy link
Collaborator

please provide output of toot diag command. I want to see what versions of urwidgets and urwid you are running.

@ArthurHoaro
Copy link
Contributor Author

 ➜ toot diag        
## Toot Diagnostics

Current Date/Time: 2024-08-28 16:29:26 UTC
Toot version: 0.44.1
Platform: Linux-5.15.0-119-generic-x86_64-with-glibc2.35
Distro: Ubuntu 22.04.4 LTS
Python version: 3.10.12

Dependency versions:
 * beautifulsoup4: 4.10.0
 * click: 8.1.7
 * flake8: 7.0.0
 * pillow: 10.4.0
 * pytest: not installed
 * requests: 2.25.1
 * setuptools: 72.1.0
 * term-image: 0.7.2
 * tomlkit: 0.13.0
 * typing-extensions: 4.12.2
 * urwid: 2.6.15
 * urwidgets: 0.2.0
 * vermin: not installed
 * wcwidth: 0.2.5

Settings file path: /home/arthur/.config/toot/settings.toml
Config file path: /home/arthur/.config/toot/config.json

@danschwarz
Copy link
Collaborator

@AnonymouX47 this is with Urwidgets 0.2.0, any thoughts?

AnonymouX47 added a commit to AnonymouX47/urwidgets that referenced this issue Aug 31, 2024
- Fix: Use `urwid.calc_width()` instead of `urwid.Text.pack()[0]` to
  compute the screen column width of text.

  - Additionally results in a performance improvement.

Avoids buggy behaviour of `Text.pack()`
(see urwid/urwid#924) and
fixes ihabunek/toot#499.
AnonymouX47 added a commit to AnonymouX47/urwidgets that referenced this issue Aug 31, 2024
- Fix: Use `urwid.calc_width()` instead of `urwid.Text.pack()[0]` to
  compute the screen column width of text.

  - Additionally results in a performance improvement.

Avoids buggy behaviour of `Text.pack()`
(see urwid/urwid#924) and
fixes ihabunek/toot#499.
@AnonymouX47
Copy link
Contributor

Hello!

I looked into the issue and found out it was due to the presence of the U+2029 (Paragraph Separator) codepoint in the user's bio (between "." and "she/her"), as I initially suspected. This is a really uncommon edge case but still deserves attention.

So, I dug further and realised the exception raised was due to the use of urwid.Text.pack() (which happens to be buggy with the use of Unicode line breaks; reported in urwid/urwid#924) for width computation by TextEmbed.

I've now switched to using urwid.calc_width() instead and released v0.2.1. This issue should now be fixed with the new version.

Thank you very much. 😃

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

No branches or pull requests

3 participants