[swift6][alamofire] Decode responses and write downloads off the main queue

Merged
SP
10d ago
+42-6

Fixes #25185.

For the Decodable (default) and URL (download) branches of AlamofireDecodableRequestBuilder.processRequest, Alamofire's completion handler now runs on a private concurrent background queue. The decoding or file writing happens there, and the result is then delivered with apiResponseQueue.async, so the delivery queue and everything callers observe stay the same.

The String, Data and Void branches are unchanged: they do no heavy work in the handler (Alamofire's serializers already run on its serialization queue).

One observable difference: a custom CodableHelper.decode override now runs off the main queue.

Verified downstream with an Alamofire URLProtocol stub and a Decodable probe that records the thread: decoding runs off the main thread, and the completion still arrives on the main thread with apiResponseQueue = .main. The alamofireLibrary sample builds.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/swift6*.yaml || exit
    
    Commit all changed files.
  • @mention the technical committee: @jgavris @ehyche @Edubits @jaz-ah @4brunu @dydus0x14

Summary by cubic

Decodes JSON responses and writes downloaded files off the main queue in AlamofireDecodableRequestBuilder. Previously this work ran in completion handlers on apiResponseQueue (main queue by default), so large responses blocked the UI. Now it runs on a private concurrent background queue, and the result is still delivered on apiResponseQueue, so callers observe no change. This fixes #25185.

The String, Data, and Void branches are unchanged. One observable difference: a custom CodableHelper.decode override now runs off the main queue.