Skip to content

test(zero-swift): count the busy main actor's time in slices when sending - #131

Merged
tmm merged 1 commit into
mainfrom
swift-busy-main-actor-slices
Nov 10, 2026
Merged

tmm merged 1 commit into
mainfrom
swift-busy-main-actor-slices

Conversation

@tmm

@tmm tmm commented Nov 10, 2026

Copy link
Copy Markdown
Member

Fixes the URLSessionTransportTests.sendsWhileTheMainActorIsBusy flake on main's iOS Simulator job at a6e11db (job), where only 2 of 200 frames arrived.

Cause. The whole test process stalled for about 20 s, and the check ran as the stall ended:

  • Consecutive Network.framework steps of one refused connection logged 8 s apart (30.96 → 39.22) and then 10.7 s apart (39.22 → 49.94).
  • Virtual list tests that don't use the network took 14–26 s in the same window.
  • The main actor's usleep(1 s) ran out during the stall, so the check ran before the frames' writer, which had stalled too, could catch up.

This isn't a transport bug: a writer on the main actor gets 0 frames out, and 2 got out.

Change. The main actor stays busy for 100 slices of 10 ms (the same 1 s budget) or until the frames are out, so a stall stretches only one slice.

Verification (iOS 26.2 simulator):

Scenario Before After
Test process SIGSTOPped for 3 s during the wait fails 3 of 3 (85, 114, 110 frames) passes 3 of 3
Writer put back on the main actor, as before #107 — still fails, with 0 frames
URLSessionTransportTests, 5 iterations — passes

Test-only, so no changeset.

…ding

URLSessionTransportTests.sendsWhileTheMainActorIsBusy failed on main's iOS
Simulator job at a6e11db with 2 of 200 frames. The whole test process
stalled for about 20 s then: consecutive Network.framework steps of one
connection logged 8 s and 10 s apart, and virtual list tests that don't
touch the network took 14 to 26 s. The main actor's usleep(1 s) ran out
during the stall, and the check ran before the frames' writer, stalled with
it, could catch up.

The main actor now stays busy for 100 slices of 10 ms, the same second,
or until the frames are out, so a stall stretches one slice. Stopping the
test process for 3 s during the wait failed the test 3 of 3 times before
(85, 114 and 110 frames) and passes it 3 of 3 times now. With the writer
back on the main actor, as before #107, it still fails with no frames.

Amp-Thread-ID: https://ampcode.com/threads/T-0d2ed206-a5dd-4f42-9b68-c56e6b23e8f6
Co-authored-by: tmm <tmm@tmm.dev>
@tmm
tmm merged commit 2941c0b into main Nov 10, 2026
15 checks passed
@tmm
tmm deleted the swift-busy-main-actor-slices branch November 10, 2026 23:29
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.

2 participants