parse-community / Parse-Swift

The Swift SDK for Parse Platform (iOS, macOS, watchOS, tvOS, Linux, Android, Windows)
https://parseplatform.org
MIT License
308 stars 69 forks source link

fix: allow url async calls to run in parallel #394

Closed cbaker6 closed 2 years ago

cbaker6 commented 2 years ago

New Pull Request Checklist

Issue Description

Since async/await calls were introduced it made it a lot easier developers to make many async calls in parallel. Depending on how these async calls are made it's possible there can be a race condition in session delegates.

Also fixes a memory leak issue with Parse URL Session.

Related issue: #347

Approach

Use an actor for the url session delegates to ensure thread safety.

The updates make the test suite pass Xcode 14 beta 5 & 6.

TODOs before merging

parse-github-assistant[bot] commented 2 years ago

Thanks for opening this pull request!

cbaker6 commented 2 years ago

@vdkdamian can you try this branch out and let me know if you still see the issue you had?

codecov[bot] commented 2 years ago

Codecov Report

Merging #394 (e52969c) into main (e3e861d) will increase coverage by 0.43%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #394      +/-   ##
==========================================
+ Coverage   89.28%   89.72%   +0.43%     
==========================================
  Files         157      157              
  Lines       14970    15072     +102     
==========================================
+ Hits        13366    13523     +157     
+ Misses       1604     1549      -55     
Impacted Files Coverage Δ
Sources/ParseSwift/API/API+Command.swift 89.38% <100.00%> (+0.17%) :arrow_up:
...urces/ParseSwift/API/ParseURLSessionDelegate.swift 100.00% <100.00%> (+84.21%) :arrow_up:
Sources/ParseSwift/Extensions/URLSession.swift 80.46% <100.00%> (+3.29%) :arrow_up:
Sources/ParseSwift/Parse.swift 91.35% <100.00%> (+0.07%) :arrow_up:
Sources/ParseSwift/Objects/ParseObject.swift 87.44% <0.00%> (+0.14%) :arrow_up:
Sources/ParseSwift/Objects/ParseUser.swift 86.34% <0.00%> (+0.16%) :arrow_up:
Sources/ParseSwift/LiveQuery/ParseLiveQuery.swift 76.75% <0.00%> (+0.58%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

vdkdamian commented 2 years ago

@vdkdamian can you try this branch out and let me know if you still see the issue you had?

Yes, give me some time. I'll try it as fast as possible