Skip to content
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

[iOS] Use serial queue for execution of iOS keychain operations #791

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

adamgic
Copy link
Contributor

@adamgic adamgic commented Sep 20, 2024

Reason:
For iOS Keychain write function checks for existence of an item before performing changes, then it either:

  • adds new item (if item for key does not exist)
  • updates item if it exists

This makes write not an atomic operation on the storage. For performing operation we are using DispatchQueue.global(qos: .userInitiated), which returns concurrent queue. In case two concurrent writings happening on the same key, one of these may fail - checks for existence of entry for key, entry does not exist yet, tries to add new entry, but in the meantime concurrent write stores the entry and the add fails.

Change:
This PR changes DispatchQueue used for executing iOS Keychain operations: Use serial queue instead of concurrent for execution of iOS keychain operations to avoid concurrent writing issues.

Background:
Before this plugin was using main DispatchQueue, which was serial as well, but it is suggested by Apple documentation not to use main Thread to avoid blocking of the UI. For details see this PR: #536

…operations to avoid concurrent writing issues (write checks for existence of item to either add or update, if in the meantime item is added, update fails).
@diogosequeira94
Copy link

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants