Skip to content

test(ios): read the log store off the main actor, and time the simulator job out - #754

Draft
jkmassel wants to merge 1 commit into
trunkfrom
jkmassel/localization-tests-off-main-actor
Draft

jkmassel wants to merge 1 commit into
trunkfrom
jkmassel/localization-tests-off-main-actor

Conversation

@jkmassel

@jkmassel jkmassel commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

EditorLocalizationTests reads its missing-translation reports back out of the system log with OSLogStore. That read is a synchronous round trip to the log daemon, and the suite made it on the main actor. While the daemon takes its time, no other @MainActor test in the run can make progress, and the ones waiting on a deadline fail.

Changes

  • Read the log store on a thread of its own, with a 30-second deadline. missingTranslationReports(forKeyNamed:since:) is now nonisolated and async. The read runs on a dispatch queue, and the test stops waiting for it — and fails, saying so — if the daemon hasn't answered in time. A dispatchPrecondition keeps the read from moving back to the main queue.
  • Restore the global localization state before reading. Each test did its lookups and its read inside withLocalization. The read now comes after, so no test holds EditorLocalization.localize or EditorLogger.shared across a suspension, where another suite's main-actor test could run against them.
  • Give the iOS Simulator job a 20-minute timeout. A healthy run takes a few minutes. One whose main thread is stuck neither fails nor finishes: build 3111 held its agent for 48 minutes.

How we found it

Running the simulator suite with a development machine's CPUs saturated stalled it. sample on the xctest process showed the main thread in one place for all 2,665 samples:

EditorLocalizationTests.missingTranslationReports(forKeyNamed:since:)
OSLogStore.getEntries(with:at:matching:)
-[OSLogCurrentProcessEnumerator initWithOptions:predicate:position:]
xpc_connection_send_message_with_reply_sync

Three @MainActor suites were still unfinished four minutes in. With EditorLocalizationTests skipped, the same run under the same load passed in 7 seconds. Both runs were on #747's branch.

This is not what stalled #747's simulator job for 46 minutes. That was Swift Testing working out the difference between two megabyte payloads after a failed ==, fixed on that branch in 9bba62d. The job timeout here bounds either kind of stall.

Test plan

  • swift test --filter EditorLocalizationTests: 8 tests pass.
  • The give-up path. With the read made to block for 6 seconds and the deadline cut to 1, each of the four log-reading tests fails after 1.07 seconds with The log store didn't answer within 1 seconds, and the other four pass.
  • SwiftLint is clean on EditorLocalizationTests.swift, and Prettier on .buildkite/pipeline.yml.

…tor job out

`EditorLocalizationTests` reads its reports back with `OSLogStore`, a
synchronous round trip to the log daemon, and did so on the main actor.
On a loaded machine the daemon can take minutes to answer. For as long
as it did, no other main-actor test in the run could make progress, and
the ones waiting on a deadline failed.

The read now runs on a thread of its own and gives up after 30 seconds.
Each test restores the global localization state before it reads, so
none holds that state across a suspension.

The iOS Simulator job also gets a 20-minute timeout. A run whose main
thread is stuck neither fails nor finishes, and one held its agent for
48 minutes.
@jkmassel jkmassel added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. iOS labels Oct 2, 2026
@jkmassel jkmassel self-assigned this Oct 2, 2026
@wpmobilebot

Copy link
Copy Markdown

XCFramework Build

This PR's XCFramework is available for testing. Add the following to your Package.swift:

.package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/754")

Built from c4e9793

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

Labels

iOS [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants