Skip to content

test_launcher_storage: the Mac window's layout check is flaky on CI (fixed 50 ms waits) #445

Closed

Description

@v0lumehi

dm/ios/tests/test_launcher_storage.py fails now and then on GitHub's runners, in the Mac settings window's layout check (launcher_layout_check.swift, from 1e207fa / d919b4b):

FAIL native Form fits its measured height (advanced=true, width=560.0, height=1282.0)
launcher storage: 1 failed

Evidence that it's timing, not code:

Likely cause: measure() gives SwiftUI a fixed RunLoop.current.run(until: Date().addingTimeInterval(0.05)) after each layout change, and then reads the fit callback's extra. On a 3-vCPU runner, 50 ms isn't always enough for the grouped Form to finish measuring after Advanced opens, so extra is still the old value.

Possible fix: run the loop in small steps until extra stops changing (for example three 10 ms steps in a row with the same value), with an upper bound of a second or two, instead of one fixed 50 ms. The check stays as strict; it only waits for the layout to settle. I can't reproduce the failure locally, so I'd rather leave the fix to someone who can watch it on a runner, or I can open a PR and let CI show it over a few runs.

Activity

  1. seedds commented on Oct 28, 2026

    @seedds
    Owner

    Fixed in e8f3a8f.

    Cause. Timing each fit callback shows SwiftUI reporting the Form's height twice per layout: an estimate first, then the measured rows a few ms later (locally at advanced=true, width=560: 624 at ~29 ms, then 608 at ~36 ms). The CI height of 1282 is 660 plus such an estimate, so the fixed 50 ms wait read the estimate and the resize to that height could not fit. In addition, each measure()'s hosting view stayed alive (autoreleased, never drained) and laid out its Form again on every later change of window.advanced, adding main-thread work on a small runner.

    Fix (test only, dm/ios/tests/launcher_layout_check.swift):

    • After each step, the check runs the loop in 10 ms steps until the reported value meets that step's expectation (reported / fits / grew or shrank) and has held for 0.2 s, at most 5 s. The checks are as strict as before: with a deliberate 16 pt misfit all four "fits its measured height" checks still fail.
    • Each measurement runs in its own autoreleasepool, so earlier views are freed.

    Locally the check passes 10/10 standalone runs and in test_launcher_storage.py; it takes ~4 s instead of ~1 s. The CI flake itself could not be reproduced locally (the old code passed even with 1 ms waits under throttled load), so if it shows up again on a runner, reopen this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions