From ab4f97347096aa38bcef794949b31efc614c70dc Mon Sep 17 00:00:00 2001 From: Darren Ford Date: Wed, 27 Apr 2022 04:59:57 +1000 Subject: [PATCH] Reverted the multithreading improvements (Catalina bug 262) See bug report https://github.com/griff/metaz/issues/262 I was able to reproduce these issues on Catalina with the current 1.0.2 build. It appears Catalina has issues with the multithread changes I made. In order to expedite a fix for users, this patch reverts the changes made to make the RemoteData downloads multithreaded (commit d6a42540c45fc96e0c89e476d8ba98603e036c89) (Note this does not revert the URL cache changes made in the same which work on Catalina without issue) --- Framework/src/RemoteData.swift | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Framework/src/RemoteData.swift b/Framework/src/RemoteData.swift index 8fd6099..87d5df7 100644 --- a/Framework/src/RemoteData.swift +++ b/Framework/src/RemoteData.swift @@ -7,9 +7,6 @@ import Foundation -// Limit the number of simultaneous downloads -private let RemoteDownloadLimiter = DispatchSemaphore(value: 10) - // A URLSession that caches its results private let RemoteLoadSession: URLSession = { // Create URL Session Configuration @@ -28,6 +25,8 @@ private let RemoteLoadSession: URLSession = { }() @objc public class RemoteData : NSObject { + private static let queue = DispatchQueue(label: "io.metaz.RemoteDataQueue") + public let url : URL public let expectedMimeType : String @@ -110,11 +109,7 @@ private let RemoteLoadSession: URLSession = { let url = self.data!.url let expectedMimeType = self.data!.expectedMimeType - DispatchQueue.global(qos: .utility).async { - RemoteDownloadLimiter.wait() - defer { - RemoteDownloadLimiter.signal() - } + RemoteData.queue.async { var downloadData : Data?, responseError : NSError? let signal = DispatchSemaphore(value: 0)