Layout never settles when the vertical scroll bar decides whether content overflows (re-layout on every frame)
まだ誰も着手していません。
評価
調査の方向性
Start by running the supplied minimal reproduction with app.run_test(size=(18, 5)); it instruments Screen._refresh_layout and shows the alternating scrollbar and widget-height states. Read Screen._refresh_layout and the layout/scrollbar behavior it invokes to understand why the screen keeps relaying out. Done means the layout settles for this case, idle layout counts stop increasing, and pilot.pause() can reach idle.
索引モデルが issue の本文から書いたものです。
説明
Hi! I hit this while writing generated tests against Textual's widgets. Some small layouts never settle. Showing the screen's vertical scroll bar takes 2 cells, which makes a percentage-width widget too narrow to have any text, so it's 0 rows tall, so nothing overflows, so the bar goes, and then the text wraps again and overflows. Textual re-lays the screen out on every update tick, indefinitely, and the widget alternates between the two states. This looks like the same kind of loop as #4141, which #4315 fixed, but this case still loops on main.
import asyncio
import time
import textual
from textual.app import App, ComposeResult
from textual.screen import Screen
from textual.widgets import Static
class FlipApp(App):
CSS = """
Static { width: 50%; padding: 0 4; }
"""
def compose(self) -> ComposeResult:
yield Static("abcdef")
async def main() -> None:
layouts = 0
states = []
original = Screen._refresh_layout
def counting_refresh_layout(self, *args, **kwargs):
nonlocal layouts
layouts += 1
result = original(self, *args, **kwargs)
if self.is_attached and self.query(Static):
states.append((self.show_vertical_scrollbar, self.query_one(Static).size.height))
return result
Screen._refresh_layout = counting_refresh_layout
app = FlipApp()
async with app.run_test(size=(18, 5)) as pilot:
await pilot.pause(0.2)
states.clear()
layouts = 0
await asyncio.sleep(1)
in_one_second = layouts
start = time.monotonic()
await pilot.pause()
pause_took = time.monotonic() - start
print(f"Textual {textual.__version__}")
print("(screen scroll bar shown, Static height) after the first 6 layouts:", states[:6])
print("screen layouts in one idle second:", in_one_second)
print(f"pilot.pause() took {pause_took:.2f} s")
asyncio.run(main())
Output on main (5e5b7ef), Python 3.13, macOS:
Textual 8.2.8
(screen scroll bar shown, Static height) after the first 6 layouts: [(False, 0), (True, 6), (False, 0), (True, 6), (False, 0), (True, 6)]
screen layouts in one idle second: 57
pilot.pause() took 1.02 s
On 8.2.7 it's the same: the same alternation, 51 layouts in the idle second. pilot.pause() took 0.12 s in that run, so the time it takes varies.
What users see:
- the widget flickers between two layouts, and the app uses CPU while idle;
- which layout a given frame shows depends on the clock;
- in tests,
pilot.pause()(throughwait_for_idle) can wait up to itsmax_sleepof 1 second, because the app is never idle.
I expected the layout to settle in one of the two states, for example by keeping the scroll bar once it has been shown for a layout that would otherwise loop. Adding Screen { scrollbar-gutter: stable; } to the CSS above avoids it: 0 layouts in the idle second, and pilot.pause() takes 0.02 s. I don't know the layout code well enough to suggest where to detect the loop, so I'm reporting it with the repro rather than a fix.
- 主要言語
- Python
- スター
- 37.7k
- フォーク
- 1.5k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Textualize/textual のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Textualize/textual#6790 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
Textualize/textual#6789 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Textualize/textual#6787 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Textualize/textual#6782 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
Textualize/textual#6778 · コメント 1 件 ·
Textualize/textual の issue をすべて見る
似ている issue
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskオープン
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
sandbox-quantum/switch#2163 ·
メンテナーはふだん 1 日以内に返信
-
bug pydanty:is-working
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
pydantic/pydantic-ai#13939 ·
メンテナーはふだん 1 日以内に返信
-
priority: low python
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
LearningCircuit/local-deep-research#8849 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
francescopace/espectre#223 ·
メンテナーはふだん 3 日以内に返信
-
good first issue Status: Triaged
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
canonical/imagecraft#538 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信