Skip to content

Commit

Permalink
Fix race condition crash on processPendingRequests
Browse files Browse the repository at this point in the history
  • Loading branch information
sukov committed Aug 12, 2024
1 parent feaa320 commit c9e6c00
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Source/ResourceLoaderDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ final class ResourceLoaderDelegate: NSObject, AVAssetResourceLoaderDelegate, URL

private var session: URLSession?
private var response: URLResponse?
private var pendingRequests = Set<AVAssetResourceLoadingRequest>()
private let queue = DispatchQueue(label: "com.gcd.CachingPlayerItemQueue", qos: .userInitiated, attributes: .concurrent)
private var pendingRequests: Set<AVAssetResourceLoadingRequest> {
get { queue.sync { return pendingRequestsValue } }
set { queue.async(flags: .barrier) { [weak self] in self?.pendingRequestsValue = newValue } }
}
private var pendingRequestsValue = Set<AVAssetResourceLoadingRequest>()
private var isDownloadComplete = false

private let url: URL
Expand Down

0 comments on commit c9e6c00

Please sign in to comment.