Skip to content

testing: Wait for a window to show on Linux before a step acts on it - #3110

Merged
madcodelife merged 1 commit into
mainfrom
linux-gallery-nav-flaky
Nov 24, 2026
Merged

madcodelife merged 1 commit into
mainfrom
linux-gallery-nav-flaky

Conversation

@madcodelife

@madcodelife madcodelife commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Description

The Linux workflow's step "Run the examples' tests in GTK windows" fails now and then on main, always in a gallery test's beforeEach, on the first press after open():

  • run 45313340466: storage.test.tsx › clearing the storage asks first: `role:button[Storage]` is not on screen (it has no native view)
  • run 45298744312: form.test.tsx, two tests: `label:Input` is not on screen (it has no native view)

In both, the screen texts listed after the error are the gallery's Home, so the row is in the app's tree; only its native view has no place on screen.

Root cause

Since window model v2, the gallery's first window is a window of the app's own (mount(() => <Window id="main">…)). On Linux such a window opens hidden (window::open, pending: Some(false)) and shows with its first frame: on the commit after the one that opened it (batch_applied) or FIRST_FRAME (150 ms) after it opened. Until then its views are not drawable, and LinuxNative::bounds returns None for them (!view.is_drawable()), which is the step's "it has no native view".

The test agent takes the app as quiet once no batch came for QUIET (100 ms) and nothing the platform changes by itself is going on (Agent::changing: animating() || opening()). #2727 added Native::opening for exactly this, and implemented it on macOS only; its description notes that Linux (FIRST_FRAME) also keeps a new window hidden until its first frame. On Linux opening() kept its default false, so when the app's first render is one commit, open() resolves about 100 ms after it, before the 150 ms wait runs out, and the first press finds the row with no drawable view. Whether a second commit comes in time decides the run, which is why it fails only sometimes, and more often on a busy runner, where the 150 ms timer fires late.

Fix

LinuxNative::opening reads window::opening: whether a window of the app's own is still waiting for its first frame (AppWindow::pending is Some). A step then waits for the window to show as it waits for an animation, as on macOS. The wait ends by itself: showing, hiding or the FIRST_FRAME timer clears pending, and SETTLE (2 s) still bounds every step. A window that is shown costs nothing.

The developer guide and the testing guide (English and zh-CN) now say that Linux steps wait for an opening window too.

Public API

None. Native::opening exists since #2727; this implements it for the Linux agent.

How to Test

cargo test -p nsh-platform-linux --lib window::tests::a_new_window_is_opening_until_its_first_frame
cargo clippy -p nsh-platform-linux -p nsh-linux-host -p nsh-linux-app --all-targets
cargo clippy -p nsh-platform-linux --all-targets --features dev
gh workflow run linux.yml --ref linux-gallery-nav-flaky

window::tests::a_new_window_is_opening_until_its_first_frame checks that a new window is opening until the commit after the one that opened it is mounted, and, without one, until FIRST_FRAME runs out.

Verification

  • Linux workflow on this branch, workflow_dispatch run 45371761496: check and gpui-gallery pass. window::tests::a_new_window_is_opening_until_its_first_frame passes in both cargo test -p nsh-platform-linux runs; clippy is clean; every example test file in GTK windows passes, form.test.tsx 9/9 and storage.test.tsx 2/2 among them.
  • Linux workflow on main after the merge (b4c792510), workflow_dispatch run 45374559502: check and gpui-gallery pass, the new test included, and every example test file in GTK windows passes.

The app's `<Window>` opens hidden on Linux until the commit after the one
that opened it is mounted, or `FIRST_FRAME` (150 ms) after it opened. Its
views are not drawable until then, so `LinuxNative::bounds` has nothing to
give and a step fails with "is not on screen (it has no native view)".
The agent took the app as quiet after 100 ms without a batch, before that
wait ran out: `Native::opening` kept its default on Linux.

`LinuxNative::opening` now reads whether a window of the app's own is still
waiting for its first frame, as macOS does since #2727.
@madcodelife
madcodelife merged commit b4c7925 into main Nov 24, 2026
10 of 15 checks passed
@madcodelife
madcodelife deleted the linux-gallery-nav-flaky branch November 24, 2026 10:24
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 this pull request may close these issues.

1 participant