-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Swift concurrency safety #1376
Commits on Mar 4, 2024
-
Configuration menu - View commit details
-
Copy full SHA for a554e30 - Browse repository at this point
Copy the full SHA a554e30View commit details -
Configuration menu - View commit details
-
Copy full SHA for d42c494 - Browse repository at this point
Copy the full SHA d42c494View commit details -
Add lock around accessing OpRepo delta queue
* Add lock around appending to the queue * Add lock around entire logic of flushing the delta queue, including enqueuing and flushing in the executors
Configuration menu - View commit details
-
Copy full SHA for 96b1ad7 - Browse repository at this point
Copy the full SHA 96b1ad7View commit details -
Synchronize the background tasks dictionary
There was a report of a crash related to this dictionary and while I have not been able to reproduce by hammering many threads to call methods manipulating the tasks dictionary, access to them should be synchronized.
Configuration menu - View commit details
-
Copy full SHA for 93435a6 - Browse repository at this point
Copy the full SHA 93435a6View commit details -
Properties model: add locking to tags dictionary
I was able to create crashes by hammering threads to add tags concurrently. Adding the lock prevented crashes, and behavior seems as expected. Unfortunately, the crashes were very flaky when trying to reproduce in tests, they would crash in much less than 50% of runs. Producing the crashes in the example app was much more consistent. Hence why there is no unit test to reproduce this.
Configuration menu - View commit details
-
Copy full SHA for a21404f - Browse repository at this point
Copy the full SHA a21404fView commit details -
Identity model: add locking to aliases dictionary
I was able to create crashes by hammering threads to add aliases and get aliases concurrently. Adding the lock prevented crashes, and behavior seems as expected. I also had to lock the getters for onesignalId and externalId Unfortunately, the crashes were very flaky when trying to reproduce in tests, they would crash in much less than 50% of runs. Producing the crashes in the example app was much more consistent. Hence why there is no unit test to reproduce this.
Configuration menu - View commit details
-
Copy full SHA for 3183463 - Browse repository at this point
Copy the full SHA 3183463View commit details -
Property Executor: Add private dispatch queue
* Reproduced crashes by creating multiple async threads that added and removed tags concurrently. * Added a private dispatch queue to synchronize access to the delta queue and request queue. * Crashes no longer happened after this change. * It is possible for the executor to be flushing while a client response is received and modify the request queue. * Additionally, there are some code paths that enqueue and update request but does not go through the operation repo, such as updating session count at the start of a new session.
Configuration menu - View commit details
-
Copy full SHA for cb88aa6 - Browse repository at this point
Copy the full SHA cb88aa6View commit details -
OpRepo: Use private dispatch queue instead of lock
* In a previous commit, an unfair lock was used to synchronize access to the delta queue and synchronize flushing behavior * A dispatch queue seems more appropriate for the Operation Repo to use considering it already polls and flushes on a global queue. * Without the lock or dispatch queue, I reproduced crashes by creating multiple async threads that either added tags or called to flush the operation repo. * With the dispatch queue, those crashes do no happen and behavior seems as expected.
Configuration menu - View commit details
-
Copy full SHA for c45c081 - Browse repository at this point
Copy the full SHA c45c081View commit details