Skip to content

WebInputStream: Honour a cancel that arrives while the macOS task is being created - #1748

Open
jdf wants to merge 1 commit into
juce-framework:developfrom
jdf:web-stream-cancel-before-task
Open

jdf wants to merge 1 commit into
juce-framework:developfrom
jdf:web-stream-cancel-before-task

Conversation

@jdf

@jdf jdf commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #1747.

URLConnectionState::cancel cancels whatever task the token holds, and start assigns the token only after creating and resuming the task, which for the first task in a process also constructs the shared NSURLSession. A cancel arriving in that interval cancelled an empty token, and start then waited out the whole connection timeout.

The connection state now records the cancel under the same mutex as the token, and start honours it right after the assignment, before anything waits. The Windows implementation already re-checks its cancel flag under the lock at each handle assignment; this brings macOS in line.

Reproduced on 9.0.2 with a stream toward a blackhole address cancelled from another thread 50 ms after connect() began: the first run after a macOS 26 guest booted took 10.19 s; with this change, two boots with that run first and nine more runs each stayed under 0.35 s. The interval is timing-dependent, so the test that shows it is the first request after boot rather than a unit test in this PR.

…being created

URLConnectionState::cancel cancels whatever task the token holds, and
start assigns the token only after creating and resuming the task, which
for the first task in a process also constructs the shared NSURLSession.
A cancel arriving in that interval cancelled an empty token, and start
then waited out the whole connection timeout.

The connection state now records the cancel under the same mutex as the
token, and start honours it right after the assignment, before anything
waits.
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